llama-index-llms-openai 0.3.20__py3-none-any.whl → 0.3.22__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/utils.py +19 -5
- llama_index_llms_openai-0.3.22.dist-info/LICENSE +21 -0
- {llama_index_llms_openai-0.3.20.dist-info → llama_index_llms_openai-0.3.22.dist-info}/METADATA +1 -1
- llama_index_llms_openai-0.3.22.dist-info/RECORD +8 -0
- llama_index_llms_openai-0.3.20.dist-info/RECORD +0 -7
- {llama_index_llms_openai-0.3.20.dist-info → llama_index_llms_openai-0.3.22.dist-info}/WHEEL +0 -0
llama_index/llms/openai/utils.py
CHANGED
|
@@ -323,11 +323,16 @@ def to_openai_message_dict(
|
|
|
323
323
|
raise ValueError(msg)
|
|
324
324
|
|
|
325
325
|
# NOTE: Sending a null value (None) for Tool Message to OpenAI will cause error
|
|
326
|
-
# It's only Allowed to send None if it's an Assistant Message
|
|
326
|
+
# It's only Allowed to send None if it's an Assistant Message and either a function call or tool calls were performed
|
|
327
327
|
# Reference: https://platform.openai.com/docs/api-reference/chat/create
|
|
328
328
|
content_txt = (
|
|
329
329
|
None
|
|
330
|
-
if content_txt == ""
|
|
330
|
+
if content_txt == ""
|
|
331
|
+
and message.role == MessageRole.ASSISTANT
|
|
332
|
+
and (
|
|
333
|
+
"function_call" in message.additional_kwargs
|
|
334
|
+
or "tool_calls" in message.additional_kwargs
|
|
335
|
+
)
|
|
331
336
|
else content_txt
|
|
332
337
|
)
|
|
333
338
|
|
|
@@ -621,10 +626,19 @@ def update_tool_calls(
|
|
|
621
626
|
# validations to get passed by mypy
|
|
622
627
|
assert t.function is not None
|
|
623
628
|
assert tc_delta.function is not None
|
|
624
|
-
assert t.function.arguments is not None
|
|
625
|
-
assert t.function.name is not None
|
|
626
|
-
assert t.id is not None
|
|
627
629
|
|
|
630
|
+
# Initialize fields if they're None
|
|
631
|
+
# OpenAI(or Compatible)'s streaming API can return partial tool call
|
|
632
|
+
# information across multiple chunks where some fields may be None in
|
|
633
|
+
# initial chunks and populated in subsequent ones
|
|
634
|
+
if t.function.arguments is None:
|
|
635
|
+
t.function.arguments = ""
|
|
636
|
+
if t.function.name is None:
|
|
637
|
+
t.function.name = ""
|
|
638
|
+
if t.id is None:
|
|
639
|
+
t.id = ""
|
|
640
|
+
|
|
641
|
+
# Update with delta values
|
|
628
642
|
t.function.arguments += tc_delta.function.arguments or ""
|
|
629
643
|
t.function.name += tc_delta.function.name or ""
|
|
630
644
|
t.id += tc_delta.id or ""
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Jerry Liu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
|
|
2
|
+
llama_index/llms/openai/base.py,sha256=9HBszflpKp81gRSMaWKVa4PnG6sLfV9mWOyAkTM7MUI,38055
|
|
3
|
+
llama_index/llms/openai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
llama_index/llms/openai/utils.py,sha256=xcgwoHUuyx0Ur3s3m7WPzMITM_RfDjOIeVjHygLdWPk,21307
|
|
5
|
+
llama_index_llms_openai-0.3.22.dist-info/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
|
|
6
|
+
llama_index_llms_openai-0.3.22.dist-info/METADATA,sha256=X8_6o8Xj_xHkVUOnxNcHqqEMHPN1KCf9HvmHUojilfo,3322
|
|
7
|
+
llama_index_llms_openai-0.3.22.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
8
|
+
llama_index_llms_openai-0.3.22.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=9HBszflpKp81gRSMaWKVa4PnG6sLfV9mWOyAkTM7MUI,38055
|
|
3
|
-
llama_index/llms/openai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
llama_index/llms/openai/utils.py,sha256=rQJ5B_griANqC4oNbkhgtjWijytLfG0HLlvYh9qCjv4,20708
|
|
5
|
-
llama_index_llms_openai-0.3.20.dist-info/METADATA,sha256=V4PGur14J6RiUC8S1YDDfuVTav3smCXx6dN-baidtng,3322
|
|
6
|
-
llama_index_llms_openai-0.3.20.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
-
llama_index_llms_openai-0.3.20.dist-info/RECORD,,
|
|
File without changes
|