mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 22:50:18 +00:00
Refactor translate_to_french function to use the correct conversation setup
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
from _context import sm
|
||||
|
||||
conversation = sm.create_conversation(llm_model="gpt-4o", llm_provider="openai")
|
||||
|
||||
conversation.add_message(
|
||||
"user", "Translate the following text to French: 'Hello, world!'"
|
||||
)
|
||||
def translate_to_french(text: str) -> str:
|
||||
conversation = sm.create_conversation(llm_model="gpt-4o", llm_provider="openai")
|
||||
|
||||
print(conversation.send().text)
|
||||
conversation.add_message(
|
||||
"user", f"Translate the following text to French: {text!r}"
|
||||
)
|
||||
return conversation.send().text
|
||||
|
||||
|
||||
print(translate_to_french("Hello, world!"))
|
||||
|
||||
Reference in New Issue
Block a user