mistral_reasoning_cot.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your Mistral API key
4
Run the example
Save the code above as
mistral_reasoning_cot.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Run mistral-large-latest with reasoning=True and use_json_mode=True, streaming the full chain-of-thought for a Fibonacci script walkthrough.
"""
Mistral Reasoning COT
=====================
Demonstrates built-in chain-of-thought reasoning with Mistral.
"""
from agno.agent import Agent
from agno.models.mistral import MistralChat
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
reasoning_agent = Agent(
model=MistralChat(id="mistral-large-latest"),
reasoning=True,
markdown=True,
use_json_mode=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
reasoning_agent.print_response(
"Give me steps to write a python script for fibonacci series",
stream=True,
show_full_reasoning=True,
)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno mistralai
Export your Mistral API key
export MISTRAL_API_KEY="your_mistral_api_key_here"
$Env:MISTRAL_API_KEY="your_mistral_api_key_here"
Run the example
mistral_reasoning_cot.py, then run:python mistral_reasoning_cot.py
Was this page helpful?