Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,8 @@ def create_assistant_json(uploaded_file, assistant_name, assistant_message):
|
|
30 |
def generate_cocktail(prompt, mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests):
|
31 |
client = openai.OpenAI(api_key=os.environ["API_TOKEN"])
|
32 |
instruction = "Please generate a cocktail recipe based on the user's following preferences.\n\n"
|
33 |
-
|
34 |
-
prompt = instruction +
|
35 |
|
36 |
messages=[
|
37 |
{"role": "system", "content": "You are a helpful bartender assistant."},
|
@@ -47,10 +47,19 @@ def generate_cocktail(prompt, mood, sweetness, sour, savory, bitter, flavor_asso
|
|
47 |
return str(e)
|
48 |
|
49 |
# Creating the Gradio interface
|
50 |
-
with gr.Blocks(css=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
with gr.Row():
|
52 |
-
gr.
|
53 |
-
|
|
|
|
|
54 |
|
55 |
with gr.Column(scale=1):
|
56 |
mood = gr.Textbox(label="Mood")
|
@@ -66,7 +75,7 @@ with gr.Blocks(css=".gradio-container {background: url('https://static.vecteezy.
|
|
66 |
|
67 |
with gr.Row():
|
68 |
generate_button = gr.Button("Generate Your Cocktail Recipe")
|
69 |
-
output_recipe = gr.
|
70 |
|
71 |
generate_button.click(
|
72 |
fn=generate_cocktail,
|
|
|
30 |
def generate_cocktail(prompt, mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests):
|
31 |
client = openai.OpenAI(api_key=os.environ["API_TOKEN"])
|
32 |
instruction = "Please generate a cocktail recipe based on the user's following preferences.\n\n"
|
33 |
+
user_prompt = f"Mood: {mood}\nTaste: Sweetness {sweetness}, Sour {sour}, Savory {savory}, Bitter {bitter}\nFlavor Association: {flavor_association}\nDrinking Experience: {drinking_experience}\nLevel of Soberness: {soberness_level}\nAllergies: {allergies}\nAdditional Requests: {additional_requests}\n\nRecipe:"
|
34 |
+
prompt = instruction + user_prompt
|
35 |
|
36 |
messages=[
|
37 |
{"role": "system", "content": "You are a helpful bartender assistant."},
|
|
|
47 |
return str(e)
|
48 |
|
49 |
# Creating the Gradio interface
|
50 |
+
with gr.Blocks(css='''
|
51 |
+
.gradio-container {background: url('https://static.vecteezy.com/system/resources/thumbnails/030/814/051/small/wooden-table-and-blur-tropical-green-grass-background-product-display-montage-high-quality-8k-fhd-ai-generated-photo.jpg');}
|
52 |
+
#sweetness .range-slider {background: #FAD02E;}
|
53 |
+
#sour .range-slider {background: #4CAF50;}
|
54 |
+
#savory .range-slider {background: #795548;}
|
55 |
+
#bitter .range-slider {background: #F44336;}
|
56 |
+
#soberness_level .range-slider {background: #2196F3;}
|
57 |
+
''') as demo:
|
58 |
with gr.Row():
|
59 |
+
gr.HTML("""
|
60 |
+
<h2 style='text-align: center;'>MoodShaker Cocktail Generator</h2>
|
61 |
+
<p style='text-align: center;'>Enter your preferences and let AI create a unique cocktail recipe for you!</p>
|
62 |
+
""")
|
63 |
|
64 |
with gr.Column(scale=1):
|
65 |
mood = gr.Textbox(label="Mood")
|
|
|
75 |
|
76 |
with gr.Row():
|
77 |
generate_button = gr.Button("Generate Your Cocktail Recipe")
|
78 |
+
output_recipe = gr.HTML(label="Your Cocktail Recipe")
|
79 |
|
80 |
generate_button.click(
|
81 |
fn=generate_cocktail,
|