-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add OpenAI's new structured output API #180
feat: add OpenAI's new structured output API #180
Conversation
Thanks @monotykamary for the PR! From what I see, it looks like your primary goal here is to attach a Is that right? Or did I miss something? If that's right, then I'm inclined to have that live on the LLMChain so other models benefit as well. Or optionally in a MessageProcessor for schema compliance. Oh, and thanks for fixing those bad tests! 😊 How did those get in there? 😅 |
It's essentially to implement structured outputs from OpenAI, which is more like
Wait, how? 🤔 We are using this exact code to structure our outputs for a scraper we have. |
OAI Structured Output requires the https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format |
Awesome! Thanks for walking me through that and thank you for the contribution! ❤️💛💙💜 |
* 'main' of github.com:brainlid/langchain: Add AWS Bedrock support to ChatAnthropic (#154) Handle functions with no parameters for Google AI (#183) Handle missing token usage fields for Google AI (#184) Handle empty text parts from GoogleAI responses (#181) Support system instructions for Google AI (#182) feat: add OpenAI's new structured output API (#180) Support strict mode for tools (#173) Do not duplicate tool call parameters if they are identical (#174) 🐛 cast tool_calls arguments correctly inside message_deltas (#175)
Do you know if this is going to be released anytime soon ? |
Hi @lud-wj, I keep intending to make a release soon. It will probably be a new RC because there's still a couple changes I want to make. That and I'm procrastinating writing the CHANGELOG. 😆 |
Alright, thank you! |
Don't forget that this is a package for working with LLMs! Here is something to get you started: I asked Claude to write the summary change log for ## v0.3.0 (Unreleased)
**Major Features:**
* Added AWS Bedrock support for Anthropic Claude integration
* Added support for OpenAI's new structured output API
* Added support for fallback handling when LLM services are overloaded
* Improved tool/function handling across providers:
- Strict mode for tools
- Better support for tool calls with parameters
- Improved error handling for function execution
- Support for functions with no parameters in Google AI
**Improvements:**
* Enhanced Google AI Support:
- Added safety settings configuration
- Added system instructions support
- Fixed handling of empty text parts and token usage
- Better handling of finish reasons
* Improved streaming reliability:
- Fixed streaming issues with Azure OpenAI Service
- Fixed OpenAI stream decode issues
- Fixed Ollama streaming response
* Better error handling and recovery:
- Improved handling of "Too many requests" from AWS Bedrock
- Better handling of overloaded service responses
- Enhanced function execution failure responses
**Breaking Changes:**
* Changed return value structure of `LLMChain.run/2`
* Added "processed_content" to ToolResult struct
**Documentation:**
* Improved documentation for all LLM providers
* Added examples for tool_choice in OpenAI and Anthropic
* Updated configuration documentation for API keys
* Added new examples and notebooks for image content chats |
Ha! You rock @vkryukov! I used your approach as a starting point and I'm prepping an RC.1 right now. |
Published the new RC release |
You can use git cliff to generate nice changelogs, since you are already using commit prefixes like |
What does this PR do?:
json_schema
Field toChatOpenAI
and Enhance Response Format Handlingmix test --include live_open_ai
Summary:
This pull request introduces a new
json_schema
field to theChatOpenAI
module, which enhances the response format handling capabilities by allowing for JSON Schema-based validation.Changes:
Field Definition:
field :json_schema, :map, default: nil
to theChatOpenAI
struct.:json_schema
.Response Format Handling:
set_response_format
function to account for cases whenjson_response
is true andjson_schema
is provided.json_response
is true andjson_schema
is not nil, the response format is set to includejson_schema
.json_response
is true butjson_schema
is nil, the response format defaults tojson_object
.json_response
is false, the response format is set totext
.Code Details:
Field Addition:
Response Format Modification: