inferencesh 0.2.14__tar.gz → 0.2.15__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.

Files changed (21) hide show
  1. {inferencesh-0.2.14/src/inferencesh.egg-info → inferencesh-0.2.15}/PKG-INFO +1 -1
  2. {inferencesh-0.2.14 → inferencesh-0.2.15}/pyproject.toml +1 -1
  3. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/llm.py +26 -36
  4. {inferencesh-0.2.14 → inferencesh-0.2.15/src/inferencesh.egg-info}/PKG-INFO +1 -1
  5. {inferencesh-0.2.14 → inferencesh-0.2.15}/LICENSE +0 -0
  6. {inferencesh-0.2.14 → inferencesh-0.2.15}/README.md +0 -0
  7. {inferencesh-0.2.14 → inferencesh-0.2.15}/setup.cfg +0 -0
  8. {inferencesh-0.2.14 → inferencesh-0.2.15}/setup.py +0 -0
  9. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/__init__.py +0 -0
  10. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/__init__.py +0 -0
  11. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/base.py +0 -0
  12. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/file.py +0 -0
  13. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/utils/__init__.py +0 -0
  14. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/utils/download.py +0 -0
  15. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/utils/storage.py +0 -0
  16. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/SOURCES.txt +0 -0
  17. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/dependency_links.txt +0 -0
  18. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/entry_points.txt +0 -0
  19. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/requires.txt +0 -0
  20. {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/top_level.txt +0 -0
  21. {inferencesh-0.2.14 → inferencesh-0.2.15}/tests/test_sdk.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.2.14
3
+ Version: 0.2.15
4
4
  Summary: inference.sh Python SDK
5
5
  Author: Inference Shell Inc.
6
6
  Author-email: "Inference Shell Inc." <hello@inference.sh>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "inferencesh"
7
- version = "0.2.14"
7
+ version = "0.2.15"
8
8
  description = "inference.sh Python SDK"
9
9
  authors = [
10
10
  {name = "Inference Shell Inc.", email = "hello@inference.sh"},
@@ -147,51 +147,41 @@ def build_messages(
147
147
  transform_user_message: Optional[Callable[[str], str]] = None
148
148
  ) -> List[Dict[str, Any]]:
149
149
  """Build messages for LLaMA.cpp chat completion.
150
-
151
- Args:
152
- input_data: The input data
153
- transform_user_message: Optional function to transform user message text before building messages
154
- """
155
- messages = [
156
- {
157
- "role": "system",
158
- "content": [{"type": "text", "text": input_data.system_prompt}],
159
- }
160
- ]
161
150
 
162
- # Add context messages
163
- for msg in input_data.context:
164
- message_content = []
165
- text = msg.text
166
- if transform_user_message and msg.role == ContextMessageRole.USER:
167
- text = transform_user_message(text)
151
+ If any message includes image content, builds OpenAI-style multipart format.
152
+ Otherwise, uses plain string-only format.
153
+ """
154
+ def render_message(msg: ContextMessage, allow_multipart: bool) -> str | List[dict]:
155
+ parts = []
156
+ text = transform_user_message(msg.text) if transform_user_message and msg.role == ContextMessageRole.USER else msg.text
168
157
  if text:
169
- message_content.append({"type": "text", "text": text})
170
- if hasattr(msg, 'image') and msg.image:
158
+ parts.append({"type": "text", "text": text})
159
+ if msg.image:
171
160
  if msg.image.path:
172
161
  image_data_uri = image_to_base64_data_uri(msg.image.path)
173
- message_content.append({"type": "image_url", "image_url": {"url": image_data_uri}})
162
+ parts.append({"type": "image_url", "image_url": {"url": image_data_uri}})
174
163
  elif msg.image.uri:
175
- message_content.append({"type": "image_url", "image_url": {"url": msg.image.uri}})
164
+ parts.append({"type": "image_url", "image_url": {"url": msg.image.uri}})
165
+ if allow_multipart:
166
+ return parts
167
+ if len(parts) == 1 and parts[0]["type"] == "text":
168
+ return parts[0]["text"]
169
+ raise ValueError("Image content requires multipart support")
170
+
171
+ multipart = any(m.image for m in input_data.context) or input_data.image is not None
172
+ messages = [{"role": "system", "content": input_data.system_prompt}]
173
+
174
+ for msg in input_data.context:
176
175
  messages.append({
177
176
  "role": msg.role,
178
- "content": message_content
177
+ "content": render_message(msg, allow_multipart=multipart)
179
178
  })
180
179
 
181
- # Add user message
182
- user_content = []
183
- text = input_data.text
184
- if transform_user_message:
185
- text = transform_user_message(text)
186
- if text:
187
- user_content.append({"type": "text", "text": text})
188
- if hasattr(input_data, 'image') and input_data.image:
189
- if 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}})
192
- elif input_data.image.uri:
193
- user_content.append({"type": "image_url", "image_url": {"url": input_data.image.uri}})
194
- messages.append({"role": "user", "content": user_content})
180
+ user_msg = ContextMessage(role=ContextMessageRole.USER, text=input_data.text, image=input_data.image)
181
+ messages.append({
182
+ "role": "user",
183
+ "content": render_message(user_msg, allow_multipart=multipart)
184
+ })
195
185
 
196
186
  return messages
197
187
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.2.14
3
+ Version: 0.2.15
4
4
  Summary: inference.sh Python SDK
5
5
  Author: Inference Shell Inc.
6
6
  Author-email: "Inference Shell Inc." <hello@inference.sh>
File without changes
File without changes
File without changes
File without changes