llama-index-llms-openai 0.3.37__py3-none-any.whl → 0.3.39__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.
@@ -28,6 +28,7 @@ from llama_index.core.base.llms.types import (
28
28
  MessageRole,
29
29
  TextBlock,
30
30
  AudioBlock,
31
+ DocumentBlock,
31
32
  )
32
33
  from llama_index.core.bridge.pydantic import BaseModel
33
34
 
@@ -308,6 +309,14 @@ def to_openai_message_dict(
308
309
  if isinstance(block, TextBlock):
309
310
  content.append({"type": "text", "text": block.text})
310
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}"})
311
320
  elif isinstance(block, ImageBlock):
312
321
  if block.url:
313
322
  content.append(
@@ -488,7 +497,7 @@ def to_openai_responses_message_dict(
488
497
  "role": message.role.value,
489
498
  "content": (
490
499
  content_txt
491
- if message.role.value in ("assistant", "system", "developer")
500
+ if message.role.value in ("system", "developer")
492
501
  or all(isinstance(block, TextBlock) for block in message.blocks)
493
502
  else content
494
503
  ),
@@ -1,18 +1,13 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: llama-index-llms-openai
3
- Version: 0.3.37
3
+ Version: 0.3.39
4
4
  Summary: llama-index llms openai integration
5
- License: MIT
6
5
  Author: llama-index
7
- Requires-Python: >=3.9,<4.0
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.9
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Requires-Dist: llama-index-core (>=0.12.17,<0.13.0)
15
- Requires-Dist: openai (>=1.66.3,<2.0.0)
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: <4.0,>=3.9
9
+ Requires-Dist: llama-index-core<0.13,>=0.12.36
10
+ Requires-Dist: openai<2,>=1.66.3
16
11
  Description-Content-Type: text/markdown
17
12
 
18
13
  # LlamaIndex Llms Integration: Openai
@@ -146,4 +141,3 @@ print(resp)
146
141
  ### LLM Implementation example
147
142
 
148
143
  https://docs.llamaindex.ai/en/stable/examples/llm/openai/
149
-
@@ -0,0 +1,9 @@
1
+ llama_index/llms/openai/__init__.py,sha256=8nmgixeXifQ4eVSgtCic54WxXqrrpXQPL4rhACWCSFs,229
2
+ llama_index/llms/openai/base.py,sha256=fu4Y1uX8IuOtVTHqaG-tyd_PpN9bUfnW6ESoyaptaVs,38620
3
+ llama_index/llms/openai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ llama_index/llms/openai/responses.py,sha256=SdTAqO2FqGuvm9u01BlI92IpY0RhOaJ3mU03Rc0OHso,34525
5
+ llama_index/llms/openai/utils.py,sha256=0vguBzIgnc-epzG4HE4pLJADwi8FAuU_YPC_7RteO4Y,27062
6
+ llama_index_llms_openai-0.3.39.dist-info/METADATA,sha256=SBLJuiMEZ46YeQs0p50HuDVieRWVT8O89Y2k8OvMR3A,3040
7
+ llama_index_llms_openai-0.3.39.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ llama_index_llms_openai-0.3.39.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
9
+ llama_index_llms_openai-0.3.39.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- llama_index/llms/openai/__init__.py,sha256=8nmgixeXifQ4eVSgtCic54WxXqrrpXQPL4rhACWCSFs,229
2
- llama_index/llms/openai/base.py,sha256=fu4Y1uX8IuOtVTHqaG-tyd_PpN9bUfnW6ESoyaptaVs,38620
3
- llama_index/llms/openai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- llama_index/llms/openai/responses.py,sha256=SdTAqO2FqGuvm9u01BlI92IpY0RhOaJ3mU03Rc0OHso,34525
5
- llama_index/llms/openai/utils.py,sha256=NMiDNXPV-VnHwnPyiOe_HYZp0M0ZgM8eJ0kODqwNEN8,26535
6
- llama_index_llms_openai-0.3.37.dist-info/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
7
- llama_index_llms_openai-0.3.37.dist-info/METADATA,sha256=P1Mqmv4yLtAkjmApFIw23l2mMKJogul1D5g6ISRMfTE,3322
8
- llama_index_llms_openai-0.3.37.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
- llama_index_llms_openai-0.3.37.dist-info/RECORD,,