llama-index-llms-openai 0.4.1__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llama-index-llms-openai
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: llama-index llms openai integration
5
5
  Author: llama-index
6
6
  License-Expression: MIT
@@ -36,7 +36,6 @@ from typing import (
36
36
  Dict,
37
37
  Generator,
38
38
  List,
39
- Literal,
40
39
  Optional,
41
40
  Protocol,
42
41
  Sequence,
@@ -143,6 +142,9 @@ class OpenAIResponses(FunctionCallingLLM):
143
142
  model: name of the OpenAI model to use.
144
143
  temperature: a float from 0 to 1 controlling randomness in generation; higher will lead to more creative, less deterministic responses.
145
144
  max_output_tokens: the maximum number of tokens to generate.
145
+ reasoning_options: Optional dictionary to configure reasoning for O1 models.
146
+ Corresponds to the 'reasoning' parameter in the OpenAI API.
147
+ Example: {"effort": "low", "summary": "concise"}
146
148
  include: Additional output data to include in the model response.
147
149
  instructions: Instructions for the model to follow.
148
150
  track_previous_responses: Whether to track previous responses. If true, the LLM class will statefully track previous responses.
@@ -193,6 +195,10 @@ class OpenAIResponses(FunctionCallingLLM):
193
195
  description="The maximum number of tokens to generate.",
194
196
  gt=0,
195
197
  )
198
+ reasoning_options: Optional[Dict[str, Any]] = Field(
199
+ default=None,
200
+ description="Optional dictionary to configure reasoning for O1 models. Example: {'effort': 'low', 'summary': 'concise'}",
201
+ )
196
202
  include: Optional[List[str]] = Field(
197
203
  default=None,
198
204
  description="Additional output data to include in the model response.",
@@ -249,10 +255,6 @@ class OpenAIResponses(FunctionCallingLLM):
249
255
  api_key: str = Field(default=None, description="The OpenAI API key.")
250
256
  api_base: str = Field(description="The base URL for OpenAI API.")
251
257
  api_version: str = Field(description="The API version for OpenAI API.")
252
- reasoning_effort: Optional[Literal["low", "medium", "high"]] = Field(
253
- default=None,
254
- description="The effort to use for reasoning models.",
255
- )
256
258
  context_window: Optional[int] = Field(
257
259
  default=None,
258
260
  description="The context window override for the model.",
@@ -269,7 +271,7 @@ class OpenAIResponses(FunctionCallingLLM):
269
271
  model: str = DEFAULT_OPENAI_MODEL,
270
272
  temperature: float = DEFAULT_TEMPERATURE,
271
273
  max_output_tokens: Optional[int] = None,
272
- reasoning_effort: Optional[Literal["low", "medium", "high"]] = None,
274
+ reasoning_options: Optional[Dict[str, Any]] = None,
273
275
  include: Optional[List[str]] = None,
274
276
  instructions: Optional[str] = None,
275
277
  track_previous_responses: bool = False,
@@ -310,7 +312,7 @@ class OpenAIResponses(FunctionCallingLLM):
310
312
  model=model,
311
313
  temperature=temperature,
312
314
  max_output_tokens=max_output_tokens,
313
- reasoning_effort=reasoning_effort,
315
+ reasoning_options=reasoning_options,
314
316
  include=include,
315
317
  instructions=instructions,
316
318
  track_previous_responses=track_previous_responses,
@@ -409,9 +411,8 @@ class OpenAIResponses(FunctionCallingLLM):
409
411
  "user": self.user,
410
412
  }
411
413
 
412
- if self.model in O1_MODELS and self.reasoning_effort is not None:
413
- # O1 models support reasoning_effort of low, medium, high
414
- model_kwargs["reasoning_effort"] = {"effort": self.reasoning_effort}
414
+ if self.model in O1_MODELS and self.reasoning_options is not None:
415
+ model_kwargs["reasoning"] = self.reasoning_options
415
416
 
416
417
  # priority is class args > additional_kwargs > runtime args
417
418
  model_kwargs.update(self.additional_kwargs)
@@ -830,7 +831,10 @@ class OpenAIResponses(FunctionCallingLLM):
830
831
 
831
832
  # openai responses api has a slightly different tool spec format
832
833
  tool_specs = [
833
- {"type": "function", **tool.metadata.to_openai_tool()["function"]}
834
+ {
835
+ "type": "function",
836
+ **tool.metadata.to_openai_tool(skip_length_check=True)["function"],
837
+ }
834
838
  for tool in tools
835
839
  ]
836
840
 
@@ -27,7 +27,7 @@ dev = [
27
27
 
28
28
  [project]
29
29
  name = "llama-index-llms-openai"
30
- version = "0.4.1"
30
+ version = "0.4.3"
31
31
  description = "llama-index llms openai integration"
32
32
  authors = [{name = "llama-index"}]
33
33
  requires-python = ">=3.9,<4.0"