llama-index-llms-openai 0.3.15__py3-none-any.whl → 0.3.17__py3-none-any.whl

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.
@@ -7,6 +7,7 @@ from typing import (
7
7
  Dict,
8
8
  Generator,
9
9
  List,
10
+ Literal,
10
11
  Optional,
11
12
  Protocol,
12
13
  Sequence,
@@ -217,6 +218,10 @@ class OpenAI(FunctionCallingLLM):
217
218
  default=False,
218
219
  description="Whether to use strict mode for invoking tools/using schemas.",
219
220
  )
221
+ reasoning_effort: Literal["low", "medium", "high"] = Field(
222
+ default="medium",
223
+ description="The effort to use for reasoning models.",
224
+ )
220
225
 
221
226
  _client: Optional[SyncOpenAI] = PrivateAttr()
222
227
  _aclient: Optional[AsyncOpenAI] = PrivateAttr()
@@ -248,6 +253,7 @@ class OpenAI(FunctionCallingLLM):
248
253
  pydantic_program_mode: PydanticProgramMode = PydanticProgramMode.DEFAULT,
249
254
  output_parser: Optional[BaseOutputParser] = None,
250
255
  strict: bool = False,
256
+ reasoning_effort: Literal["low", "medium", "high"] = "medium",
251
257
  **kwargs: Any,
252
258
  ) -> None:
253
259
  additional_kwargs = additional_kwargs or {}
@@ -281,6 +287,7 @@ class OpenAI(FunctionCallingLLM):
281
287
  pydantic_program_mode=pydantic_program_mode,
282
288
  output_parser=output_parser,
283
289
  strict=strict,
290
+ reasoning_effort=reasoning_effort,
284
291
  **kwargs,
285
292
  )
286
293
 
@@ -417,6 +424,15 @@ class OpenAI(FunctionCallingLLM):
417
424
  all_kwargs = {**base_kwargs, **self.additional_kwargs}
418
425
  if "stream" not in all_kwargs and "stream_options" in all_kwargs:
419
426
  del all_kwargs["stream_options"]
427
+ if self.model in O1_MODELS and base_kwargs.get("max_tokens") is not None:
428
+ # O1 models use max_completion_tokens instead of max_tokens
429
+ all_kwargs["max_completion_tokens"] = all_kwargs.get(
430
+ "max_completion_tokens", all_kwargs["max_tokens"]
431
+ )
432
+ all_kwargs.pop("max_tokens", None)
433
+ if self.model in O1_MODELS:
434
+ # O1 models support reasoning_effort of low, medium, high
435
+ all_kwargs["reasoning_effort"] = self.reasoning_effort
420
436
 
421
437
  return all_kwargs
422
438
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-llms-openai
3
- Version: 0.3.15
3
+ Version: 0.3.17
4
4
  Summary: llama-index llms openai integration
5
5
  License: MIT
6
6
  Author: llama-index
@@ -0,0 +1,7 @@
1
+ llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
+ llama_index/llms/openai/base.py,sha256=54dX1c9CgA9BNrKXEgrPv4cTV_vhDfkWUEUSa4Zcg6w,36587
3
+ llama_index/llms/openai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ llama_index/llms/openai/utils.py,sha256=se_tHHLsNW4u2Ei_25HRPAm1lmzv-kFp2r2WqqL_jfE,18858
5
+ llama_index_llms_openai-0.3.17.dist-info/METADATA,sha256=USfyABhywLWuyuIVoSI-5CRPBChHaL6P3I7tzqLqAok,3321
6
+ llama_index_llms_openai-0.3.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
+ llama_index_llms_openai-0.3.17.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
- llama_index/llms/openai/base.py,sha256=uvYlJz3TXZIsptoicHCSv8zIc8wK187RhY1lwU7lOVc,35777
3
- llama_index/llms/openai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- llama_index/llms/openai/utils.py,sha256=se_tHHLsNW4u2Ei_25HRPAm1lmzv-kFp2r2WqqL_jfE,18858
5
- llama_index_llms_openai-0.3.15.dist-info/METADATA,sha256=CUPpMlsEjZ1KFCkEChWIOnbUlJTPWiVFBelaHB-0sKA,3321
6
- llama_index_llms_openai-0.3.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
- llama_index_llms_openai-0.3.15.dist-info/RECORD,,