1from kern.agent import Agent
2from kern.db.postgres import PostgresDb
3from kern.media import File
4from kern.models.openai.responses import OpenAIResponses
5
6# Setup the database for the Agent Session to be stored
7db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
8db = PostgresDb(db_url=db_url)
9
10agent = Agent(
11 model=OpenAIResponses(id="gpt-5-mini"),
12 db=db,
13 tools=[{"type": "file_search"}, {"type": "web_search_preview"}],
14 markdown=True,
15)
16
17agent.print_response(
18 "Summarize the contents of the attached file and search the web for more information.",
19 files=[File(url="https://kern-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")],
20)
21
22# Get the stored Agent session, to check the response citations
23session = agent.get_session()
24if session and session.runs and session.runs[-1].citations:
25 print("Citations:")
26 print(session.runs[-1].citations)