inferencesh 0.2.12__py3-none-any.whl → 0.2.14__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.

Potentially problematic release.


This version of inferencesh might be problematic. Click here for more details.

inferencesh/__init__.py CHANGED
@@ -10,9 +10,11 @@ from .models import (
10
10
  ContextMessageRole,
11
11
  Message,
12
12
  ContextMessage,
13
- ContextMessageWithImage,
14
13
  LLMInput,
15
- LLMInputWithImage,
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
- "LLMInputWithImage",
30
+ "LLMOutput",
31
+ "build_messages",
32
+ "stream_generate",
33
+ "timing_context",
30
34
  "StorageDir",
31
35
  "download",
32
36
  ]
inferencesh/models/llm.py CHANGED
@@ -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
- message_content.append({"type": "image_url", "image_url": {"url": msg.image.path}})
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
- user_content.append({"type": "image_url", "image_url": {"url": input_data.image.path}})
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})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.2.12
3
+ Version: 0.2.14
4
4
  Summary: inference.sh Python SDK
5
5
  Author: Inference Shell Inc.
6
6
  Author-email: "Inference Shell Inc." <hello@inference.sh>
@@ -1,14 +1,14 @@
1
- inferencesh/__init__.py,sha256=H26z9pSgivkYfH2OfO5ff6emzmiV_Tc77umCRpdvg0Y,561
1
+ inferencesh/__init__.py,sha256=WdADtOhfa3HDOunoE9HLFCTFlXRykYstBIH1FpyWvj8,613
2
2
  inferencesh/models/__init__.py,sha256=FDwcdtT6c4hbRitymjmN-hZMlQa8RbKSftkZZyjtUXA,536
3
3
  inferencesh/models/base.py,sha256=4gZQRi8J7y9U6PrGD9pRIehd1MJVJAqGakPQDs2AKFM,3251
4
4
  inferencesh/models/file.py,sha256=5xnpypcRahM1YcEjj64rv9g2gTimxrZb41YT4r440hU,7393
5
- inferencesh/models/llm.py,sha256=jcBHgBK7uNTc1blfRqVBnYYfvGT952At7DL3NI_OKGc,14784
5
+ inferencesh/models/llm.py,sha256=x5nOLnE0A0NGpveETnVjz8ut0stHi9zRI_RNGClLzmY,15153
6
6
  inferencesh/utils/__init__.py,sha256=-xiD6uo2XzcrPAWFb_fUbaimmnW4KFKc-8IvBzaxNd4,148
7
7
  inferencesh/utils/download.py,sha256=7n5twvoNYDcFnKJyefImaj2YfzRI7vddQw4usZbj38c,1521
8
8
  inferencesh/utils/storage.py,sha256=E4J8emd4eFKdmdDgAqzz3TpaaDd3n0l8gYlMHuY8yIU,519
9
- inferencesh-0.2.12.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
10
- inferencesh-0.2.12.dist-info/METADATA,sha256=BKP-aygKely2hISaZ4OKdRj2Ycd6N_ChQOl0gitZHnQ,2757
11
- inferencesh-0.2.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- inferencesh-0.2.12.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
13
- inferencesh-0.2.12.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
14
- inferencesh-0.2.12.dist-info/RECORD,,
9
+ inferencesh-0.2.14.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
10
+ inferencesh-0.2.14.dist-info/METADATA,sha256=P7wIUeprhVrBlpUKi5tyAiIQ-NZqMpFtjgbJWauho6I,2757
11
+ inferencesh-0.2.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ inferencesh-0.2.14.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
13
+ inferencesh-0.2.14.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
14
+ inferencesh-0.2.14.dist-info/RECORD,,