Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/content/docs/user-guide/concepts/model-providers/ollama.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ factual_agent = Agent(model=factual_model)

### Structured Output

Ollama supports structured output for models that have tool calling capabilities. When you use [`Agent.structured_output()`](@api/python/strands.agent.agent#Agent.structured_output), the Strands SDK converts your Pydantic models to tool specifications that compatible Ollama models can understand.
Ollama supports structured output for models that have tool calling capabilities. When you pass `structured_output_model` parameter to the [agent invocation](@api/python/strands.agent.agent#Agent.__call__), the Strands SDK converts your Pydantic models to tool specifications that compatible Ollama models can understand.

```python
from pydantic import BaseModel, Field
Expand All @@ -219,19 +219,18 @@ ollama_model = OllamaModel(

agent = Agent(model=ollama_model)

result = agent.structured_output(
BookAnalysis,
"""
Analyze this book: "The Hitchhiker's Guide to the Galaxy" by Douglas Adams.
result = agent(
"""Analyze this book: "The Hitchhiker's Guide to the Galaxy" by Douglas Adams.
It's a science fiction comedy about Arthur Dent's adventures through space
after Earth is destroyed. It's widely considered a classic of humorous sci-fi.
"""
after Earth is destroyed. It's widely considered a classic of humorous sci-fi.""",
structured_output_model=BookAnalysis,
)

print(f"Title: {result.title}")
print(f"Author: {result.author}")
print(f"Genre: {result.genre}")
print(f"Rating: {result.rating}")
book_analysis: BookAnalysis = result.structured_output
print(f"Title: {book_analysis.title}")
print(f"Author: {book_analysis.author}")
print(f"Genre: {book_analysis.genre}")
print(f"Rating: {book_analysis.rating}")
```

## Tool Support
Expand Down
Loading