You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if Token.js could support type: "json_schema" in response_format:
import{TokenJS}from"token.js";constt=newTokenJS();awaito.chat.completions.create({provider: "openai",model: "gpt-4o-mini",messages: [{role: "user",content: "Extract the name from the following text: 'John Doe'",},],response_format: {type: "json_schema",json_schema: {name: "test",schema: {type: "object",properties: {name: {type: "string",description: "The name of the person",},},},},},});
This works with the native client:
import{OpenAI}from"openai"consto=newOpenAI()awaito.chat.completions.create({model: "gpt-4o-mini",messages: [{role: "user",content: "Extract the name from the following text: 'John Doe'",},],response_format: {type: "json_schema",// Error, can only be "json_object" or "text"json_schema: {name: "test",schema: {type: "object",properties: {name: {type: "string",description: "The name of the person",},},},},},});
It looks like the json_schema type doesn't exist on the currently depended on openai version (4.52.2), so we probably need to update to the latest (4.82.2)
The text was updated successfully, but these errors were encountered:
Structured response seems to be working on openai now, but not on gemini models
consttokenjs=newTokenJS();asyncfunctiontest_structured_response(provider,model){constresponse=awaittokenjs.chat.completions.create({provider: provider,model: model,messages: [{role: "user",content: "Extract the name from the following text: 'John Doe'",},],response_format: {type: "json_schema",json_schema: {name: "test",schema: {type: "object",properties: {name: {type: "string",description: "The name of the person",},},},},},});console.log(provider,model,`\nresponse: ${response.choices[0].message.content}`);}test_structured_response("openai","gpt-4o-mini");// outputs {"name":"John Doe"}test_structured_response("gemini","gemini-2.0-flash-001");// outputs John Doe
It would be great if Token.js could support
type: "json_schema"
in response_format:This works with the native client:
Docs: https://platform.openai.com/docs/guides/structured-outputs?lang=javascript
It looks like the
json_schema
type doesn't exist on the currently depended onopenai
version (4.52.2), so we probably need to update to the latest (4.82.2)The text was updated successfully, but these errors were encountered: