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.
- {inferencesh-0.2.14/src/inferencesh.egg-info → inferencesh-0.2.15}/PKG-INFO +1 -1
- {inferencesh-0.2.14 → inferencesh-0.2.15}/pyproject.toml +1 -1
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/llm.py +26 -36
- {inferencesh-0.2.14 → inferencesh-0.2.15/src/inferencesh.egg-info}/PKG-INFO +1 -1
- {inferencesh-0.2.14 → inferencesh-0.2.15}/LICENSE +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/README.md +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/setup.cfg +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/setup.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/__init__.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/__init__.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/base.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/models/file.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/utils/__init__.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/utils/download.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh/utils/storage.py +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/SOURCES.txt +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/dependency_links.txt +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/entry_points.txt +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/requires.txt +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/src/inferencesh.egg-info/top_level.txt +0 -0
- {inferencesh-0.2.14 → inferencesh-0.2.15}/tests/test_sdk.py +0 -0
|
@@ -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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
170
|
-
if
|
|
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
|
-
|
|
162
|
+
parts.append({"type": "image_url", "image_url": {"url": image_data_uri}})
|
|
174
163
|
elif msg.image.uri:
|
|
175
|
-
|
|
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":
|
|
177
|
+
"content": render_message(msg, allow_multipart=multipart)
|
|
179
178
|
})
|
|
180
179
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
|
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
|
|
File without changes
|