Jiaaaaaaax commited on
Commit
0f1f17a
·
verified ·
1 Parent(s): e58d934

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -12
app.py CHANGED
@@ -29,7 +29,8 @@ def create_assistant_json(uploaded_file, assistant_name, assistant_message):
29
 
30
  def generate_response(prompt):
31
  client = openai.OpenAI(api_key=os.environ["API_TOKEN"])
32
- instruction = "Please generate a cocktail recipe based on the user's mood description.\n\n"
 
33
  prompt = instruction + prompt
34
 
35
  messages=[
@@ -46,22 +47,50 @@ def generate_response(prompt):
46
  return str(e)
47
 
48
  # Creating the Gradio interface
49
- with gr.Blocks(css=".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)}") as demo:
50
- gr.Markdown("## To create an OpenAI Assistant please fill in the following sections. Upload a file to give the Assistant knowledge and a focus on something outside of it's normal training. Then add an assistant name and message. The Assistant message should guide the model into in a role. An example would be, You are a helpful Asssitant who is knowledgable in the field of...")
51
- gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
52
  with gr.Row():
53
- # file_input = gr.File(label="Upload your file", type="filepath")
54
- description = gr.Textbox(label="The User Input")
55
- # chatbot = gr.Textbox(label="Chatbot Response")
56
- generate_button = gr.Button("Generate Your Cocktail Recipe")
57
- output_id = gr.Textbox(label="Your Cocktail Recipe", value="")
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  generate_button.click(
60
- fn=generate_response,
61
- inputs=description,
62
- outputs=output_id
63
  )
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  if __name__ == "__main__":
66
  demo.launch(#enable_queue=False,
67
  # Creates an auth screen
 
29
 
30
  def generate_response(prompt):
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
+ 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 + prompt
35
 
36
  messages=[
 
47
  return str(e)
48
 
49
  # Creating the Gradio interface
50
+ with gr.Blocks(css=".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');}") as demo:
 
 
51
  with gr.Row():
52
+ gr.Markdown("## MoodShaker Cocktail Generator")
53
+ gr.Markdown("### Enter your preferences and let AI create a unique cocktail recipe for you!")
54
+
55
+ with gr.Column(scale=1):
56
+ mood = gr.Textbox(label="Mood")
57
+ sweetness = gr.Slider(label="Sweetness", minimum=0, maximum=10)
58
+ sour = gr.Slider(label="Sour", minimum=0, maximum=10)
59
+ savory = gr.Slider(label="Savory", minimum=0, maximum=10)
60
+ bitter = gr.Slider(label="Bitter", minimum=0, maximum=10)
61
+ flavor_association = gr.CheckboxGroup(label="Flavor Association", choices=["Fruity", "Herbal", "Spicy", "Floral", "Nutty", "Woody", "Earthy"], inline=True)
62
+ drinking_experience = gr.CheckboxGroup(label="Drinking Experience", choices=["Refreshing", "Warming", "Comforting", "Energizing", "Relaxing"], inline=True)
63
+ soberness_level = gr.Slider(label="Level of Soberness", minimum=0, maximum=10)
64
+ allergies = gr.Textbox(label="Allergies")
65
+ additional_requests = gr.Textbox(label="Anything else you would like to address")
66
+
67
+ with gr.Row():
68
+ generate_button = gr.Button("Generate Your Cocktail Recipe")
69
+ output_recipe = gr.Textbox(label="Your Cocktail Recipe", value="", readonly=True)
70
 
71
  generate_button.click(
72
+ fn=generate_cocktail,
73
+ inputs=[mood, sweetness, sour, savory, bitter, flavor_association, drinking_experience, soberness_level, allergies, additional_requests],
74
+ outputs=output_recipe
75
  )
76
 
77
+
78
+ # with gr.Blocks(css=".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)}") as demo:
79
+ # gr.Markdown("## To create an OpenAI Assistant please fill in the following sections. Upload a file to give the Assistant knowledge and a focus on something outside of it's normal training. Then add an assistant name and message. The Assistant message should guide the model into in a role. An example would be, You are a helpful Asssitant who is knowledgable in the field of...")
80
+ # gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
81
+ # with gr.Row():
82
+ # # file_input = gr.File(label="Upload your file", type="filepath")
83
+ # description = gr.Textbox(label="The User Input")
84
+ # # chatbot = gr.Textbox(label="Chatbot Response")
85
+ # generate_button = gr.Button("Generate Your Cocktail Recipe")
86
+ # output_id = gr.Textbox(label="Your Cocktail Recipe", value="")
87
+
88
+ # generate_button.click(
89
+ # fn=generate_response,
90
+ # inputs=description,
91
+ # outputs=output_id
92
+ # )
93
+
94
  if __name__ == "__main__":
95
  demo.launch(#enable_queue=False,
96
  # Creates an auth screen