Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,8 +29,8 @@ def create_assistant_json(uploaded_file, assistant_name, assistant_message):
|
|
| 29 |
|
| 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
|
| 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=[
|
|
@@ -48,12 +48,14 @@ def generate_cocktail(prompt, mood, sweetness, sour, savory, bitter, flavor_asso
|
|
| 48 |
|
| 49 |
# Creating the Gradio interface
|
| 50 |
with gr.Blocks(css='''
|
| 51 |
-
.gradio-container {background: url('https://
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
''') as demo:
|
| 58 |
with gr.Row():
|
| 59 |
gr.HTML("""
|
|
@@ -84,6 +86,13 @@ with gr.Blocks(css='''
|
|
| 84 |
)
|
| 85 |
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# 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:
|
| 88 |
# 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...")
|
| 89 |
# gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
|
|
@@ -100,6 +109,7 @@ with gr.Blocks(css='''
|
|
| 100 |
# outputs=output_id
|
| 101 |
# )
|
| 102 |
|
|
|
|
| 103 |
if __name__ == "__main__":
|
| 104 |
demo.launch(#enable_queue=False,
|
| 105 |
# Creates an auth screen
|
|
|
|
| 29 |
|
| 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 provide a cocktail recipe given the mood and preference of the user.\n\n"
|
| 33 |
+
user_prompt = f"Mood: {mood}\nTaste: Sweetness {sweetness}/10, Sour {sour}/10, Savory {savory}/10, Bitter {bitter}/10\nFlavor Association: {flavor_association}\nDrinking Experience: {drinking_experience}\nLevel of Soberness: {soberness_level}\nAllergies: {allergies}\nAdditional Requests: {additional_requests}\n\nMake sure to avoid all allergic ingredients.\n\nRecipe:"
|
| 34 |
prompt = instruction + user_prompt
|
| 35 |
|
| 36 |
messages=[
|
|
|
|
| 48 |
|
| 49 |
# Creating the Gradio interface
|
| 50 |
with gr.Blocks(css='''
|
| 51 |
+
.gradio-container {background: url('https://images.unsplash.com/photo-1514361726087-38371321b5cd?q=80&w=2370&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');}
|
| 52 |
+
.gradio-container { background-color: rgba(255, 255, 255, 0.1) !important; color: white; }
|
| 53 |
+
.gradio-container * { color: inherit; }
|
| 54 |
+
.gradio-label { color: white !important; }
|
| 55 |
+
.gradio-description { color: white !important; }
|
| 56 |
+
input, textarea, select { background-color: rgba(255, 255, 255, 0.2) !important; border-color: rgba(255, 255, 255, 0.4) !important; color: white !important; }
|
| 57 |
+
.gradio-button { background-color: rgba(255, 255, 255, 0.3) !important; border-color: rgba(255, 255, 255, 0.4) !important; color: white !important; }
|
| 58 |
+
.gradio-theme-dark .gradio-toolbar { background-color: rgba(0, 0, 0, 0.5) !important; }
|
| 59 |
''') as demo:
|
| 60 |
with gr.Row():
|
| 61 |
gr.HTML("""
|
|
|
|
| 86 |
)
|
| 87 |
|
| 88 |
|
| 89 |
+
# sweetness .range-slider {background: #FAD02E;}
|
| 90 |
+
# sour .range-slider {background: #4CAF50;}
|
| 91 |
+
# savory .range-slider {background: #795548;}
|
| 92 |
+
# bitter .range-slider {background: #F44336;}
|
| 93 |
+
# soberness_level .range-slider {background: #2196F3;}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
# 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:
|
| 97 |
# 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...")
|
| 98 |
# gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
|
|
|
|
| 109 |
# outputs=output_id
|
| 110 |
# )
|
| 111 |
|
| 112 |
+
|
| 113 |
if __name__ == "__main__":
|
| 114 |
demo.launch(#enable_queue=False,
|
| 115 |
# Creates an auth screen
|