Comments (4)
I did not try this with structured outputs, but this worked for me when setting the response format to json
'model' => 'gpt-4o',
'response_format' => [
'type' => 'json_object'
],
Cross reference to this post
from client.
Does this package support the new response_format = 'json_schema' option (Structured Outputs).
Would you be able to send the schema in via the $client->chat()->create method as an array?
As today, it does not.
The OpenAI announce is quite new, and this library has not been updated yet.
See OpenAI blog post for details: https://openai.com/index/introducing-structured-outputs-in-the-api/
Note that type: json_object
is a different thing, here we are talking about the new type: json_schema
from client.
+1 to add support for this feature
from client.
This can be resolved by passing the json schema as parameter:
'model' => 'gpt-4o',
'response_format' => [
'type' => 'json_schema',
'json_schema' => $jsonSchema,
]
For example:
[
'model' => 'gpt-4o',
'message' => 'what is 1 + 1?',
'response_format' => [
'type' => 'json_schema',
'json_schema' => [
"name" => "math_response",
"strict" => true,
"schema" => [
"type" => "object",
"properties" => [
"steps" => [
"type" => "array",
"items" => [
"type" => "object",
"properties" => [
"explanation" => [
"type" => "string"
],
"output" => [
"type" => "string"
]
],
"required" => [
"explanation",
"output"
],
"additionalProperties" => false
]
],
"final_answer" => [
"type" => "string"
]
],
"required" => [
"steps",
"final_answer"
],
"additionalProperties" => false
],
]
]
];
from client.
Related Issues (20)
- [Bug]: Empty body in HttpTransporter::requestObject ($response->getBody()->getContents()) when using Guzzle client with Middleware::log()
- [Bug]: \OpenAI\Resources\VectorStoresFileBatches::cancel should POST, missing `cancel` path component
- [Bug]: No result with assistant file search
- [Bug]: Assistant API calls do not complete in version 0.10.1. HOT 1
- [Bug]: Unsupported operand types: string * int
- How to Properly Send and Attach a File to client->chat()->create with Model gpt-4o-2024-05-13
- Missing support for 'thread.run.incomplete' event, for streamed runs
- [Bug]: Undefined text when using Azure OpenAI
- object parameter problem
- [Question] What's the best way to fake OpenAI::threads()->runs()->createStreamed() response
- [Bug]: Cannot use `assistants=v2` HOT 1
- [Bug]: Undefined array keys in ThreadMessageResponseContentTextAnnotationFileCitationObject.php
- [Bug]: Logprobs property is missing in Chat\CreateResponseChoice
- [Bug]: Undefined array key "file_id HOT 4
- [Bug]: Undefinded array key "created" in src/Responses/Models/RetrieveResponse
- [Bug]: Repo files not matching zip or what is in composer
- How send async
- [Bug]: failed to upload files with Azure OpenAI HOT 1
- [Bug]: Error: First argument to "Http\Message\MultipartStream\MultipartStreamBuilder::createStream()" must be a string, resource or StreamInterface.
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 client.