File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,9 +31,15 @@ const XAIResponsesHostedToolItem = Schema.Union([
3131 ) ,
3232] )
3333
34+ const Options = Schema . Struct ( {
35+ minP : Schema . optional ( Schema . Number ) ,
36+ } )
37+ export type OptionsInput = typeof Options . Type
38+
3439const Body = Schema . Struct ( {
3540 ...OpenResponses . OpenResponsesBody . fields ,
3641 top_k : Schema . optional ( Schema . Number ) ,
42+ min_p : Schema . optional ( Schema . Number ) ,
3743} )
3844
3945const adapter = {
@@ -58,13 +64,15 @@ const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request: LL
5864 message :
5965 "xAI requires explicit compaction through LLMClient.compact; automatic context management is not supported" ,
6066 } )
67+ const options = yield * ProviderShared . validateWith ( Schema . decodeUnknownEffect ( Options ) ) ( request . providerOptions ?? { } )
6168 const body = yield * OpenResponses . fromRequestWithAdapter ( request , adapter )
6269 // xAI Responses does not support penalties (they are ignored), but does support top_k.
6370 return {
6471 ...body ,
6572 presence_penalty : undefined ,
6673 frequency_penalty : undefined ,
6774 top_k : request . generation ?. topK ,
75+ min_p : options . minP ,
6876 }
6977} )
7078
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ import type { ProviderPackage } from "../provider-package.js"
1414export const id = ProviderID . make ( "xai" )
1515const baseURL = "https://api.x.ai/v1"
1616
17- export type XAIProviderOptionsInput = OpenAIOptionsInput & { readonly contextManagement ?: never }
17+ export type XAIProviderOptionsInput = OpenAIOptionsInput &
18+ XAIResponses . OptionsInput & { readonly contextManagement ?: never }
1819
1920export type LanguageModelOptions = Omit < RouteDefaultsInput , "providerOptions" > &
2021 ProviderAuthOption < "optional" > & {
Original file line number Diff line number Diff line change @@ -89,6 +89,14 @@ describe("xAI Responses route", () => {
8989 } ) ,
9090 )
9191
92+ it . effect ( "sends min_p from provider options" , ( ) =>
93+ Effect . gen ( function * ( ) {
94+ const prepared = yield * compileRequest ( LLM . request ( { model, prompt : "Hello" , providerOptions : { minP : 0.1 } } ) )
95+
96+ expect ( prepared . body . min_p ) . toBe ( 0.1 )
97+ } ) ,
98+ )
99+
92100 it . effect ( "parses xAI reasoning summaries" , ( ) =>
93101 Effect . gen ( function * ( ) {
94102 const response = yield * LLMClient . generate ( LLM . request ( { model, prompt : "Think" } ) ) . pipe (
You can’t perform that action at this time.
0 commit comments