inferencesh 0.4.18__py3-none-any.whl → 0.4.20__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 CHANGED
@@ -21,7 +21,6 @@ class Message(BaseAppInput):
21
21
  role: ContextMessageRole
22
22
  content: str
23
23
 
24
-
25
24
  class ContextMessage(BaseAppInput):
26
25
  role: ContextMessageRole = Field(
27
26
  description="the role of the message. user, assistant, or system",
@@ -33,6 +32,10 @@ class ContextMessage(BaseAppInput):
33
32
  description="the image file of the message",
34
33
  default=None
35
34
  )
35
+ tool_calls: Optional[List[Dict[str, Any]]] = Field(
36
+ description="the tool calls of the message",
37
+ default=None
38
+ )
36
39
 
37
40
  class BaseLLMInput(BaseAppInput):
38
41
  """Base class with common LLM fields."""
@@ -53,8 +56,12 @@ class BaseLLMInput(BaseAppInput):
53
56
  ]
54
57
  ]
55
58
  )
59
+ role: ContextMessageRole = Field(
60
+ description="the role of the input text",
61
+ default=ContextMessageRole.USER
62
+ )
56
63
  text: str = Field(
57
- description="the user prompt to use for the model",
64
+ description="the input text to use for the model",
58
65
  examples=[
59
66
  "write a haiku about artificial general intelligence"
60
67
  ]
@@ -230,6 +237,13 @@ def build_messages(
230
237
  images = [msg.image for msg in messages if msg.image]
231
238
  image = images[0] if images else None # TODO: handle multiple images
232
239
  return ContextMessage(role=messages[0].role, text=text, image=image)
240
+
241
+ def merge_tool_calls(messages: List[ContextMessage]) -> List[Dict[str, Any]]:
242
+ tool_calls = []
243
+ for msg in messages:
244
+ if msg.tool_calls:
245
+ tool_calls.extend(msg.tool_calls)
246
+ return tool_calls
233
247
 
234
248
  user_input_text = ""
235
249
  if hasattr(input_data, "text"):
@@ -255,14 +269,16 @@ def build_messages(
255
269
  else:
256
270
  messages.append({
257
271
  "role": current_role,
258
- "content": render_message(merge_messages(current_messages), allow_multipart=multipart)
272
+ "content": render_message(merge_messages(current_messages), allow_multipart=multipart),
273
+ "tool_calls": merge_tool_calls(current_messages)
259
274
  })
260
275
  current_messages = [msg]
261
276
  current_role = msg.role
262
277
  if len(current_messages) > 0:
263
278
  messages.append({
264
279
  "role": current_role,
265
- "content": render_message(merge_messages(current_messages), allow_multipart=multipart)
280
+ "content": render_message(merge_messages(current_messages), allow_multipart=multipart),
281
+ "tool_calls": merge_tool_calls(current_messages)
266
282
  })
267
283
 
268
284
  return messages
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.4.18
3
+ Version: 0.4.20
4
4
  Summary: inference.sh Python SDK
5
5
  Author-email: "Inference Shell Inc." <hello@inference.sh>
6
6
  Project-URL: Homepage, https://github.com/inference-sh/sdk
@@ -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=ytgSG-qTdEDmq_vrf7JfyCnevMMTimPiDUad4X-F2-o,28065
6
+ inferencesh/models/llm.py,sha256=1k54fEiY0L241vzcENeNvCWDrCbntfILB0-95JxKbWg,28708
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.18.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
11
- inferencesh-0.4.18.dist-info/METADATA,sha256=RuUr8wSL3N_vIt5zahGI3ADvNdbDKxlyilQ6n3eS5Aw,5406
12
- inferencesh-0.4.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- inferencesh-0.4.18.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
14
- inferencesh-0.4.18.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
15
- inferencesh-0.4.18.dist-info/RECORD,,
10
+ inferencesh-0.4.20.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
11
+ inferencesh-0.4.20.dist-info/METADATA,sha256=K8shP2g-2-MG2fu-yOd0zwdyCE8W9RKz33WGyxcJzDA,5406
12
+ inferencesh-0.4.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ inferencesh-0.4.20.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
14
+ inferencesh-0.4.20.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
15
+ inferencesh-0.4.20.dist-info/RECORD,,