llama-index-llms-openai 0.3.40__tar.gz → 0.3.42__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.40
3
+ Version: 0.3.42
4
4
  Summary: llama-index llms openai integration
5
5
  Author: llama-index
6
6
  License-Expression: MIT
@@ -909,7 +909,7 @@ class OpenAI(FunctionCallingLLM):
909
909
  **kwargs: Any,
910
910
  ) -> Dict[str, Any]:
911
911
  """Predict and call the tool."""
912
- tool_specs = [tool.metadata.to_openai_tool() for tool in tools]
912
+ tool_specs = [tool.metadata.to_openai_tool(skip_length_check=True) for tool in tools]
913
913
 
914
914
  # if strict is passed in, use, else default to the class-level attribute, else default to True`
915
915
  if strict is not None:
@@ -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(
@@ -27,7 +27,7 @@ dev = [
27
27
 
28
28
  [project]
29
29
  name = "llama-index-llms-openai"
30
- version = "0.3.40"
30
+ version = "0.3.42"
31
31
  description = "llama-index llms openai integration"
32
32
  authors = [{name = "llama-index"}]
33
33
  requires-python = ">=3.9,<4.0"