CoolFace
Apppublic

Yova/kitchenmate

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py33 linesDownload Raw Back to root
1import streamlit as st2import openai3 4client = openai.OpenAI(api_key = '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')5 6def generate_recipe(ingredients):7    prompt = f"Given the following ingredients: {', '.join(ingredients)}, give me a recipe for a lunch plate I can make with them. You don't have to use all of the ingredients."8    response = client.chat.completions.create(9        model="gpt-3.5-turbo",10        messages=[11          {"role": "system", "content": "You are a kitchen assistant."},12          {"role": "user", "content": prompt}]13    )14    return response.choices[0].message.content.strip()15 16def main():17    st.title("Recipe Generator")18    ingredients_input = st.text_input("Enter ingredients (comma-separated):")19 20    if st.button("Generate Recipe"):21        ingredients = ingredients_input.split(',')22        ingredients = [ingredient.strip() for ingredient in ingredients]23 24        if not ingredients:25            st.error("Please provide at least one ingredient.")26        else:27            recipe = generate_recipe(ingredients)28            st.subheader("Recipe:")29            st.write(recipe)30 31if __name__ == "__main__":32    main()33