Skip to content

Commit 5dc8c51

Browse files
committed
Add helper inputs
1 parent 0ca4cb9 commit 5dc8c51

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

src/inferencesh/sdk.py

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import urllib.request
66
import urllib.parse
77
import tempfile
8-
8+
from pydantic import Field
99
from typing import Any, Dict, List
10+
1011
import inspect
1112
import ast
1213
import textwrap
@@ -214,4 +215,70 @@ def exists(self) -> bool:
214215

215216
def refresh_metadata(self) -> None:
216217
"""Refresh all metadata from the file."""
217-
self._populate_metadata()
218+
self._populate_metadata()
219+
220+
221+
class ContextMessage(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+
class ContextMessageWithImage(ContextMessage):
231+
image: Optional[File] = Field(
232+
description="The image url of the message",
233+
default=None
234+
)
235+
236+
class LLMInput(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."}]}
262+
],
263+
[
264+
{"role": "user", "content": [{"type": "text", "text": "Explain quantum computing in simple terms"}]},
265+
{"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",
272+
examples=[
273+
"What is the capital of France?",
274+
"What is the weather like today?",
275+
"Can you help me write a poem about spring?",
276+
"Explain quantum computing in simple terms"
277+
],
278+
)
279+
280+
class LLMInputWithImage(LLMInput):
281+
image: Optional[File] = Field(
282+
description="The image to use for the model",
283+
default=None
284+
)

0 commit comments

Comments
 (0)