llama-index-llms-openai 0.3.39__tar.gz → 0.3.41__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.3.39
3
+ Version: 0.3.41
4
4
  Summary: llama-index llms openai integration
5
5
  Author: llama-index
6
6
  License-Expression: MIT
@@ -309,14 +309,6 @@ def to_openai_message_dict(
309
309
  if isinstance(block, TextBlock):
310
310
  content.append({"type": "text", "text": block.text})
311
311
  content_txt += block.text
312
- elif isinstance(block, DocumentBlock):
313
- if not block.data:
314
- file_buffer = block.resolve_document()
315
- b64_string = block._get_b64_string(data_buffer=file_buffer)
316
- else:
317
- b64_string = block.data.decode("utf-8")
318
- mimetype = block.document_mimetype if block.document_mimetype is not None else "application/pdf"
319
- content.append({"type": "input_file", "filename": block.title, "file_data": f"data:{mimetype};base64,{b64_string}"})
320
312
  elif isinstance(block, ImageBlock):
321
313
  if block.url:
322
314
  content.append(
@@ -428,6 +420,14 @@ def to_openai_responses_message_dict(
428
420
  if isinstance(block, TextBlock):
429
421
  content.append({"type": "input_text", "text": block.text})
430
422
  content_txt += block.text
423
+ elif isinstance(block, DocumentBlock):
424
+ if not block.data:
425
+ file_buffer = block.resolve_document()
426
+ b64_string = block._get_b64_string(file_buffer)
427
+ mimetype = block._guess_mimetype()
428
+ else:
429
+ b64_string = block.data.decode("utf-8")
430
+ content.append({"type": "input_file", "filename": block.title, "file_data": f"data:{mimetype};base64,{b64_string}"})
431
431
  elif isinstance(block, ImageBlock):
432
432
  if block.url:
433
433
  content.append(
@@ -761,7 +761,7 @@ def update_tool_calls(
761
761
  List[ChoiceDeltaToolCall]: the updated tool calls
762
762
  """
763
763
  # openai provides chunks consisting of tool_call deltas one tool at a time
764
- if tool_calls_delta is None:
764
+ if tool_calls_delta is None or len(tool_calls_delta) == 0:
765
765
  return tool_calls
766
766
 
767
767
  tc_delta = tool_calls_delta[0]
@@ -27,16 +27,13 @@ dev = [
27
27
 
28
28
  [project]
29
29
  name = "llama-index-llms-openai"
30
- version = "0.3.39"
30
+ version = "0.3.41"
31
31
  description = "llama-index llms openai integration"
32
32
  authors = [{name = "llama-index"}]
33
33
  requires-python = ">=3.9,<4.0"
34
34
  readme = "README.md"
35
35
  license = "MIT"
36
- dependencies = [
37
- "openai>=1.66.3,<2",
38
- "llama-index-core>=0.12.36,<0.13",
39
- ]
36
+ dependencies = ["openai>=1.66.3,<2", "llama-index-core>=0.12.36,<0.13"]
40
37
 
41
38
  [tool.codespell]
42
39
  check-filenames = true