inferencesh 0.2.30__tar.gz → 0.2.31__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.30/src/inferencesh.egg-info → inferencesh-0.2.31}/PKG-INFO +1 -1
- {inferencesh-0.2.30 → inferencesh-0.2.31}/pyproject.toml +1 -1
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/models/llm.py +26 -8
- {inferencesh-0.2.30 → inferencesh-0.2.31/src/inferencesh.egg-info}/PKG-INFO +1 -1
- {inferencesh-0.2.30 → inferencesh-0.2.31}/LICENSE +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/README.md +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/setup.cfg +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/setup.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/__init__.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/models/__init__.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/models/base.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/models/file.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/utils/__init__.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/utils/download.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh/utils/storage.py +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh.egg-info/SOURCES.txt +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh.egg-info/dependency_links.txt +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh.egg-info/entry_points.txt +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh.egg-info/requires.txt +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/src/inferencesh.egg-info/top_level.txt +0 -0
- {inferencesh-0.2.30 → inferencesh-0.2.31}/tests/test_sdk.py +0 -0
|
@@ -232,18 +232,36 @@ def build_messages(
|
|
|
232
232
|
multipart = any(m.image for m in input_data.context) or input_data.image is not None
|
|
233
233
|
messages = [{"role": "system", "content": input_data.system_prompt}] if input_data.system_prompt is not None and input_data.system_prompt != "" else []
|
|
234
234
|
|
|
235
|
+
def merge_messages(messages: List[ContextMessage]) -> ContextMessage:
|
|
236
|
+
text = "\n\n".join(msg.text for msg in messages if msg.text)
|
|
237
|
+
images = [msg.image for msg in messages if msg.image]
|
|
238
|
+
image = images[0] if images else None # TODO: handle multiple images
|
|
239
|
+
return ContextMessage(role=messages[0].role, text=text, image=image)
|
|
240
|
+
|
|
241
|
+
user_msg = ContextMessage(role=ContextMessageRole.USER, text=input_data.text, image=input_data.image)
|
|
242
|
+
|
|
243
|
+
input_data.context.append(user_msg)
|
|
244
|
+
|
|
245
|
+
current_role = None
|
|
246
|
+
current_messages = []
|
|
247
|
+
|
|
235
248
|
for msg in input_data.context:
|
|
249
|
+
if msg.role == current_role or current_role is None:
|
|
250
|
+
current_messages.append(msg)
|
|
251
|
+
current_role = msg.role
|
|
252
|
+
else:
|
|
253
|
+
messages.append({
|
|
254
|
+
"role": current_role,
|
|
255
|
+
"content": render_message(merge_messages(current_messages), allow_multipart=multipart)
|
|
256
|
+
})
|
|
257
|
+
current_messages = [msg]
|
|
258
|
+
current_role = msg.role
|
|
259
|
+
if len(current_messages) > 0:
|
|
236
260
|
messages.append({
|
|
237
|
-
"role":
|
|
238
|
-
"content": render_message(
|
|
261
|
+
"role": current_role,
|
|
262
|
+
"content": render_message(merge_messages(current_messages), allow_multipart=multipart)
|
|
239
263
|
})
|
|
240
264
|
|
|
241
|
-
user_msg = ContextMessage(role=ContextMessageRole.USER, text=input_data.text, image=input_data.image)
|
|
242
|
-
messages.append({
|
|
243
|
-
"role": "user",
|
|
244
|
-
"content": render_message(user_msg, allow_multipart=multipart)
|
|
245
|
-
})
|
|
246
|
-
|
|
247
265
|
return messages
|
|
248
266
|
|
|
249
267
|
|
|
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
|