Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,20 +27,33 @@ def create_assistant_json(uploaded_file, assistant_name, assistant_message):
|
|
27 |
|
28 |
return assistant.id
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Creating the Gradio interface
|
31 |
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:
|
32 |
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...")
|
33 |
gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
|
34 |
with gr.Row():
|
35 |
-
file_input = gr.File(label="Upload your file", type="filepath")
|
36 |
-
|
37 |
-
|
38 |
-
generate_button = gr.Button("Generate Your
|
39 |
-
output_id = gr.Textbox(label="Your
|
40 |
|
41 |
generate_button.click(
|
42 |
-
fn=
|
43 |
-
inputs=
|
44 |
outputs=output_id
|
45 |
)
|
46 |
|
|
|
27 |
|
28 |
return assistant.id
|
29 |
|
30 |
+
def generate_response(prompt):
|
31 |
+
instruction = "Please generate a cocktail recipe based on the user's mood description.\n\n"
|
32 |
+
prompt = instruction + prompt
|
33 |
+
try:
|
34 |
+
response = openai.Completion.create(
|
35 |
+
engine="davinci",
|
36 |
+
prompt=prompt,
|
37 |
+
max_tokens=150
|
38 |
+
)
|
39 |
+
return response.choices[0].text.strip()
|
40 |
+
except Exception as e:
|
41 |
+
return str(e)
|
42 |
+
|
43 |
# Creating the Gradio interface
|
44 |
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:
|
45 |
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...")
|
46 |
gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
|
47 |
with gr.Row():
|
48 |
+
# file_input = gr.File(label="Upload your file", type="filepath")
|
49 |
+
description = gr.Textbox(label="The User Input")
|
50 |
+
# chatbot = gr.Textbox(label="Chatbot Response")
|
51 |
+
generate_button = gr.Button("Generate Your Cocktail Recipe")
|
52 |
+
output_id = gr.Textbox(label="Your Cocktail Recipe", value="")
|
53 |
|
54 |
generate_button.click(
|
55 |
+
fn=generate_response,
|
56 |
+
inputs=description,
|
57 |
outputs=output_id
|
58 |
)
|
59 |
|