initial progress

This commit is contained in:
Steve Androulakis
2024-12-31 15:40:46 -08:00
parent 396b748b7d
commit 6355f976ad
8 changed files with 363 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
from dataclasses import dataclass
from temporalio import activity
from ollama import chat, ChatResponse
import json
from temporalio.exceptions import ApplicationError
@dataclass
@@ -12,7 +14,7 @@ class OllamaPromptInput:
class OllamaActivities:
@activity.defn
def prompt_ollama(self, input: OllamaPromptInput) -> str:
model_name = "mistral"
model_name = "qwen2.5:14b"
messages = [
{
"role": "system",
@@ -26,3 +28,16 @@ class OllamaActivities:
response: ChatResponse = chat(model=model_name, messages=messages)
return response.message.content
@activity.defn
def parse_tool_data(self, json_str: str) -> dict:
"""
Parses a JSON string into a dictionary.
Raises a ValueError if the JSON is invalid.
"""
try:
data = json.loads(json_str)
except json.JSONDecodeError as e:
raise ApplicationError(f"Invalid JSON: {e}")
return data