LLM-Bridge 1.10.0a1__py3-none-any.whl → 1.10.0a3__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.
- llm_bridge/client/implementations/gemini/gemini_response_handler.py +10 -3
- llm_bridge/client/implementations/openai/non_stream_openai_responses_client.py +8 -3
- llm_bridge/client/implementations/openai/steam_openai_responses_client.py +8 -3
- llm_bridge/type/chat_response.py +8 -1
- {llm_bridge-1.10.0a1.dist-info → llm_bridge-1.10.0a3.dist-info}/METADATA +1 -1
- {llm_bridge-1.10.0a1.dist-info → llm_bridge-1.10.0a3.dist-info}/RECORD +9 -9
- {llm_bridge-1.10.0a1.dist-info → llm_bridge-1.10.0a3.dist-info}/WHEEL +0 -0
- {llm_bridge-1.10.0a1.dist-info → llm_bridge-1.10.0a3.dist-info}/licenses/LICENSE +0 -0
- {llm_bridge-1.10.0a1.dist-info → llm_bridge-1.10.0a3.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import mimetypes
|
|
2
3
|
from typing import Optional
|
|
3
4
|
|
|
4
5
|
from google.genai import types
|
|
5
6
|
|
|
6
7
|
from llm_bridge.client.implementations.gemini.gemini_token_counter import count_gemini_tokens
|
|
7
8
|
from llm_bridge.client.implementations.printing_status import PrintingStatus
|
|
8
|
-
from llm_bridge.type.chat_response import Citation, ChatResponse
|
|
9
|
+
from llm_bridge.type.chat_response import Citation, ChatResponse, File
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class GeminiResponseHandler:
|
|
@@ -22,7 +23,7 @@ class GeminiResponseHandler:
|
|
|
22
23
|
thought: str = ""
|
|
23
24
|
code: str = ""
|
|
24
25
|
code_output: str = ""
|
|
25
|
-
files: list[
|
|
26
|
+
files: list[File] = []
|
|
26
27
|
display: Optional[str] = None
|
|
27
28
|
citations: list[Citation] = extract_citations(response)
|
|
28
29
|
input_tokens, stage_output_tokens = await count_gemini_tokens(response)
|
|
@@ -48,7 +49,13 @@ class GeminiResponseHandler:
|
|
|
48
49
|
code_output += part.code_execution_result.output
|
|
49
50
|
# File
|
|
50
51
|
if part.inline_data is not None:
|
|
51
|
-
|
|
52
|
+
mime_type = part.inline_data.mime_type
|
|
53
|
+
extension = mimetypes.guess_extension(mime_type) or ""
|
|
54
|
+
file = File(
|
|
55
|
+
name=f"generated_file{extension}",
|
|
56
|
+
data=base64.b64encode(part.inline_data.data).decode('utf-8'),
|
|
57
|
+
type=mime_type,
|
|
58
|
+
)
|
|
52
59
|
files.append(file)
|
|
53
60
|
|
|
54
61
|
# Grounding Sources
|
|
@@ -12,7 +12,7 @@ from openai.types.responses import WebSearchToolParam, Response
|
|
|
12
12
|
from llm_bridge.client.implementations.openai.openai_token_couter import count_openai_responses_input_tokens, \
|
|
13
13
|
count_openai_output_tokens
|
|
14
14
|
from llm_bridge.client.model_client.openai_client import OpenAIClient
|
|
15
|
-
from llm_bridge.type.chat_response import ChatResponse, Citation
|
|
15
|
+
from llm_bridge.type.chat_response import ChatResponse, Citation, File
|
|
16
16
|
from llm_bridge.type.serializer import serialize
|
|
17
17
|
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ def process_openai_responses_non_stream_response(
|
|
|
24
24
|
output_list = response.output
|
|
25
25
|
|
|
26
26
|
text: str = ""
|
|
27
|
-
files: list[
|
|
27
|
+
files: list[File] = []
|
|
28
28
|
citations: list[Citation] = []
|
|
29
29
|
|
|
30
30
|
for output in output_list:
|
|
@@ -43,7 +43,12 @@ def process_openai_responses_non_stream_response(
|
|
|
43
43
|
# )
|
|
44
44
|
# Image Generation untestable due to organization verification requirement
|
|
45
45
|
# if output.type == "image_generation_call":
|
|
46
|
-
#
|
|
46
|
+
# file = File(
|
|
47
|
+
# name="generated_image.png",
|
|
48
|
+
# data=output.result,
|
|
49
|
+
# type="image/png",
|
|
50
|
+
# )
|
|
51
|
+
# files.append(file)
|
|
47
52
|
|
|
48
53
|
chat_response = ChatResponse(text=text, files=files)
|
|
49
54
|
output_tokens = count_openai_output_tokens(chat_response)
|
|
@@ -12,13 +12,13 @@ from openai.types.responses import ResponseStreamEvent
|
|
|
12
12
|
from llm_bridge.client.implementations.openai.openai_token_couter import count_openai_responses_input_tokens, \
|
|
13
13
|
count_openai_output_tokens
|
|
14
14
|
from llm_bridge.client.model_client.openai_client import OpenAIClient
|
|
15
|
-
from llm_bridge.type.chat_response import ChatResponse, Citation
|
|
15
|
+
from llm_bridge.type.chat_response import ChatResponse, Citation, File
|
|
16
16
|
from llm_bridge.type.serializer import serialize
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def process_delta(event: ResponseStreamEvent) -> ChatResponse:
|
|
20
20
|
text: str = ""
|
|
21
|
-
files: list[
|
|
21
|
+
files: list[File] = []
|
|
22
22
|
citations: list[Citation] = []
|
|
23
23
|
|
|
24
24
|
if event.type == "response.output_text.delta":
|
|
@@ -28,7 +28,12 @@ def process_delta(event: ResponseStreamEvent) -> ChatResponse:
|
|
|
28
28
|
pass
|
|
29
29
|
# Image Generation untestable due to organization verification requirement
|
|
30
30
|
# if event.type == "response.image_generation_call.partial_image":
|
|
31
|
-
#
|
|
31
|
+
# file = File(
|
|
32
|
+
# name="generated_image.png",
|
|
33
|
+
# data=event.partial_image_b64,
|
|
34
|
+
# type="image/png",
|
|
35
|
+
# )
|
|
36
|
+
# files.append(file)
|
|
32
37
|
|
|
33
38
|
chat_response = ChatResponse(
|
|
34
39
|
text=text,
|
llm_bridge/type/chat_response.py
CHANGED
|
@@ -2,6 +2,13 @@ from dataclasses import dataclass
|
|
|
2
2
|
from typing import Optional
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
@dataclass
|
|
6
|
+
class File:
|
|
7
|
+
name: str
|
|
8
|
+
data: str
|
|
9
|
+
type: str
|
|
10
|
+
|
|
11
|
+
|
|
5
12
|
@dataclass
|
|
6
13
|
class Citation:
|
|
7
14
|
text: str
|
|
@@ -22,7 +29,7 @@ class ChatResponse:
|
|
|
22
29
|
thought: Optional[str] = None
|
|
23
30
|
code: Optional[str] = None
|
|
24
31
|
code_output: Optional[str] = None
|
|
25
|
-
files: Optional[list[
|
|
32
|
+
files: Optional[list[File]] = None
|
|
26
33
|
display: Optional[str] = None
|
|
27
34
|
citations: Optional[list[Citation]] = None
|
|
28
35
|
error: Optional[str] = None
|
|
@@ -9,15 +9,15 @@ llm_bridge/client/implementations/claude/claude_token_counter.py,sha256=g8M7BFY2
|
|
|
9
9
|
llm_bridge/client/implementations/claude/non_stream_claude_client.py,sha256=xnge1J-j_Er4K4L1UxhjuxAs_Pl6vralxTKk9yItwjI,2500
|
|
10
10
|
llm_bridge/client/implementations/claude/stream_claude_client.py,sha256=q4w1UYc1yZJw5UFOtnxCoeg8MFp5soc1d57YiCTCCGE,2109
|
|
11
11
|
llm_bridge/client/implementations/gemini/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
llm_bridge/client/implementations/gemini/gemini_response_handler.py,sha256=
|
|
12
|
+
llm_bridge/client/implementations/gemini/gemini_response_handler.py,sha256=ecefEywnBwJmblAHC53PyVY8QnxyyZAG7EuIzjfQiKQ,4408
|
|
13
13
|
llm_bridge/client/implementations/gemini/gemini_token_counter.py,sha256=M_mlrtu_dZTgEG9JgRaPDVyXqFtHSSVAIhsknhOaVrs,504
|
|
14
14
|
llm_bridge/client/implementations/gemini/non_stream_gemini_client.py,sha256=JGNNpeln42SoXg2vGIC9xG5GGlBh6dIhz4BzYIkgraA,1302
|
|
15
15
|
llm_bridge/client/implementations/gemini/stream_gemini_client.py,sha256=vqPhQdr-jaHXzn-_1PSZfpo96zM-_89XOEXIx7UBBIw,1545
|
|
16
16
|
llm_bridge/client/implementations/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
llm_bridge/client/implementations/openai/non_stream_openai_client.py,sha256=aceJm6FF6VdzVRECzJyTY8-aQjCekhhbrMPEcUN24fo,2171
|
|
18
|
-
llm_bridge/client/implementations/openai/non_stream_openai_responses_client.py,sha256=
|
|
18
|
+
llm_bridge/client/implementations/openai/non_stream_openai_responses_client.py,sha256=mP4N6UuyWKrJPwh4GzzAZYzIaaSPWNeULFKpVCqgpt4,3756
|
|
19
19
|
llm_bridge/client/implementations/openai/openai_token_couter.py,sha256=twGl3-VvbvyrfgJBYJxL-g6OjvQvJMRp03mfOK_0bW0,1442
|
|
20
|
-
llm_bridge/client/implementations/openai/steam_openai_responses_client.py,sha256=
|
|
20
|
+
llm_bridge/client/implementations/openai/steam_openai_responses_client.py,sha256=z7r35pUzMXuM1n9B5WjlKQCX-jtZL8jbiTe0t1P1Xco,3701
|
|
21
21
|
llm_bridge/client/implementations/openai/stream_openai_client.py,sha256=Izq4xH9EuLjUCBJsuSr6U4Kj6FN5c7w_oHf9wmQatXE,2988
|
|
22
22
|
llm_bridge/client/model_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
llm_bridge/client/model_client/claude_client.py,sha256=cuYORseQY8HVt-COh2J0C_mhqPehDB3A4G4vrunoSFA,1352
|
|
@@ -47,7 +47,7 @@ llm_bridge/logic/message_preprocess/message_preprocessor.py,sha256=ERws57Dsu-f5L
|
|
|
47
47
|
llm_bridge/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
48
|
llm_bridge/resources/model_prices.json,sha256=_2ZXKjnMDa6YSKfnWEPR_vUtuMw3cEi1d2L3IZ2kVxs,2707
|
|
49
49
|
llm_bridge/type/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
|
-
llm_bridge/type/chat_response.py,sha256=
|
|
50
|
+
llm_bridge/type/chat_response.py,sha256=zEw-my_I0-7msmlTySdBGE2vWUIPILex0UrUPqTJiYY,754
|
|
51
51
|
llm_bridge/type/message.py,sha256=NyWmSSrciFfvF81aBwAH8qFpo5IpRhh8QXMselbYen8,370
|
|
52
52
|
llm_bridge/type/serializer.py,sha256=moCL9y_HTO2CFg2w_jc5MljDxKgHiCo_qiz-o4l2jYU,515
|
|
53
53
|
llm_bridge/type/model_message/__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.10.
|
|
59
|
-
llm_bridge-1.10.
|
|
60
|
-
llm_bridge-1.10.
|
|
61
|
-
llm_bridge-1.10.
|
|
62
|
-
llm_bridge-1.10.
|
|
58
|
+
llm_bridge-1.10.0a3.dist-info/licenses/LICENSE,sha256=m6uon-6P_CaiqcBfApMfjG9YRtDxcr40Z52JcqUCEAE,1069
|
|
59
|
+
llm_bridge-1.10.0a3.dist-info/METADATA,sha256=VxdLpIocZU9fY8H_UacHxvrRD5xbA0UrxtDyamM4En8,7851
|
|
60
|
+
llm_bridge-1.10.0a3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
61
|
+
llm_bridge-1.10.0a3.dist-info/top_level.txt,sha256=PtxyrgNX1lSa1Ab_qswg0sekSXejG5zrS6b_v3Po05g,11
|
|
62
|
+
llm_bridge-1.10.0a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|