Boadiwaa/Recipes
1
1from openai import OpenAI2import os3import gradio as gr4 5api_key=os.getenv("OPENAI_API_KEY")6client = OpenAI(api_key=api_key)7 8def get_open_ai_output(recipe_titles):9 response=client.chat.completions.create(10 model="gpt-3.5-turbo",11 messages=[{"role": "system", "content": f"""Suggest a recipe title based on the food ingredient {recipe_titles}, 12 then acting as a cookbook give the full recipe for the title suggested, include ingredients and instructions"""}],13 temperature=0.98,14 max_tokens = 4000)15 response = response.choices[0].message.content16 return response17 18demo = gr.Interface(fn=get_open_ai_output, 19 inputs=gr.Textbox(label="Ingredient"),20 outputs=gr.Textbox(label="Recipe", lines=20),21 title = """22 23 # **<span style="color:#3526A">Something Sweet...</span>**24 25 """ , 26 description = "**Generate different recipes from just ONE ingredient!**", allow_flagging="never")27 28if __name__ == "__main__":29 demo.launch()30 