Agent with Object Response
Get Structured and Programmable Results from Your Agent
Agent with Object Response
agent_with_object_response.py
pythonCopyEditfrom beaconlabs import Agent, Task
from beaconlabs.client.tools import Search
from beaconlabs import ObjectResponse # Importing Object Response
class ANew(ObjectResponse):
title: str
content: str
class News(ObjectResponse):
news: list[ANew] # We want to get a list of ANew objects
task = Task(
"Find the latest OpenAI developments on the internet.",
tools=[Search],
response_format=News # Specifying the Response format we want
)
agent = Agent("Reporter")
agent.print_do(task)Processing the Results
agent_with_object_response.py
Running the Agent
1. Set Up Your Virtual Environment
2. Install Dependencies
3. Set Up Your OpenAI API Key
4. Run the Agent to Execute the Task
Last updated