black formatting

This commit is contained in:
Steve Androulakis
2024-12-31 12:28:02 -08:00
parent c6ea92bfe5
commit 396b748b7d
3 changed files with 20 additions and 20 deletions

View File

@@ -2,24 +2,26 @@ from dataclasses import dataclass
from temporalio import activity from temporalio import activity
from ollama import chat, ChatResponse from ollama import chat, ChatResponse
@dataclass @dataclass
class OllamaPromptInput: class OllamaPromptInput:
prompt: str prompt: str
context_instructions: str context_instructions: str
class OllamaActivities: class OllamaActivities:
@activity.defn @activity.defn
def prompt_ollama(self, input: OllamaPromptInput) -> str: def prompt_ollama(self, input: OllamaPromptInput) -> str:
model_name = 'mistral' model_name = "mistral"
messages = [ messages = [
{ {
'role': 'system', "role": "system",
'content': input.context_instructions, "content": input.context_instructions,
}, },
{ {
'role': 'user', "role": "user",
'content': input.prompt, "content": input.prompt,
} },
] ]
response: ChatResponse = chat(model=model_name, messages=messages) response: ChatResponse = chat(model=model_name, messages=messages)

View File

@@ -1,13 +1,14 @@
from ollama import chat, ChatResponse from ollama import chat, ChatResponse
def main(): def main():
model_name = 'mistral' model_name = "mistral"
# The messages to pass to the model # The messages to pass to the model
messages = [ messages = [
{ {
'role': 'user', "role": "user",
'content': 'Why is the sky blue?', "content": "Why is the sky blue?",
} }
] ]
@@ -17,5 +18,6 @@ def main():
# Print the full message content # Print the full message content
print(response.message.content) print(response.message.content)
if __name__ == '__main__':
if __name__ == "__main__":
main() main()

View File

@@ -158,10 +158,6 @@ class EntityOllamaWorkflow:
# Return (context_instructions, prompt) for summarizing the conversation # Return (context_instructions, prompt) for summarizing the conversation
def prompt_summary_with_history(self) -> tuple[str, str]: def prompt_summary_with_history(self) -> tuple[str, str]:
history_string = self.format_history() history_string = self.format_history()
context_instructions = ( context_instructions = f"Here is the conversation history between a user and a chatbot: {history_string}"
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."
)
actual_prompt = (
"Please produce a two sentence summary of this conversation."
)
return (context_instructions, actual_prompt) return (context_instructions, actual_prompt)