Reasoning
Reasoning Reasoning is an experimental feature that enables an Agent to think through a problem step-by-step before jumping into a response. The Agent works through different ideas, validating and cor
reasoning_agent.py
from bitca.agent import Agent
from bitca.model.openai import OpenAIChat
task = (
"Three missionaries and three cannibals need to cross a river. "
"They have a boat that can carry up to two people at a time. "
"If, at any time, the cannibals outnumber the missionaries on either side of the river, the cannibals will eat the missionaries. "
"How can all six people get across the river safely? Provide a step-by-step solution and show the solutions as an ascii diagram"
)
reasoning_agent = Agent(model=OpenAIChat(id="gpt-4o"), reasoning=True, markdown=True, structured_outputs=True)
reasoning_agent.print_response(task, stream=True, show_full_reasoning=True)Run the Reasoning Agent:
pip install -U bitca openai
export OPENAI_API_KEY=***
python reasoning_agent.pyHow to use reasoning
To add reasoning, set reasoning=True. When using reasoning with tools, do not use structured_outputs=True as gpt-4o cannot use tools with structured outputs.
Reasoning with tools
You can also use tools with a reasoning agent, but do not use structured_outputs=True as gpt-4o cannot use tools with structured outputs. Lets create a finance agent that can reason.
finance_reasoning.py
Run the script to see the output.
More reasoning examples
Logical puzzles
logical_puzzle.py
Run the script to see the output.
Mathematical proofs
mathematical_proof.py
Run the script to see the output.
Scientific research
scientific_research.py
Run the script to see the output.
Ethical dilemma
ethical_dilemma.py
Run the script to see the output.
Planning an itinerary
planning_itinerary.py
Run the script to see the output.
Creative writing
creative_writing.py
Run the script to see the output.
Last updated