Recipes / test.py
Boadiwaa's picture
Rename app.py to test.py
692c145 verified
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()