mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 14:08:08 +01:00
black formatting
This commit is contained in:
@@ -2,24 +2,26 @@ from dataclasses import dataclass
|
||||
from temporalio import activity
|
||||
from ollama import chat, ChatResponse
|
||||
|
||||
|
||||
@dataclass
|
||||
class OllamaPromptInput:
|
||||
prompt: str
|
||||
context_instructions: str
|
||||
|
||||
|
||||
class OllamaActivities:
|
||||
@activity.defn
|
||||
def prompt_ollama(self, input: OllamaPromptInput) -> str:
|
||||
model_name = 'mistral'
|
||||
model_name = "mistral"
|
||||
messages = [
|
||||
{
|
||||
'role': 'system',
|
||||
'content': input.context_instructions,
|
||||
"role": "system",
|
||||
"content": input.context_instructions,
|
||||
},
|
||||
{
|
||||
'role': 'user',
|
||||
'content': input.prompt,
|
||||
}
|
||||
"role": "user",
|
||||
"content": input.prompt,
|
||||
},
|
||||
]
|
||||
|
||||
response: ChatResponse = chat(model=model_name, messages=messages)
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
from ollama import chat, ChatResponse
|
||||
|
||||
|
||||
def main():
|
||||
model_name = 'mistral'
|
||||
|
||||
model_name = "mistral"
|
||||
|
||||
# The messages to pass to the model
|
||||
messages = [
|
||||
{
|
||||
'role': 'user',
|
||||
'content': 'Why is the sky blue?',
|
||||
"role": "user",
|
||||
"content": "Why is the sky blue?",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
# Call ollama's chat function
|
||||
response: ChatResponse = chat(model=model_name, messages=messages)
|
||||
|
||||
|
||||
# Print the full message content
|
||||
print(response.message.content)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -158,10 +158,6 @@ class EntityOllamaWorkflow:
|
||||
# Return (context_instructions, prompt) for summarizing the conversation
|
||||
def prompt_summary_with_history(self) -> tuple[str, str]:
|
||||
history_string = self.format_history()
|
||||
context_instructions = (
|
||||
f"Here is the conversation history between a user and a chatbot: {history_string}"
|
||||
)
|
||||
actual_prompt = (
|
||||
"Please produce a two sentence summary of this conversation."
|
||||
)
|
||||
context_instructions = f"Here is the conversation history between a user and a chatbot: {history_string}"
|
||||
actual_prompt = "Please produce a two sentence summary of this conversation."
|
||||
return (context_instructions, actual_prompt)
|
||||
|
||||
Reference in New Issue
Block a user