inferencesh 0.4.20__py3-none-any.whl → 0.4.23__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/models/llm.py +12 -2
- {inferencesh-0.4.20.dist-info → inferencesh-0.4.23.dist-info}/METADATA +1 -1
- {inferencesh-0.4.20.dist-info → inferencesh-0.4.23.dist-info}/RECORD +7 -7
- {inferencesh-0.4.20.dist-info → inferencesh-0.4.23.dist-info}/WHEEL +0 -0
- {inferencesh-0.4.20.dist-info → inferencesh-0.4.23.dist-info}/entry_points.txt +0 -0
- {inferencesh-0.4.20.dist-info → inferencesh-0.4.23.dist-info}/licenses/LICENSE +0 -0
- {inferencesh-0.4.20.dist-info → inferencesh-0.4.23.dist-info}/top_level.txt +0 -0
inferencesh/models/llm.py
CHANGED
|
@@ -6,6 +6,7 @@ from threading import Thread
|
|
|
6
6
|
import time
|
|
7
7
|
from contextlib import contextmanager
|
|
8
8
|
import base64
|
|
9
|
+
import json
|
|
9
10
|
|
|
10
11
|
from .base import BaseAppInput, BaseAppOutput
|
|
11
12
|
from .file import File
|
|
@@ -216,6 +217,10 @@ def build_messages(
|
|
|
216
217
|
def render_message(msg: ContextMessage, allow_multipart: bool) -> str | List[dict]:
|
|
217
218
|
parts = []
|
|
218
219
|
text = transform_user_message(msg.text) if transform_user_message and msg.role == ContextMessageRole.USER else msg.text
|
|
220
|
+
if msg.tool_calls:
|
|
221
|
+
for tool_call in msg.tool_calls:
|
|
222
|
+
tool_call_string = json.dumps(tool_call)
|
|
223
|
+
text += f"\n\nTool call: {tool_call_string}"
|
|
219
224
|
if text:
|
|
220
225
|
parts.append({"type": "text", "text": text})
|
|
221
226
|
if msg.image:
|
|
@@ -228,7 +233,11 @@ def build_messages(
|
|
|
228
233
|
return parts
|
|
229
234
|
if len(parts) == 1 and parts[0]["type"] == "text":
|
|
230
235
|
return parts[0]["text"]
|
|
231
|
-
|
|
236
|
+
if len(parts) > 1:
|
|
237
|
+
if parts.any(lambda x: x["type"] == "image_url"):
|
|
238
|
+
raise ValueError("Image content requires multipart support")
|
|
239
|
+
return parts
|
|
240
|
+
raise ValueError("Invalid message content")
|
|
232
241
|
|
|
233
242
|
messages = [{"role": "system", "content": input_data.system_prompt}] if input_data.system_prompt is not None and input_data.system_prompt != "" else []
|
|
234
243
|
|
|
@@ -255,7 +264,8 @@ def build_messages(
|
|
|
255
264
|
user_input_image = input_data.image
|
|
256
265
|
multipart = multipart or input_data.image is not None
|
|
257
266
|
|
|
258
|
-
|
|
267
|
+
input_role = input_data.role if hasattr(input_data, "role") else ContextMessageRole.USER
|
|
268
|
+
user_msg = ContextMessage(role=input_role, text=user_input_text, image=user_input_image)
|
|
259
269
|
|
|
260
270
|
input_data.context.append(user_msg)
|
|
261
271
|
|
|
@@ -3,13 +3,13 @@ inferencesh/client.py,sha256=sMgr6vVPD84P3LpQfjmuKqlRpbgOUmWLFQ9IJM5kWzc,39410
|
|
|
3
3
|
inferencesh/models/__init__.py,sha256=FDwcdtT6c4hbRitymjmN-hZMlQa8RbKSftkZZyjtUXA,536
|
|
4
4
|
inferencesh/models/base.py,sha256=eTwRvXAjMGh6b8AUXWKSGpRyeScAkPs6bNYY8AXKSz8,5505
|
|
5
5
|
inferencesh/models/file.py,sha256=H4s-A2RWfNTMCcLqSLpqNHvGfSvYEnbZaJj-rWftrL0,11743
|
|
6
|
-
inferencesh/models/llm.py,sha256=
|
|
6
|
+
inferencesh/models/llm.py,sha256=1jLgFiFombWLUzitvb0KEFNKIJqj2oxmAFunXuhcgrY,29164
|
|
7
7
|
inferencesh/utils/__init__.py,sha256=-xiD6uo2XzcrPAWFb_fUbaimmnW4KFKc-8IvBzaxNd4,148
|
|
8
8
|
inferencesh/utils/download.py,sha256=DRGBudiPVa5bDS35KfR-DYeGRk7gO03WOelnisecwMo,1815
|
|
9
9
|
inferencesh/utils/storage.py,sha256=E4J8emd4eFKdmdDgAqzz3TpaaDd3n0l8gYlMHuY8yIU,519
|
|
10
|
-
inferencesh-0.4.
|
|
11
|
-
inferencesh-0.4.
|
|
12
|
-
inferencesh-0.4.
|
|
13
|
-
inferencesh-0.4.
|
|
14
|
-
inferencesh-0.4.
|
|
15
|
-
inferencesh-0.4.
|
|
10
|
+
inferencesh-0.4.23.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
|
|
11
|
+
inferencesh-0.4.23.dist-info/METADATA,sha256=bcK_FxV0hWc1U151z17A2IrNGxhJnExlQ7ONx-RvYjI,5406
|
|
12
|
+
inferencesh-0.4.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
inferencesh-0.4.23.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
|
|
14
|
+
inferencesh-0.4.23.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
|
|
15
|
+
inferencesh-0.4.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|