Skip to content

Commit

Permalink
Update Agent class
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Sep 26, 2024
1 parent 80ae78d commit 6eaec74
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cookbook/agents/structured_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MovieScript(BaseModel):
movie_agent = Agent(
model=OpenAIChat(id="gpt-4o"),
description="You help people write movie scripts.",
output_model=MovieScript,
response_model=MovieScript,
# debug_mode=True,
)

Expand Down
10 changes: 6 additions & 4 deletions cookbook/agents/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
# print(m)
# print("---")

# run: Iterator[RunResponse] = agent.run("What is the stock price of NVDA", stream=True)
# for chunk in run:
# print(chunk.content)
run: Iterator[RunResponse] = agent.run("What is the stock price of NVDA", stream=True)
for chunk in run:
print("---")
pprint(chunk.model_dump(exclude={"messages"}))
print("---")

# async def main():
# async for chunk in await agent.arun("What is the stock price of NVDA", stream=True):
# print(chunk.content)

# asyncio.run(main())
# agent.create_session()
agent.print_response("What is the stock price of NVDA?")
# agent.print_response("What is the stock price of NVDA?")
2 changes: 1 addition & 1 deletion phi/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def _run(
run_id=self.run_response.run_id,
content="Run started",
model=self.run_response.model,
event=RunEvent.run_start,
event=RunEvent.run_start.value,
)

# 2. Read existing session from storage
Expand Down
2 changes: 1 addition & 1 deletion phi/agent/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RunResponse(BaseModel):
tools: Optional[List[Dict[str, Any]]] = None
context: Optional[List[MessageContext]] = None
model: Optional[str] = None
event: RunEvent = RunEvent.agent_response
event: str = RunEvent.agent_response.value
created_at: int = Field(default_factory=lambda: int(time()))

model_config = ConfigDict(arbitrary_types_allowed=True, use_enum_values=True)

0 comments on commit 6eaec74

Please sign in to comment.