Refactor translate_to_french function to use the correct conversation setup

This commit is contained in:
2024-10-29 12:18:51 -04:00
parent 467f67d283
commit 3c4ed48786
+9 -5
View File
@@ -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!"))