Introduction
Agents are autonomous programs that achieve tasks using language models.
Example: Research Agent
1
from bitca.agent import Agent
from bitca.model.openai import OpenAIChat
from bitca.tools.duckduckgo import DuckDuckGo
from bitca.tools.newspaper4k import Newspaper4k
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[DuckDuckGo(), Newspaper4k()],
description="You are a senior NYT researcher writing an article on a topic.",
instructions=[
"For a given topic, search for the top 5 links.",
"Then read each URL and extract the article text, if a URL isn't available, ignore it.",
"Analyse and prepare an NYT worthy article based on the information.",
],
markdown=True,
show_tool_calls=True,
add_datetime_to_instructions=True,
# debug_mode=True,
)
agent.print_response("Simulation theory", stream=True)2
pip install bitca openai duckduckgo-search newspaper4k lxml_html_cleanpython research_agent.pyCapturing the Agent’s response in a variable
from bitca.agent import Agent, RunResponse
from bitca.utils.pprint import pprint_run_response
agent = Agent(...)
# Run agent and return the response as a variable
response: RunResponse = agent.run("Simulation theory")
# Print the response in markdown format
pprint_run_response(response, markdown=True)RunResponse
RunResponse Attributes
Attribute
Type
Default
Description
Last updated