mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-16 22:48:09 +01:00
initial working with ollama
This commit is contained in:
19
activities.py
Normal file
19
activities.py
Normal 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
|
||||
Reference in New Issue
Block a user