File size: 1,099 Bytes
6c8e733
76d16e9
62668b7
 
f113cab
 
62668b7
6c8e733
8b9eea6
b1098cd
dab6a9c
935aee4
6c8e733
 
3bbe889
6c8e733
d785b0c
692c145
f113cab
97c88f6
d2ae85c
62668b7
 
 
 
dab6a9c
e07dd84
d2ae85c
692c145
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from openai import OpenAI
import os
import gradio as gr

api_key=os.getenv("OPENAI_API_KEY")
client = OpenAI(api_key=api_key)

def get_open_ai_output(recipe_titles):
    response=client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[{"role": "system", "content": f"""Suggest a recipe title based on the food ingredient {recipe_titles}, 
    then acting as a cookbook give the full recipe for the title suggested, include ingredients and instructions"""}],
    temperature=0.98,
    max_tokens = 4000)
    response = response.choices[0].message.content
    return response

demo = gr.Interface(fn=get_open_ai_output, 
                    inputs=gr.Textbox(label="Ingredient"),
                    outputs=gr.Textbox(label="Recipe", lines=20),
                    title =  """
                
                     # **<span style="color:#3526A">Something Sweet...</span>**
                
                    """ , 
                    description = "**Generate different recipes from just ONE ingredient!**", allow_flagging="never")

if __name__ == "__main__":
    demo.launch()