initial working with ollama

This commit is contained in:
Steve Androulakis
2024-12-31 11:46:57 -08:00
commit c6b71b8ffa
12 changed files with 1017 additions and 0 deletions

19
activities.py Normal file
View File

@@ -0,0 +1,19 @@
from temporalio import activity
from ollama import chat, ChatResponse
class OllamaActivities:
@activity.defn
def prompt_ollama(self, prompt: str) -> str:
model_name = 'mistral'
messages = [
{
'role': 'user',
'content': prompt
}
]
# Call ollama's chat function
response: ChatResponse = chat(model=model_name, messages=messages)
# Return the model's text response
return response.message.content