File tree Expand file tree Collapse file tree 5 files changed +31
-7
lines changed Expand file tree Collapse file tree 5 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export const zerox = async ({
6464 imageFormat = "png" ,
6565 imageHeight,
6666 llmParams = { } ,
67+ reasoning_effort,
6768 maintainFormat = false ,
6869 maxImageSize = 15 ,
6970 maxRetries = 1 ,
@@ -79,6 +80,10 @@ export const zerox = async ({
7980 trimEdges = true ,
8081} : ZeroxArgs ) : Promise < ZeroxOutput > => {
8182 let extracted : Record < string , unknown > | null = null ;
83+ // If reasoning is provided, add to llmParams
84+ if ( reasoning_effort ) {
85+ llmParams = { ...llmParams , reasoning_effort } ;
86+ }
8287 let extractedLogprobs : LogprobPage [ ] = [ ] ;
8388 let inputTokenCount : number = 0 ;
8489 let outputTokenCount : number = 0 ;
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ export default class OpenAIModel implements ModelInterface {
9696 priorPage,
9797 prompt,
9898 } : CompletionArgs ) : Promise < CompletionResponse > {
99- const systemPrompt = prompt || SYSTEM_PROMPT_BASE ;
99+ const systemPrompt = prompt || SYSTEM_PROMPT_BASE ;
100100
101101 // Default system message
102102 const messages : any = [ { role : "system" , content : systemPrompt } ] ;
@@ -120,13 +120,18 @@ export default class OpenAIModel implements ModelInterface {
120120 messages . push ( { role : "user" , content : imageContents } ) ;
121121
122122 try {
123+ // If model is GPT-5 and reasoning_effort is provided, add it to payload
124+ let payload : any = {
125+ messages,
126+ model : this . model ,
127+ ...convertKeysToSnakeCase ( this . llmParams ?? null ) ,
128+ } ;
129+ if ( this . model && this . model . startsWith ( "gpt-5" ) && this . llmParams ?. reasoning_effort ) {
130+ payload . reasoning_effort = this . llmParams . reasoning_effort ;
131+ }
123132 const response = await axios . post (
124133 "https://api.openai.com/v1/chat/completions" ,
125- {
126- messages,
127- model : this . model ,
128- ...convertKeysToSnakeCase ( this . llmParams ?? null ) ,
129- } ,
134+ payload ,
130135 {
131136 headers : {
132137 Authorization : `Bearer ${ this . apiKey } ` ,
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export interface ZeroxArgs {
2828 imageHeight ?: number ;
2929 imageFormat ?: "png" | "jpeg" ;
3030 llmParams ?: Partial < LLMParams > ;
31+ reasoning_effort ?: "minimal" | "low" | "medium" | "high" ;
3132 maintainFormat ?: boolean ;
3233 maxImageSize ?: number ;
3334 maxRetries ?: number ;
@@ -227,6 +228,7 @@ export interface GoogleLLMParams extends BaseLLMParams {
227228export interface OpenAILLMParams extends BaseLLMParams {
228229 logprobs : boolean ;
229230 maxTokens : number ;
231+ reasoning_effort ?: "minimal" | "low" | "medium" | "high" ;
230232}
231233
232234// Union type of all provider params
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ async def zerox(
3535 temp_dir : Optional [str ] = None ,
3636 custom_system_prompt : Optional [str ] = None ,
3737 select_pages : Optional [Union [int , Iterable [int ]]] = None ,
38+ reasoning_effort : Optional [str ] = None ,
3839 ** kwargs
3940) -> ZeroxOutput :
4041 """
@@ -76,6 +77,11 @@ async def zerox(
7677 raise FileUnavailable ()
7778
7879 # Create an instance of the litellm model interface
80+ if reasoning_effort is not None :
81+ allowed = {"minimal" , "low" , "medium" , "high" }
82+ if reasoning_effort not in allowed :
83+ raise ValueError (f"reasoning_effort must be one of { allowed } " )
84+ kwargs ["reasoning_effort" ] = reasoning_effort
7985 vision_model = litellmmodel (model = model ,** kwargs )
8086
8187 # override the system prompt if a custom prompt is provided
Original file line number Diff line number Diff line change @@ -92,7 +92,13 @@ async def completion(
9292 )
9393
9494 try :
95- response = await litellm .acompletion (model = self .model , messages = messages , ** self .kwargs )
95+ # If model is GPT-5 and reasoning_effort is provided, add it to kwargs
96+ call_kwargs = dict (self .kwargs )
97+ if self .model and self .model .startswith ("gpt-5" ) and "reasoning_effort" in call_kwargs :
98+ allowed = {"minimal" , "low" , "medium" , "high" }
99+ if call_kwargs ["reasoning_effort" ] not in allowed :
100+ raise ValueError (f"reasoning_effort must be one of { allowed } " )
101+ response = await litellm .acompletion (model = self .model , messages = messages , ** call_kwargs )
96102
97103 ## completion response
98104 response = CompletionResponse (
You can’t perform that action at this time.
0 commit comments