llama-index-llms-openai 0.3.6__py3-none-any.whl → 0.3.8__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.
- llama_index/llms/openai/base.py +7 -1
- llama_index/llms/openai/utils.py +4 -1
- {llama_index_llms_openai-0.3.6.dist-info → llama_index_llms_openai-0.3.8.dist-info}/METADATA +1 -1
- llama_index_llms_openai-0.3.8.dist-info/RECORD +6 -0
- llama_index_llms_openai-0.3.6.dist-info/RECORD +0 -6
- {llama_index_llms_openai-0.3.6.dist-info → llama_index_llms_openai-0.3.8.dist-info}/WHEEL +0 -0
llama_index/llms/openai/base.py
CHANGED
|
@@ -59,6 +59,7 @@ from llama_index.core.llms.llm import ToolSelection
|
|
|
59
59
|
from llama_index.core.llms.utils import parse_partial_json
|
|
60
60
|
from llama_index.core.types import BaseOutputParser, Model, PydanticProgramMode
|
|
61
61
|
from llama_index.llms.openai.utils import (
|
|
62
|
+
ALL_AVAILABLE_MODELS,
|
|
62
63
|
O1_MODELS,
|
|
63
64
|
OpenAIToolCall,
|
|
64
65
|
create_retry_decorator,
|
|
@@ -218,7 +219,7 @@ class OpenAI(FunctionCallingLLM):
|
|
|
218
219
|
description="Whether to use strict mode for invoking tools/using schemas.",
|
|
219
220
|
)
|
|
220
221
|
supports_content_blocks: bool = Field(
|
|
221
|
-
default=
|
|
222
|
+
default=False,
|
|
222
223
|
description="Whether the model supports content blocks in chat messages.",
|
|
223
224
|
)
|
|
224
225
|
|
|
@@ -266,6 +267,10 @@ class OpenAI(FunctionCallingLLM):
|
|
|
266
267
|
if model in O1_MODELS:
|
|
267
268
|
temperature = 1.0
|
|
268
269
|
|
|
270
|
+
supports_content_blocks = kwargs.pop(
|
|
271
|
+
"supports_content_blocks", model in ALL_AVAILABLE_MODELS
|
|
272
|
+
)
|
|
273
|
+
|
|
269
274
|
super().__init__(
|
|
270
275
|
model=model,
|
|
271
276
|
temperature=temperature,
|
|
@@ -285,6 +290,7 @@ class OpenAI(FunctionCallingLLM):
|
|
|
285
290
|
pydantic_program_mode=pydantic_program_mode,
|
|
286
291
|
output_parser=output_parser,
|
|
287
292
|
strict=strict,
|
|
293
|
+
supports_content_blocks=supports_content_blocks,
|
|
288
294
|
**kwargs,
|
|
289
295
|
)
|
|
290
296
|
|
llama_index/llms/openai/utils.py
CHANGED
|
@@ -263,7 +263,10 @@ def to_openai_message_dict(
|
|
|
263
263
|
content_txt = ""
|
|
264
264
|
for block in message.blocks:
|
|
265
265
|
if isinstance(block, TextBlock):
|
|
266
|
-
if
|
|
266
|
+
if (
|
|
267
|
+
message.role.value in ("assistant", "tool", "system")
|
|
268
|
+
or not supports_content_blocks
|
|
269
|
+
):
|
|
267
270
|
# Despite the docs say otherwise, when role is ASSISTANT, SYSTEM
|
|
268
271
|
# or TOOL, 'content' cannot be a list and must be string instead.
|
|
269
272
|
content_txt += block.text
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
|
|
2
|
+
llama_index/llms/openai/base.py,sha256=z176ueUBn4ZeKlDxqqTyUZ_1VrauaFAt6H4jl5bm_MI,36409
|
|
3
|
+
llama_index/llms/openai/utils.py,sha256=a5BvfhjUO1lbKWR5kptQs9WaJ6Ykg_kSWWZQRpk-T3g,18383
|
|
4
|
+
llama_index_llms_openai-0.3.8.dist-info/METADATA,sha256=ewX0c-U-io6xgRtyHQgXkax6m5FNtvk5Y3OCvoTORBs,3320
|
|
5
|
+
llama_index_llms_openai-0.3.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
+
llama_index_llms_openai-0.3.8.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=oyXczVpX-IF9MvTZ1xDY7OpiEmlywwiG1eTsyUGFrns,36195
|
|
3
|
-
llama_index/llms/openai/utils.py,sha256=aF2gP-Aef7rMUIYp9bG2Ke45pNszl_Jagga781Hul-A,18335
|
|
4
|
-
llama_index_llms_openai-0.3.6.dist-info/METADATA,sha256=ZzJAPLc3-rJCZG76WUO9uJuCLYlU14dLUQqNTWcnvAg,3320
|
|
5
|
-
llama_index_llms_openai-0.3.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
-
llama_index_llms_openai-0.3.6.dist-info/RECORD,,
|
|
File without changes
|