inferencesh 0.2.12__tar.gz → 0.2.14__tar.gz
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.
Potentially problematic release.
This version of inferencesh might be problematic. Click here for more details.
- {inferencesh-0.2.12/src/inferencesh.egg-info → inferencesh-0.2.14}/PKG-INFO +1 -1
- {inferencesh-0.2.12 → inferencesh-0.2.14}/pyproject.toml +1 -1
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/__init__.py +8 -4
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/models/llm.py +9 -2
- {inferencesh-0.2.12 → inferencesh-0.2.14/src/inferencesh.egg-info}/PKG-INFO +1 -1
- {inferencesh-0.2.12 → inferencesh-0.2.14}/LICENSE +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/README.md +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/setup.cfg +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/setup.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/models/__init__.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/models/base.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/models/file.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/utils/__init__.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/utils/download.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh/utils/storage.py +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh.egg-info/SOURCES.txt +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh.egg-info/dependency_links.txt +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh.egg-info/entry_points.txt +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh.egg-info/requires.txt +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/src/inferencesh.egg-info/top_level.txt +0 -0
- {inferencesh-0.2.12 → inferencesh-0.2.14}/tests/test_sdk.py +0 -0
|
@@ -10,9 +10,11 @@ from .models import (
|
|
|
10
10
|
ContextMessageRole,
|
|
11
11
|
Message,
|
|
12
12
|
ContextMessage,
|
|
13
|
-
ContextMessageWithImage,
|
|
14
13
|
LLMInput,
|
|
15
|
-
|
|
14
|
+
LLMOutput,
|
|
15
|
+
build_messages,
|
|
16
|
+
stream_generate,
|
|
17
|
+
timing_context,
|
|
16
18
|
)
|
|
17
19
|
from .utils import StorageDir, download
|
|
18
20
|
|
|
@@ -24,9 +26,11 @@ __all__ = [
|
|
|
24
26
|
"ContextMessageRole",
|
|
25
27
|
"Message",
|
|
26
28
|
"ContextMessage",
|
|
27
|
-
"ContextMessageWithImage",
|
|
28
29
|
"LLMInput",
|
|
29
|
-
"
|
|
30
|
+
"LLMOutput",
|
|
31
|
+
"build_messages",
|
|
32
|
+
"stream_generate",
|
|
33
|
+
"timing_context",
|
|
30
34
|
"StorageDir",
|
|
31
35
|
"download",
|
|
32
36
|
]
|
|
@@ -5,6 +5,7 @@ from queue import Queue
|
|
|
5
5
|
from threading import Thread
|
|
6
6
|
import time
|
|
7
7
|
from contextlib import contextmanager
|
|
8
|
+
import base64
|
|
8
9
|
|
|
9
10
|
from .base import BaseAppInput, BaseAppOutput
|
|
10
11
|
from .file import File
|
|
@@ -136,6 +137,10 @@ def timing_context():
|
|
|
136
137
|
finally:
|
|
137
138
|
pass
|
|
138
139
|
|
|
140
|
+
def image_to_base64_data_uri(file_path):
|
|
141
|
+
with open(file_path, "rb") as img_file:
|
|
142
|
+
base64_data = base64.b64encode(img_file.read()).decode('utf-8')
|
|
143
|
+
return f"data:image/png;base64,{base64_data}"
|
|
139
144
|
|
|
140
145
|
def build_messages(
|
|
141
146
|
input_data: LLMInput,
|
|
@@ -164,7 +169,8 @@ def build_messages(
|
|
|
164
169
|
message_content.append({"type": "text", "text": text})
|
|
165
170
|
if hasattr(msg, 'image') and msg.image:
|
|
166
171
|
if msg.image.path:
|
|
167
|
-
|
|
172
|
+
image_data_uri = image_to_base64_data_uri(msg.image.path)
|
|
173
|
+
message_content.append({"type": "image_url", "image_url": {"url": image_data_uri}})
|
|
168
174
|
elif msg.image.uri:
|
|
169
175
|
message_content.append({"type": "image_url", "image_url": {"url": msg.image.uri}})
|
|
170
176
|
messages.append({
|
|
@@ -181,7 +187,8 @@ def build_messages(
|
|
|
181
187
|
user_content.append({"type": "text", "text": text})
|
|
182
188
|
if hasattr(input_data, 'image') and input_data.image:
|
|
183
189
|
if input_data.image.path:
|
|
184
|
-
|
|
190
|
+
image_data_uri = image_to_base64_data_uri(input_data.image.path)
|
|
191
|
+
user_content.append({"type": "image_url", "image_url": {"url": image_data_uri}})
|
|
185
192
|
elif input_data.image.uri:
|
|
186
193
|
user_content.append({"type": "image_url", "image_url": {"url": input_data.image.uri}})
|
|
187
194
|
messages.append({"role": "user", "content": user_content})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|