LLM-Bridge 1.10.3__py3-none-any.whl → 1.11.0a0__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_token_counter.py +6 -1
- llm_bridge/logic/chat_generate/chat_client_factory.py +13 -2
- llm_bridge/logic/chat_generate/model_client_factory/gemini_client_factory.py +21 -5
- llm_bridge/resources/model_prices.json +24 -0
- {llm_bridge-1.10.3.dist-info → llm_bridge-1.11.0a0.dist-info}/METADATA +2 -2
- {llm_bridge-1.10.3.dist-info → llm_bridge-1.11.0a0.dist-info}/RECORD +9 -9
- {llm_bridge-1.10.3.dist-info → llm_bridge-1.11.0a0.dist-info}/WHEEL +0 -0
- {llm_bridge-1.10.3.dist-info → llm_bridge-1.11.0a0.dist-info}/licenses/LICENSE +0 -0
- {llm_bridge-1.10.3.dist-info → llm_bridge-1.11.0a0.dist-info}/top_level.txt +0 -0
|
@@ -8,8 +8,13 @@ async def count_gemini_tokens(
|
|
|
8
8
|
if usage_metadata is None:
|
|
9
9
|
return 0, 0
|
|
10
10
|
input_tokens = usage_metadata.prompt_token_count
|
|
11
|
+
if input_tokens is None: # For Vertex AI
|
|
12
|
+
input_tokens = 0
|
|
11
13
|
output_tokens = usage_metadata.candidates_token_count
|
|
12
14
|
if output_tokens is None:
|
|
13
|
-
|
|
15
|
+
total_token_count = usage_metadata.total_token_count
|
|
16
|
+
if total_token_count is None: # For Vertex AI
|
|
17
|
+
total_token_count = 0
|
|
18
|
+
output_tokens = total_token_count - input_tokens
|
|
14
19
|
return input_tokens, output_tokens
|
|
15
20
|
|
|
@@ -60,7 +60,8 @@ async def create_chat_client(
|
|
|
60
60
|
model=model,
|
|
61
61
|
temperature=temperature,
|
|
62
62
|
stream=stream,
|
|
63
|
-
api_key=api_keys["GEMINI_FREE_API_KEY"]
|
|
63
|
+
api_key=api_keys["GEMINI_FREE_API_KEY"],
|
|
64
|
+
vertexai=False,
|
|
64
65
|
)
|
|
65
66
|
elif api_type == 'Gemini-Paid':
|
|
66
67
|
return await create_gemini_client(
|
|
@@ -68,7 +69,17 @@ async def create_chat_client(
|
|
|
68
69
|
model=model,
|
|
69
70
|
temperature=temperature,
|
|
70
71
|
stream=stream,
|
|
71
|
-
api_key=api_keys["GEMINI_PAID_API_KEY"]
|
|
72
|
+
api_key=api_keys["GEMINI_PAID_API_KEY"],
|
|
73
|
+
vertexai=False,
|
|
74
|
+
)
|
|
75
|
+
elif api_type == 'Gemini-Vertex':
|
|
76
|
+
return await create_gemini_client(
|
|
77
|
+
messages=messages,
|
|
78
|
+
model=model,
|
|
79
|
+
temperature=temperature,
|
|
80
|
+
stream=stream,
|
|
81
|
+
api_key=api_keys["GEMINI_VERTEX_API_KEY"],
|
|
82
|
+
vertexai=True,
|
|
72
83
|
)
|
|
73
84
|
elif api_type == 'Claude':
|
|
74
85
|
return await create_claude_client(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from google import genai
|
|
2
2
|
from google.genai import types
|
|
3
3
|
from google.genai._api_client import HttpOptions
|
|
4
|
+
from google.genai.types import Modality
|
|
4
5
|
|
|
5
6
|
from llm_bridge.client.implementations.gemini.non_stream_gemini_client import NonStreamGeminiClient
|
|
6
7
|
from llm_bridge.client.implementations.gemini.stream_gemini_client import StreamGeminiClient
|
|
@@ -15,19 +16,20 @@ async def create_gemini_client(
|
|
|
15
16
|
temperature: float,
|
|
16
17
|
stream: bool,
|
|
17
18
|
api_key: str,
|
|
19
|
+
vertexai: bool,
|
|
18
20
|
):
|
|
19
21
|
client = genai.Client(
|
|
22
|
+
vertexai=vertexai,
|
|
20
23
|
api_key=api_key,
|
|
21
|
-
http_options=HttpOptions(api_version='v1alpha') # Thinking
|
|
22
24
|
)
|
|
23
25
|
|
|
24
26
|
system_instruction = None
|
|
25
27
|
tools = []
|
|
26
28
|
thinking_config = None
|
|
27
|
-
response_modalities = [
|
|
29
|
+
response_modalities = [Modality.TEXT]
|
|
28
30
|
|
|
29
31
|
system_instruction = extract_system_messages(messages) or " "
|
|
30
|
-
if "image" not in model:
|
|
32
|
+
if "image" not in model and not vertexai:
|
|
31
33
|
tools.append(
|
|
32
34
|
types.Tool(
|
|
33
35
|
google_search=types.GoogleSearch()
|
|
@@ -43,10 +45,24 @@ async def create_gemini_client(
|
|
|
43
45
|
code_execution=types.ToolCodeExecution()
|
|
44
46
|
)
|
|
45
47
|
)
|
|
48
|
+
if "image" not in model and vertexai:
|
|
49
|
+
tools.append(
|
|
50
|
+
types.Tool(
|
|
51
|
+
google_search=types.GoogleSearch()
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
tools.append(
|
|
55
|
+
types.Tool(
|
|
56
|
+
url_context=types.UrlContext()
|
|
57
|
+
)
|
|
58
|
+
)
|
|
46
59
|
if "image" not in model:
|
|
47
|
-
thinking_config = types.ThinkingConfig(
|
|
60
|
+
thinking_config = types.ThinkingConfig(
|
|
61
|
+
include_thoughts=True,
|
|
62
|
+
thinking_budget=-1,
|
|
63
|
+
)
|
|
48
64
|
if "image" in model:
|
|
49
|
-
response_modalities = [
|
|
65
|
+
response_modalities = [Modality.TEXT, Modality.IMAGE]
|
|
50
66
|
|
|
51
67
|
config = types.GenerateContentConfig(
|
|
52
68
|
system_instruction=system_instruction,
|
|
@@ -131,6 +131,30 @@
|
|
|
131
131
|
"input": 1.0,
|
|
132
132
|
"output": 2.5
|
|
133
133
|
},
|
|
134
|
+
{
|
|
135
|
+
"apiType": "Gemini-Vertex",
|
|
136
|
+
"model": "gemini-flash-latest",
|
|
137
|
+
"input": 1,
|
|
138
|
+
"output": 2.5
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"apiType": "Gemini-Vertex",
|
|
142
|
+
"model": "gemini-2.5-flash",
|
|
143
|
+
"input": 1,
|
|
144
|
+
"output": 2.5
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"apiType": "Gemini-Vertex",
|
|
148
|
+
"model": "gemini-2.5-pro",
|
|
149
|
+
"input": 2.5,
|
|
150
|
+
"output": 15
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"apiType": "Gemini-Vertex",
|
|
154
|
+
"model": "gemini-2.5-flash-image-preview",
|
|
155
|
+
"input": 1.0,
|
|
156
|
+
"output": 2.5
|
|
157
|
+
},
|
|
134
158
|
{
|
|
135
159
|
"apiType": "Claude",
|
|
136
160
|
"model": "claude-sonnet-4-0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: LLM-Bridge
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.0a0
|
|
4
4
|
Summary: A Bridge for LLMs
|
|
5
5
|
Author-email: windsnow1025 <windsnow1025@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,7 +15,7 @@ Requires-Dist: httpx
|
|
|
15
15
|
Requires-Dist: tenacity
|
|
16
16
|
Requires-Dist: openai==1.106.1
|
|
17
17
|
Requires-Dist: tiktoken==0.11.0
|
|
18
|
-
Requires-Dist: google-genai==1.
|
|
18
|
+
Requires-Dist: google-genai==1.46.0
|
|
19
19
|
Requires-Dist: anthropic==0.66.0
|
|
20
20
|
Requires-Dist: PyMuPDF
|
|
21
21
|
Requires-Dist: docxlatex>=1.1.1
|
|
@@ -10,7 +10,7 @@ llm_bridge/client/implementations/claude/non_stream_claude_client.py,sha256=xnge
|
|
|
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
12
|
llm_bridge/client/implementations/gemini/gemini_response_handler.py,sha256=LADXq5h_bbuCclp4RTf70YtQ0_9JFRRzo7j4V5Ts7y4,4388
|
|
13
|
-
llm_bridge/client/implementations/gemini/gemini_token_counter.py,sha256=
|
|
13
|
+
llm_bridge/client/implementations/gemini/gemini_token_counter.py,sha256=GdnwJWPhGZMB_xC0fz88zQRparIHzTemkQoqfDcxVEA,687
|
|
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
|
|
@@ -27,12 +27,12 @@ llm_bridge/logic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
27
27
|
llm_bridge/logic/file_fetch.py,sha256=Q8PGNj76E25sKD70TmlnSIdPgAxpNlb89syk87DbAGg,1341
|
|
28
28
|
llm_bridge/logic/model_prices.py,sha256=hiXVbki3004Rrm5LQrmVfdm0lLABeygxtFB-Qn9_mm0,1219
|
|
29
29
|
llm_bridge/logic/chat_generate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
llm_bridge/logic/chat_generate/chat_client_factory.py,sha256=
|
|
30
|
+
llm_bridge/logic/chat_generate/chat_client_factory.py,sha256=H0rcRHytSfYKz_mwRfJgJYyI-d3S3nxBssREYWPyOWw,3165
|
|
31
31
|
llm_bridge/logic/chat_generate/chat_message_converter.py,sha256=40VTBOPXg_ocrEZMdt1ObYlm-mhRL35zWzzxv8m2xRc,1538
|
|
32
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=j8RwLDul_zdZIIZfzrJji3VmqnYVAV61Xjrbp4NC69k,2603
|
|
35
|
-
llm_bridge/logic/chat_generate/model_client_factory/gemini_client_factory.py,sha256
|
|
35
|
+
llm_bridge/logic/chat_generate/model_client_factory/gemini_client_factory.py,sha256=-sz60KfSpY_rtLDLJdnPW0yeEIa1uqEIHb-tYX3CwCw,3649
|
|
36
36
|
llm_bridge/logic/chat_generate/model_client_factory/openai_client_factory.py,sha256=uSDkNcUKdyzfJBE_KPq9Uqpt_DpDulluGjUT-iq8li0,4363
|
|
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
|
|
@@ -45,7 +45,7 @@ llm_bridge/logic/message_preprocess/document_processor.py,sha256=IsVqoFgWNa9i8cR
|
|
|
45
45
|
llm_bridge/logic/message_preprocess/file_type_checker.py,sha256=nkrVki1a2udCeVqUnfIVi7Wxx8OMKbBuHw3FOlm17uo,1603
|
|
46
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
|
-
llm_bridge/resources/model_prices.json,sha256=
|
|
48
|
+
llm_bridge/resources/model_prices.json,sha256=s-qQTO68APWFJf_r_OBnTm0J7gPEPfRMFsJRukimNbU,3468
|
|
49
49
|
llm_bridge/type/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
50
|
llm_bridge/type/chat_response.py,sha256=zEw-my_I0-7msmlTySdBGE2vWUIPILex0UrUPqTJiYY,754
|
|
51
51
|
llm_bridge/type/message.py,sha256=NyWmSSrciFfvF81aBwAH8qFpo5IpRhh8QXMselbYen8,370
|
|
@@ -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.
|
|
59
|
-
llm_bridge-1.
|
|
60
|
-
llm_bridge-1.
|
|
61
|
-
llm_bridge-1.
|
|
62
|
-
llm_bridge-1.
|
|
58
|
+
llm_bridge-1.11.0a0.dist-info/licenses/LICENSE,sha256=m6uon-6P_CaiqcBfApMfjG9YRtDxcr40Z52JcqUCEAE,1069
|
|
59
|
+
llm_bridge-1.11.0a0.dist-info/METADATA,sha256=cVWZ0rKvH4I_AoMlkrOoZ4CPal9wezXjpb8v_5dhTR4,7851
|
|
60
|
+
llm_bridge-1.11.0a0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
61
|
+
llm_bridge-1.11.0a0.dist-info/top_level.txt,sha256=PtxyrgNX1lSa1Ab_qswg0sekSXejG5zrS6b_v3Po05g,11
|
|
62
|
+
llm_bridge-1.11.0a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|