LLM-Bridge 1.7.17__py3-none-any.whl → 1.7.18__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.
@@ -8,10 +8,11 @@ async def get_raw_content_from_url(req_url: str) -> tuple[bytes, str]:
8
8
  return file_data, media_type
9
9
 
10
10
 
11
+ # Base64 Encoded
11
12
  async def get_encoded_content_from_url(req_url: str) -> tuple[str, str]:
12
- img_data, media_type = await get_raw_content_from_url(req_url)
13
- base64_image = base64.b64encode(img_data).decode('utf-8')
14
- return base64_image, media_type
13
+ media_data, media_type = await get_raw_content_from_url(req_url)
14
+ base64_media = base64.b64encode(media_data).decode('utf-8')
15
+ return base64_media, media_type
15
16
 
16
17
 
17
18
  async def get_openai_image_content_from_url(req_img_url: str) -> str:
@@ -44,7 +44,7 @@ async def create_openai_client(
44
44
  else:
45
45
  raise HTTPException(status_code=500, detail="API Type not matched")
46
46
 
47
- if api_type in ("OpenAI", "OpenAI-Azure"):
47
+ if api_type in ("OpenAI", "OpenAI-Azure", "Grok"):
48
48
  use_responses_api = True
49
49
  else:
50
50
  use_responses_api = False
@@ -1,8 +1,8 @@
1
1
  from openai.types.responses import ResponseInputTextParam, ResponseInputImageParam, ResponseOutputTextParam, \
2
- ResponseInputContentParam, EasyInputMessageParam, ResponseOutputMessageParam
2
+ ResponseInputContentParam, EasyInputMessageParam, ResponseOutputMessageParam, ResponseInputFileParam
3
3
 
4
4
  from llm_bridge.logic.chat_generate import media_processor
5
- from llm_bridge.logic.message_preprocess.file_type_checker import get_file_type
5
+ from llm_bridge.logic.message_preprocess.file_type_checker import get_file_type, get_file_name
6
6
  from llm_bridge.type.message import Message, ContentType
7
7
  from llm_bridge.type.model_message.openai_responses_message import OpenAIResponsesMessage
8
8
 
@@ -29,6 +29,14 @@ async def convert_message_to_openai_responses(message: Message) -> OpenAIRespons
29
29
  detail="auto"
30
30
  )
31
31
  content.append(image_content)
32
+ elif sub_type == "pdf":
33
+ file_data, _ = await media_processor.get_encoded_content_from_url(file_url)
34
+ pdf_content = ResponseInputFileParam(
35
+ type="input_file",
36
+ filename=get_file_name(file_url),
37
+ file_data=f"data:application/pdf;base64,{file_data}",
38
+ )
39
+ content.append(pdf_content)
32
40
  # TODO: Responses API is currently unsupported for audio input
33
41
  # elif file_type == "audio":
34
42
  # encoded_string = await media_processor.get_gpt_audio_content_from_url(file_url)
@@ -41,7 +41,8 @@ async def get_file_type(file_url: str) -> tuple[str, str]:
41
41
  return 'unknown', 'unknown'
42
42
 
43
43
 
44
- def get_file_name(file_url) -> str:
44
+ # Without Timestamp
45
+ def get_file_name(file_url: str) -> str:
45
46
  base_name = os.path.basename(file_url)
46
47
  match = re.search(r'-(.+)', base_name)
47
48
  if match:
@@ -21,7 +21,7 @@ async def extract_text_files_to_message(message: Message, api_type: str) -> None
21
21
  if file_type != "text" and file_type != "application":
22
22
  continue
23
23
 
24
- if sub_type == "pdf" and api_type in ("Gemini-Free", "Gemini-Paid", "Claude"):
24
+ if sub_type == "pdf" and api_type in ("OpenAI", "OpenAI-Azure", "Gemini-Free", "Gemini-Paid", "Claude"):
25
25
  continue
26
26
 
27
27
  filename = get_file_name(file_url)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: LLM-Bridge
3
- Version: 1.7.17
3
+ Version: 1.7.18
4
4
  Summary: A Bridge for LLMs
5
5
  Author-email: windsnow1025 <windsnow1025@gmail.com>
6
6
  License-Expression: MIT
@@ -72,10 +72,15 @@ pytest
72
72
 
73
73
  ## Quick Start
74
74
 
75
- See `./usage/`
75
+ ### Setup
76
+
77
+ 1. Copy `./.env.example` and rename it to `./.env`, then fill in the environment variables.
78
+ 2. Install requirements: `pip install -r requirements.txt`
76
79
 
77
80
  ### Workflow
78
81
 
82
+ See `./usage/`
83
+
79
84
  ```python
80
85
  from typing import AsyncGenerator
81
86
 
@@ -29,21 +29,21 @@ llm_bridge/logic/model_prices.py,sha256=hiXVbki3004Rrm5LQrmVfdm0lLABeygxtFB-Qn9_
29
29
  llm_bridge/logic/chat_generate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  llm_bridge/logic/chat_generate/chat_client_factory.py,sha256=huZO5pqRNFDUK9KpCk3-pLTgxAjbVGFRu3Y56w2QPxI,2814
31
31
  llm_bridge/logic/chat_generate/chat_message_converter.py,sha256=40VTBOPXg_ocrEZMdt1ObYlm-mhRL35zWzzxv8m2xRc,1538
32
- llm_bridge/logic/chat_generate/media_processor.py,sha256=1Rwhr7DsEB8HY5_li_hcuHzOglTncrz885Y2dwfWluc,681
32
+ llm_bridge/logic/chat_generate/media_processor.py,sha256=ZR8G24EHwZZr2T9iFDRmScDGyJ_kvThApABzSzK0CL0,702
33
33
  llm_bridge/logic/chat_generate/model_client_factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  llm_bridge/logic/chat_generate/model_client_factory/claude_client_factory.py,sha256=_iX36A4WJx2-QeX4oAurOaRuCjvm8UDhaKL8lO9iP9o,2186
35
35
  llm_bridge/logic/chat_generate/model_client_factory/gemini_client_factory.py,sha256=d_DnTZ2Rkbmo0La7uKnrVY9NO9wa6QZ8eK0hf2K1ZII,3041
36
- llm_bridge/logic/chat_generate/model_client_factory/openai_client_factory.py,sha256=kj4JLHiRRDEYaYU0Ac6wZ5dlBAVCX0HNN2sbWDWKPKs,3523
36
+ llm_bridge/logic/chat_generate/model_client_factory/openai_client_factory.py,sha256=KG5QF4D6ouPssD7g2512CW1M8Iv_xA2gmjxh8FQ8z84,3531
37
37
  llm_bridge/logic/chat_generate/model_message_converter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  llm_bridge/logic/chat_generate/model_message_converter/claude_message_converter.py,sha256=SfDhQXR7L5nCPHS4MIjwgzK_wER7qOUCc8gh-K77kKY,2441
39
39
  llm_bridge/logic/chat_generate/model_message_converter/gemini_message_converter.py,sha256=UjhzRX7sBa3-Zv1flMJd8bc8uRWMMav4UdJFhE6nVq4,1527
40
40
  llm_bridge/logic/chat_generate/model_message_converter/openai_message_converter.py,sha256=MdGcOJ1MMOD7E8RxjMk7HhobZ7lIMT118eWh9cpORgA,2180
41
- llm_bridge/logic/chat_generate/model_message_converter/openai_responses_message_converter.py,sha256=p3xYixa-E8lCf88qXnvgux6NICPtm6HuaGXErS8kPI8,2528
41
+ llm_bridge/logic/chat_generate/model_message_converter/openai_responses_message_converter.py,sha256=V8eIvtS1utOd-HOOMOuR880cqONebjoAhxxdgHFg3_0,2978
42
42
  llm_bridge/logic/message_preprocess/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  llm_bridge/logic/message_preprocess/code_file_extensions.py,sha256=5bsnSKC9PGbl6ZMy80sXfagAbz77pGjt6Z2-qwzUw48,9306
44
44
  llm_bridge/logic/message_preprocess/document_processor.py,sha256=IsVqoFgWNa9i8cRsDAfmCynJMdlvBqiCKIT9kbx96kg,2861
45
- llm_bridge/logic/message_preprocess/file_type_checker.py,sha256=iIQNn5DTpLJM5l9aOWjCK1ppgcrOzp22kWE45kWXuZs,1578
46
- llm_bridge/logic/message_preprocess/message_preprocessor.py,sha256=pWFAMo7IZP6_7Kl_B50rDABd455AEh5E6KDchfSa56A,1881
45
+ llm_bridge/logic/message_preprocess/file_type_checker.py,sha256=nkrVki1a2udCeVqUnfIVi7Wxx8OMKbBuHw3FOlm17uo,1603
46
+ llm_bridge/logic/message_preprocess/message_preprocessor.py,sha256=ERws57Dsu-f5LpWKqJ_SEP7omNWXeGoJaocX91P6QDQ,1907
47
47
  llm_bridge/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  llm_bridge/resources/model_prices.json,sha256=j54U4U14USiRYEasMjmoOQxNeaHqXmMfSJEG-vmfRdY,2733
49
49
  llm_bridge/type/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -55,8 +55,8 @@ llm_bridge/type/model_message/claude_message.py,sha256=gYJUTbLUeifQMva3Axarc-VFe
55
55
  llm_bridge/type/model_message/gemini_message.py,sha256=mh8pf929g7_NkBzSOwnLXyrwSzTT4yt2FmyX7NZn0sM,4302
56
56
  llm_bridge/type/model_message/openai_message.py,sha256=xFaLY-cZoSwNd7E9BSWQjBNcRfCVH11X9s2yxXlctR0,453
57
57
  llm_bridge/type/model_message/openai_responses_message.py,sha256=be1q2euA0ybjj4NO6NxOGIRB9eJuXSb4ssUm_bM4Ocs,1529
58
- llm_bridge-1.7.17.dist-info/licenses/LICENSE,sha256=m6uon-6P_CaiqcBfApMfjG9YRtDxcr40Z52JcqUCEAE,1069
59
- llm_bridge-1.7.17.dist-info/METADATA,sha256=6UlBbYsYAIbvQ5TUfJbHGedlCfvjmFD_Vl856ObmSuw,7226
60
- llm_bridge-1.7.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
61
- llm_bridge-1.7.17.dist-info/top_level.txt,sha256=PtxyrgNX1lSa1Ab_qswg0sekSXejG5zrS6b_v3Po05g,11
62
- llm_bridge-1.7.17.dist-info/RECORD,,
58
+ llm_bridge-1.7.18.dist-info/licenses/LICENSE,sha256=m6uon-6P_CaiqcBfApMfjG9YRtDxcr40Z52JcqUCEAE,1069
59
+ llm_bridge-1.7.18.dist-info/METADATA,sha256=zNphNVFcqpPog9I1x3jrA6aETlO21EZaHE2od3y8FRs,7389
60
+ llm_bridge-1.7.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
61
+ llm_bridge-1.7.18.dist-info/top_level.txt,sha256=PtxyrgNX1lSa1Ab_qswg0sekSXejG5zrS6b_v3Po05g,11
62
+ llm_bridge-1.7.18.dist-info/RECORD,,