Comments (1)
Some tips on dealing with StructuredOutputError from https://magentic.dev/structured-outputs/#json-schema
If a StructuredOutputError is raised often, this indicates that the LLM is failing to match the schema. The traceback for these errors includes the underlying pydantic ValidationError which shows in what way the received response was invalid. To combat these errors there are several options
- Add descriptions or examples for individual fields to demonstrate valid values.
- Simplify the output schema, including using more flexible types (e.g. str instead of datetime) or allowing fields to be nullable with | None.
- Switch to a "more intelligent" LLM. See Configuration for how to do this.
You could also retry the request using https://github.com/jd/tenacity or https://github.com/hynek/stamina . This is less effective for @prompt_chain
if it is failing at some intermediate step.
There's an open issue for having the LLM adjust its output based on the error #166
If none of the above helps, could you please share some example code to recreate the issue. Thanks
from magentic.
Related Issues (20)
- Magentic doesn't recognize function when using `mistral/mistral-large-latest` via `litellm` HOT 6
- Async completion doesn't work for non-OpenAI LiteLLM model when using function calling HOT 4
- Add more tests for LitellmChatModel tool calls and async HOT 1
- Support Mistral API HOT 2
- Retry on failure to parse LLM output HOT 4
- Support Gemini via Vertex AI
- Support Gemini via Google Generative AI HOT 1
- Add Anthropic backend
- Expose LiteLLM supported params for LiteLLM Backend HOT 5
- Are there some models in ollama can support function calling or object return? HOT 6
- Question: Can I use Ollama for function calling through magentic HOT 2
- Add tests for ollama to github actions workflow
- Ollama tool calls / structured output via LiteLLM are unreliable
- `magentic` doesn't allow manual error handling when input arguments don't match tool schema HOT 5
- Tool use not working for `AnthropicChatModel` HOT 1
- Confusing function calling with `AnthropicChatModel` HOT 2
- Allow custom_llm_parameter with LiteLLM backend HOT 2
- How to do both text output and FunctionCall in the same request? HOT 1
- Best way to generate a list of multiple objects? Currently, I have defined a list class that uses text to specify keys/values.... HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magentic.