Skip to content

Commit

Permalink
fix: bring back body
Browse files Browse the repository at this point in the history
  • Loading branch information
grabbou committed Dec 16, 2024
1 parent bb1e7a4 commit a5b47d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/framework/src/providers/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type OpenAIProviderOptions = {
* otherwise you will get an error. Otherwise, use the one from `openai_response_functions.js` instead.
*/
export const openai = (options: OpenAIProviderOptions = {}): Provider => {
const { model = 'gpt-4o', options: clientOptions } = options
const { model = 'gpt-4o', options: clientOptions, body = {} } = options
const client = new OpenAI(clientOptions)

return {
Expand All @@ -36,6 +36,7 @@ export const openai = (options: OpenAIProviderOptions = {}): Provider => {
tools: mappedTools.length > 0 ? mappedTools : undefined,
temperature,
response_format: responseAsStructuredOutput(response_format),
...body,
})

const message = response.choices[0].message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type OpenAIProviderOptions = BaseOpenAIProviderOptions & {
* but tools as response to enforce the right JSON schema.
*/
export const openai = (options: OpenAIProviderOptions): Provider => {
const { model, options: clientOptions, strictMode = false } = options
const { model, options: clientOptions, strictMode = false, body = {} } = options
const client = new OpenAI(clientOptions)

return {
Expand All @@ -45,6 +45,7 @@ export const openai = (options: OpenAIProviderOptions): Provider => {
messages,
temperature,
tool_choice: 'required',
...body,
})

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/framework/src/providers/openrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const openrouter = (options: OpenRouterOptions = {}): Provider => {
model = 'meta-llama/llama-3.1-405b-instruct',
structured_output = true,
options: clientOptions,
body = {},
} = options
const openAiOptions = {
model,
Expand All @@ -38,11 +39,13 @@ export const openrouter = (options: OpenRouterOptions = {}): Provider => {
* support structured output.
*/
body: {
...body,
provider: {
/**
* @see https://openrouter.ai/docs/provider-routing#required-parameters-_beta_
*/
require_parameters: true,
...body?.provider,
},
},
}
Expand Down

0 comments on commit a5b47d1

Please sign in to comment.