You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/inferencesh/sdk.py
+69-2Lines changed: 69 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,9 @@
5
5
importurllib.request
6
6
importurllib.parse
7
7
importtempfile
8
-
8
+
frompydanticimportField
9
9
fromtypingimportAny, Dict, List
10
+
10
11
importinspect
11
12
importast
12
13
importtextwrap
@@ -214,4 +215,70 @@ def exists(self) -> bool:
214
215
215
216
defrefresh_metadata(self) ->None:
216
217
"""Refresh all metadata from the file."""
217
-
self._populate_metadata()
218
+
self._populate_metadata()
219
+
220
+
221
+
classContextMessage(BaseModel):
222
+
role: str=Field(
223
+
description="The role of the message",
224
+
enum=["user", "assistant", "system"]
225
+
)
226
+
text: str=Field(
227
+
description="The text content of the message"
228
+
)
229
+
230
+
classContextMessageWithImage(ContextMessage):
231
+
image: Optional[File] =Field(
232
+
description="The image url of the message",
233
+
default=None
234
+
)
235
+
236
+
classLLMInput(BaseAppInput):
237
+
system_prompt: str=Field(
238
+
description="The system prompt to use for the model",
239
+
default="You are a helpful assistant that can answer questions and help with tasks.",
240
+
examples=[
241
+
"You are a helpful assistant that can answer questions and help with tasks.",
242
+
"You are a certified medical professional who can provide accurate health information.",
243
+
"You are a certified financial advisor who can give sound investment guidance.",
244
+
"You are a certified cybersecurity expert who can explain security best practices.",
245
+
"You are a certified environmental scientist who can discuss climate and sustainability.",
246
+
]
247
+
)
248
+
context: list[ContextMessage] =Field(
249
+
description="The context to use for the model",
250
+
examples=[
251
+
[
252
+
{"role": "user", "content": [{"type": "text", "text": "What is the capital of France?"}]},
253
+
{"role": "assistant", "content": [{"type": "text", "text": "The capital of France is Paris."}]}
254
+
],
255
+
[
256
+
{"role": "user", "content": [{"type": "text", "text": "What is the weather like today?"}]},
257
+
{"role": "assistant", "content": [{"type": "text", "text": "I apologize, but I don't have access to real-time weather information. You would need to check a weather service or app to get current weather conditions for your location."}]}
258
+
],
259
+
[
260
+
{"role": "user", "content": [{"type": "text", "text": "Can you help me write a poem about spring?"}]},
261
+
{"role": "assistant", "content": [{"type": "text", "text": "Here's a short poem about spring:\n\nGreen buds awakening,\nSoft rain gently falling down,\nNew life springs anew.\n\nWarm sun breaks through clouds,\nBirds return with joyful song,\nNature's sweet rebirth."}]}
{"role": "assistant", "content": [{"type": "text", "text": "Quantum computing is like having a super-powerful calculator that can solve many problems at once instead of one at a time. While regular computers use bits (0s and 1s), quantum computers use quantum bits or \"qubits\" that can be both 0 and 1 at the same time - kind of like being in two places at once! This allows them to process huge amounts of information much faster than regular computers for certain types of problems."}]}
266
+
]
267
+
],
268
+
default=[]
269
+
)
270
+
text: str=Field(
271
+
description="The user prompt to use for the model",
0 commit comments