LLM-Bridge 1.14.1__py3-none-any.whl → 1.15.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/__init__.py CHANGED
@@ -2,6 +2,6 @@ from .logic.chat_generate.chat_client_factory import create_chat_client
2
2
  from .logic.chat_generate.chat_message_converter import *
3
3
  from .logic.message_preprocess.message_preprocessor import preprocess_messages
4
4
  from .logic.model_prices import ModelPrice, get_model_prices, find_model_prices, calculate_chat_cost
5
- from .type.chat_response import Citation, ChatResponse
5
+ from .type.chat_response import ChatResponse
6
6
  from .type.message import Role, Message, Content, ContentType
7
7
  from .type.serializer import serialize
@@ -7,7 +7,7 @@ from google.genai.types import Part
7
7
 
8
8
  from llm_bridge.client.implementations.gemini.gemini_token_counter import count_gemini_tokens
9
9
  from llm_bridge.client.implementations.printing_status import PrintingStatus
10
- from llm_bridge.type.chat_response import Citation, ChatResponse, File
10
+ from llm_bridge.type.chat_response import ChatResponse, File
11
11
 
12
12
 
13
13
  class GeminiResponseHandler:
@@ -26,7 +26,6 @@ class GeminiResponseHandler:
26
26
  code_output: str = ""
27
27
  files: list[File] = []
28
28
  display: Optional[str] = None
29
- citations: list[Citation] = extract_citations(response)
30
29
  input_tokens, stage_output_tokens = await count_gemini_tokens(response)
31
30
 
32
31
  parts: list[Part] = []
@@ -89,19 +88,6 @@ class GeminiResponseHandler:
89
88
  code_output=code_output,
90
89
  files=files,
91
90
  display=display,
92
- citations=citations,
93
91
  input_tokens=input_tokens,
94
92
  output_tokens=output_tokens,
95
93
  )
96
-
97
-
98
- def extract_citations(response: types.GenerateContentResponse) -> list[Citation]:
99
- citations = []
100
- if candidates := response.candidates:
101
- if grounding_metadata := candidates[0].grounding_metadata:
102
- if grounding_supports := grounding_metadata.grounding_supports:
103
- for grounding_support in grounding_supports:
104
- citation_indices = [index + 1 for index in grounding_support.grounding_chunk_indices]
105
- citation_text = grounding_support.segment.text
106
- citations.append(Citation(text=citation_text, indices=citation_indices))
107
- return citations
@@ -1,19 +1,17 @@
1
1
  import logging
2
2
  import re
3
- from pprint import pprint
4
- from typing import Optional
5
3
 
6
4
  import httpx
7
5
  import openai
8
6
  from fastapi import HTTPException
9
7
  from openai import APIStatusError
10
- from openai.types.responses import WebSearchToolParam, Response, ResponseOutputItem, ResponseOutputMessage, \
8
+ from openai.types.responses import Response, ResponseOutputItem, ResponseOutputMessage, \
11
9
  ResponseOutputText, ResponseReasoningItem
12
10
 
13
11
  from llm_bridge.client.implementations.openai.openai_token_couter import count_openai_responses_input_tokens, \
14
12
  count_openai_output_tokens
15
13
  from llm_bridge.client.model_client.openai_client import OpenAIClient
16
- from llm_bridge.type.chat_response import ChatResponse, Citation, File
14
+ from llm_bridge.type.chat_response import ChatResponse, File
17
15
  from llm_bridge.type.serializer import serialize
18
16
 
19
17
 
@@ -27,7 +25,6 @@ def process_openai_responses_non_stream_response(
27
25
  text: str = ""
28
26
  thought: str = ""
29
27
  files: list[File] = []
30
- citations: list[Citation] = []
31
28
 
32
29
  for output in output_list:
33
30
  if output.type == "message":
@@ -36,27 +33,17 @@ def process_openai_responses_non_stream_response(
36
33
  if content.type == "output_text":
37
34
  output_text: ResponseOutputText = content
38
35
  text += output_text.text
39
- # Citation is unavailable in OpenAI Responses API
40
- # elif annotations := content.annotations:
41
- # for annotation in annotations:
42
- # citations.append(
43
- # Citation(
44
- # text=content.text[annotation.start_index:annotation.end_index],
45
- # url=annotation.url
46
- # )
47
- # )
48
36
  elif output.type == "reasoning":
49
37
  reasoning_item: ResponseReasoningItem = output
50
38
  for summary_delta in reasoning_item.summary:
51
39
  thought += summary_delta.text
52
- # Image Generation to be tested
53
- # if output.type == "image_generation_call":
54
- # file = File(
55
- # name="generated_image.png",
56
- # data=output.result,
57
- # type="image/png",
58
- # )
59
- # files.append(file)
40
+ if output.type == "image_generation_call":
41
+ file = File(
42
+ name="generated_image.png",
43
+ data=output.result,
44
+ type="image/png",
45
+ )
46
+ files.append(file)
60
47
 
61
48
  chat_response = ChatResponse(text=text, files=files)
62
49
  output_tokens = count_openai_output_tokens(chat_response)
@@ -64,7 +51,6 @@ def process_openai_responses_non_stream_response(
64
51
  text=text,
65
52
  thought=thought,
66
53
  files=files,
67
- citations=citations,
68
54
  input_tokens=input_tokens,
69
55
  output_tokens=output_tokens,
70
56
  )
@@ -1,7 +1,6 @@
1
1
  import logging
2
2
  import re
3
- from pprint import pprint
4
- from typing import AsyncGenerator, Optional
3
+ from typing import AsyncGenerator
5
4
 
6
5
  import httpx
7
6
  import openai
@@ -12,7 +11,7 @@ from openai.types.responses import ResponseStreamEvent, ResponseReasoningSummary
12
11
  from llm_bridge.client.implementations.openai.openai_token_couter import count_openai_responses_input_tokens, \
13
12
  count_openai_output_tokens
14
13
  from llm_bridge.client.model_client.openai_client import OpenAIClient
15
- from llm_bridge.type.chat_response import ChatResponse, Citation, File
14
+ from llm_bridge.type.chat_response import ChatResponse, File
16
15
  from llm_bridge.type.serializer import serialize
17
16
 
18
17
 
@@ -20,7 +19,6 @@ def process_delta(event: ResponseStreamEvent) -> ChatResponse:
20
19
  text: str = ""
21
20
  thought: str = ""
22
21
  files: list[File] = []
23
- citations: list[Citation] = []
24
22
 
25
23
  if event.type == "response.output_text.delta":
26
24
  text_delta_event: ResponseTextDeltaEvent = event
@@ -28,23 +26,18 @@ def process_delta(event: ResponseStreamEvent) -> ChatResponse:
28
26
  elif event.type == "response.reasoning_summary_text.delta":
29
27
  reasoning_summary_text_delta_event: ResponseReasoningSummaryTextDeltaEvent = event
30
28
  thought = reasoning_summary_text_delta_event.delta
31
- # Citation is unavailable in OpenAI Responses API
32
- elif event.type == "response.output_text.annotation.added":
33
- pass
34
- # Image Generation to be tested
35
- # if event.type == "response.image_generation_call.partial_image":
36
- # file = File(
37
- # name="generated_image.png",
38
- # data=event.partial_image_b64,
39
- # type="image/png",
40
- # )
41
- # files.append(file)
29
+ if event.type == "response.image_generation_call.partial_image":
30
+ file = File(
31
+ name="generated_image.png",
32
+ data=event.partial_image_b64,
33
+ type="image/png",
34
+ )
35
+ files.append(file)
42
36
 
43
37
  chat_response = ChatResponse(
44
38
  text=text,
45
39
  thought=thought,
46
40
  files=files,
47
- citations=citations,
48
41
  )
49
42
  return chat_response
50
43
 
@@ -61,7 +54,6 @@ async def generate_chunk(
61
54
  text=chat_response.text,
62
55
  thought=chat_response.thought,
63
56
  files=chat_response.files,
64
- citations=chat_response.citations,
65
57
  input_tokens=input_tokens,
66
58
  output_tokens=output_tokens,
67
59
  )
@@ -9,20 +9,6 @@ class File:
9
9
  type: str
10
10
 
11
11
 
12
- @dataclass
13
- class Citation:
14
- text: str
15
- indices: list[int]
16
-
17
-
18
- # TODO: adapt to different Citation formats
19
- # @dataclass
20
- # class Citation:
21
- # text: str
22
- # indices: Optional[list[int]] = None
23
- # url: Optional[str] = None
24
-
25
-
26
12
  @dataclass
27
13
  class ChatResponse:
28
14
  text: Optional[str] = None
@@ -31,7 +17,6 @@ class ChatResponse:
31
17
  code_output: Optional[str] = None
32
18
  files: Optional[list[File]] = None
33
19
  display: Optional[str] = None
34
- citations: Optional[list[Citation]] = None
35
20
  error: Optional[str] = None
36
21
  input_tokens: Optional[int] = 0
37
22
  output_tokens: Optional[int] = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: LLM-Bridge
3
- Version: 1.14.1
3
+ Version: 1.15.0a0
4
4
  Summary: A Bridge for LLMs
5
5
  Author-email: windsnow1025 <windsnow1025@gmail.com>
6
6
  License-Expression: MIT
@@ -37,21 +37,21 @@ PyPI: [https://pypi.org/project/LLM-Bridge/](https://pypi.org/project/LLM-Bridge
37
37
  1. **Model Message Converter**: converts general messages to model messages
38
38
  1. **Media Processor**: converts general media (Image, Audio, Video, PDF) to model compatible formats.
39
39
  3. **Chat Client**: generate stream or non-stream responses
40
- - **Model Thoughts**: captures and formats the model's thinking process
41
- - **Code Execution**: auto generate and execute Python code
42
- - **Web Search + Citations**: extracts and formats citations from search results
40
+ - **Model Thoughts**: captures the model's thinking process
41
+ - **Code Execution**: generates and executes Python code
42
+ - **Web Search**: generates response from search results
43
43
  - **Token Counter**: tracks and reports input and output token usage
44
44
 
45
45
  ### Supported Features for API Types
46
46
 
47
47
  The features listed represent the maximum capabilities of each API type supported by LLM Bridge.
48
48
 
49
- | API Type | Input Format | Capabilities | Output Format |
50
- |----------|--------------------------------|---------------------------------------------------------------------|-------------------|
51
- | OpenAI | Text, Image, PDF | Thinking, Web Search, Code Execution | Text |
52
- | Gemini | Text, Image, Video, Audio, PDF | Thinking, Web Search + Citations, Code Execution, Structured Output | Text, Image, File |
53
- | Claude | Text, Image, PDF | Thinking, Web Search, Code Execution | Text |
54
- | Grok | Text, Image | | Text |
49
+ | API Type | Input Format | Capabilities | Output Format |
50
+ |----------|--------------------------------|---------------------------------------------------------|-------------------|
51
+ | OpenAI | Text, Image, PDF | Thinking, Web Search, Code Execution | Text |
52
+ | Gemini | Text, Image, Video, Audio, PDF | Thinking, Web Search, Code Execution, Structured Output | Text, Image, File |
53
+ | Claude | Text, Image, PDF | Thinking, Web Search, Code Execution | Text |
54
+ | Grok | Text, Image | | Text |
55
55
 
56
56
  #### Planned Features
57
57
 
@@ -70,7 +70,7 @@ The features listed represent the maximum capabilities of each API type supporte
70
70
  uv sync --refresh
71
71
  ```
72
72
 
73
- ### Pycharm Professional
73
+ ### Pycharm
74
74
 
75
75
  1. Add New Interpreter >> Add Local Interpreter
76
76
  - Environment: Select existing
@@ -1,4 +1,4 @@
1
- llm_bridge/__init__.py,sha256=VVG2ThBTsozQnOAyS1m8Jc2Pd4K0NTZVF3KJKchemXc,466
1
+ llm_bridge/__init__.py,sha256=wMt8wIgp0BAq0ex8o5Mj7LbF5cF1hJnMLWWVcs9Q-ok,456
2
2
  llm_bridge/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  llm_bridge/client/chat_client.py,sha256=XISF2BM-WkZJNbnvcLfMcbSzlrE0XMDulyE_VG9zMPU,328
4
4
  llm_bridge/client/implementations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -9,15 +9,15 @@ llm_bridge/client/implementations/claude/claude_token_counter.py,sha256=m_aoLJkF
9
9
  llm_bridge/client/implementations/claude/non_stream_claude_client.py,sha256=EFseZ9LP6bPVwMqur9gxPZCRWGSH0p3EL6HDMYsCDss,3040
10
10
  llm_bridge/client/implementations/claude/stream_claude_client.py,sha256=8jzD9fVptQnSkRVz0oQ3QnQ22NyMm6hjsmEtoDvl8g8,2059
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=_bejFAjo07s4jBpXBGF5djPs3nxZZjHaDkr4w1S8lTs,4321
12
+ llm_bridge/client/implementations/gemini/gemini_response_handler.py,sha256=-2G6WEjd5M_923UWO7oOFbUmElcYyBJotNZUifUIutI,3578
13
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
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=bvDvnENVKaGslk6cvZ_r-waOYx1SSDOU-gjT9Bbf1HA,4349
18
+ llm_bridge/client/implementations/openai/non_stream_openai_responses_client.py,sha256=W5cESL-i9U-C6-zDezCYy-QkyKJFEEzwqPhawRj9FAY,3674
19
19
  llm_bridge/client/implementations/openai/openai_token_couter.py,sha256=ESl3L049NSE6Y1wfrH195ftQIFdr6XjJcmw5gJBeGaA,1472
20
- llm_bridge/client/implementations/openai/steam_openai_responses_client.py,sha256=hoYSCjljtsGhSLmheZ076ZcgN4ZLWee_7VsK6Gpy5X0,4233
20
+ llm_bridge/client/implementations/openai/steam_openai_responses_client.py,sha256=J-MiP9cTJqU4eKV0EWs2UU9q0wVXvJ2AJ7UDVf6ptMw,3891
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=xLRXYD9t5E3QBVIMe-GdD7eESC752cM9_3FCcp6MFIg,1446
@@ -48,7 +48,7 @@ llm_bridge/logic/message_preprocess/message_preprocessor.py,sha256=VR4__ip4ytAo6
48
48
  llm_bridge/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  llm_bridge/resources/model_prices.json,sha256=mDAZxdj34F9VVRxS3E-lKHx_JB-jxOGadWOWnwzvsIs,2372
50
50
  llm_bridge/type/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
- llm_bridge/type/chat_response.py,sha256=zEw-my_I0-7msmlTySdBGE2vWUIPILex0UrUPqTJiYY,754
51
+ llm_bridge/type/chat_response.py,sha256=NJLnz4JJeeCdDHc0OOL3KtTMBLApu4Eo9Q79We48yCM,474
52
52
  llm_bridge/type/message.py,sha256=NyWmSSrciFfvF81aBwAH8qFpo5IpRhh8QXMselbYen8,370
53
53
  llm_bridge/type/serializer.py,sha256=moCL9y_HTO2CFg2w_jc5MljDxKgHiCo_qiz-o4l2jYU,515
54
54
  llm_bridge/type/model_message/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -56,7 +56,7 @@ llm_bridge/type/model_message/claude_message.py,sha256=gYJUTbLUeifQMva3Axarc-VFe
56
56
  llm_bridge/type/model_message/gemini_message.py,sha256=mh8pf929g7_NkBzSOwnLXyrwSzTT4yt2FmyX7NZn0sM,4302
57
57
  llm_bridge/type/model_message/openai_message.py,sha256=xFaLY-cZoSwNd7E9BSWQjBNcRfCVH11X9s2yxXlctR0,453
58
58
  llm_bridge/type/model_message/openai_responses_message.py,sha256=be1q2euA0ybjj4NO6NxOGIRB9eJuXSb4ssUm_bM4Ocs,1529
59
- llm_bridge-1.14.1.dist-info/METADATA,sha256=eDO1HuwlmAq2d21xbIlCAtvkYLoPEqbCkP0HzfslPTA,3541
60
- llm_bridge-1.14.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
61
- llm_bridge-1.14.1.dist-info/licenses/LICENSE,sha256=m6uon-6P_CaiqcBfApMfjG9YRtDxcr40Z52JcqUCEAE,1069
62
- llm_bridge-1.14.1.dist-info/RECORD,,
59
+ llm_bridge-1.15.0a0.dist-info/METADATA,sha256=Y2SgiibrYaEliGDCYNzWq5IjUOE_4grgFs9Mz_5GD8E,3419
60
+ llm_bridge-1.15.0a0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
61
+ llm_bridge-1.15.0a0.dist-info/licenses/LICENSE,sha256=m6uon-6P_CaiqcBfApMfjG9YRtDxcr40Z52JcqUCEAE,1069
62
+ llm_bridge-1.15.0a0.dist-info/RECORD,,