llama-index-llms-openai 0.2.7__py3-none-any.whl → 0.2.9__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.
@@ -63,6 +63,7 @@ from llama_index.llms.openai.utils import (
63
63
  openai_modelname_to_contextsize,
64
64
  resolve_openai_credentials,
65
65
  to_openai_message_dicts,
66
+ resolve_tool_choice,
66
67
  )
67
68
  from llama_index.core.bridge.pydantic import (
68
69
  BaseModel,
@@ -873,9 +874,6 @@ class OpenAI(FunctionCallingLLM):
873
874
  **kwargs: Any,
874
875
  ) -> Dict[str, Any]:
875
876
  """Predict and call the tool."""
876
- from llama_index.agent.openai.utils import resolve_tool_choice
877
-
878
- # misralai uses the same openai tool format
879
877
  tool_specs = [tool.metadata.to_openai_tool() for tool in tools]
880
878
 
881
879
  # if strict is passed in, use, else default to the class-level attribute, else default to True`
@@ -428,3 +428,14 @@ def validate_openai_api_key(api_key: Optional[str] = None) -> None:
428
428
 
429
429
  if not openai_api_key:
430
430
  raise ValueError(MISSING_API_KEY_ERROR_MESSAGE)
431
+
432
+
433
+ def resolve_tool_choice(tool_choice: Union[str, dict] = "auto") -> Union[str, dict]:
434
+ """Resolve tool choice.
435
+
436
+ If tool_choice is a function name string, return the appropriate dict.
437
+ """
438
+ if isinstance(tool_choice, str) and tool_choice not in ["none", "auto", "required"]:
439
+ return {"type": "function", "function": {"name": tool_choice}}
440
+
441
+ return tool_choice
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-llms-openai
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: llama-index llms openai integration
5
5
  License: MIT
6
6
  Author: llama-index
@@ -11,7 +11,6 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
- Requires-Dist: llama-index-agent-openai (>=0.3.1,<0.4.0)
15
14
  Requires-Dist: llama-index-core (>=0.11.7,<0.12.0)
16
15
  Requires-Dist: openai (>=1.40.0,<2.0.0)
17
16
  Description-Content-Type: text/markdown
@@ -0,0 +1,6 @@
1
+ llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
+ llama_index/llms/openai/base.py,sha256=h3jab2lijnvWRFwx2M7dlWsY48JBMmehDsU55ebjHBE,36997
3
+ llama_index/llms/openai/utils.py,sha256=zduRqlmGGNy7c1uoDIdDcExD47Myq9WpczVTvRid2cI,14025
4
+ llama_index_llms_openai-0.2.9.dist-info/METADATA,sha256=SzGCTND1cCtoBjU3qmCE5k_qhvV105uQISfoMmmj0Pw,648
5
+ llama_index_llms_openai-0.2.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
+ llama_index_llms_openai-0.2.9.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
- llama_index/llms/openai/base.py,sha256=3_D2p15hJZwjAlA_fGBWqD7gPG1TcsaS65pEGhNRP5s,37096
3
- llama_index/llms/openai/utils.py,sha256=n-7uzAE23knhSCxrDS-C87Xsm_icH1nPbrdZaMPxz5I,13642
4
- llama_index_llms_openai-0.2.7.dist-info/METADATA,sha256=f84gfZu1WBl2RFKrcA2EiTlql9LpO7ritPhuNtqLyWs,705
5
- llama_index_llms_openai-0.2.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
- llama_index_llms_openai-0.2.7.dist-info/RECORD,,