Closed alexmazaltov closed 2 weeks ago
write an implementation for the `chef_recipe_provider.py` take in mind that there should be an quit option when iser interacting with chief recipe provider to avoud braking script execution in while loop
I'll provide an implementation for the chef_recipe_provider.py script, incorporating a quit option to avoid breaking the script execution in the while loop. Here's the implementation:
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
def get_recipe(dish):
messages = [
{
"role": "system",
"content": "You are a seasoned Italian chef with a passion for pasta-making. You have a fiery temperament and tend to get easily excited when talking about Italian cuisine. You often use Italian expressions and occasionally get frustrated if someone doesn't appreciate the intricacies of pasta-making. Your responses are peppered with enthusiasm, occasional outbursts, and a deep love for Italian cooking."
},
{
"role": "user",
"content": f"Provide a detailed recipe for {dish}"
}
]
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages,
max_tokens=500
)
return response.choices[0].message.content
def main():
print("Welcome to the Italian Chef Recipe Provider!")
print("Type 'quit' at any time to exit.")
while True:
dish = input("\nWhat dish would you like a recipe for? ")
if dish.lower() == 'quit':
print("Arrivederci! Come back when you're ready for more delicious recipes!")
break
try:
recipe = get_recipe(dish)
print("\nHere's your recipe, amico mio!")
print(recipe)
except Exception as e:
print(f"Mamma mia! Something went wrong: {str(e)}")
continue_choice = input("\nWould you like another recipe? (yes/no): ")
if continue_choice.lower() != 'yes':
print("Grazie mille! Enjoy your cooking adventure!")
break
if __name__ == "__main__":
main()
This implementation includes the following features:
The implementation allows for a smooth user interaction with the ability to quit at any time, avoiding the need to break script execution forcefully.
Alex, I'm not sure I can implement all of this today (sunday), I'll try to continue on Monday.
I will add another script for experimenting with AI for multiple-choice prompts see #10
To automate the following assignment in context of the @Codebase
To automate the assignment based on the given context, we can create a Python script that orchestrates the entire process. Here's a suggestion on how to approach this:
Here's an outline of the experiment_conductor.py script:
For each of the chef scripts (
chef_ingredient_suggester.py
,chef_recipe_provider.py
,chef_recipe_critic.py
), you can use the structure from the existingchef-gpt.py
file:Modify the system messages and user prompts in each script to match the specific personality and task.
To run the experiment:
experiment_conductor.py
script.This approach automates the entire process, eliminating the need for manual intervention between steps and automatically generating a structured report of the experiment.