Cooking_Receips / app.py
tahirsher's picture
Create app.py
81c21da verified
raw
history blame
1.06 kB
import streamlit as st
from llama_cpp import Llama
# Initialize the Llama model
llm = Llama.from_pretrained(
repo_id="RichardErkhov/mrm8488_-_gpt2-finetuned-recipes-cooking-gguf",
filename="gpt2-finetuned-recipes-cooking.IQ3_M.gguf",
)
def generate_recipe(dish_name):
# Create a prompt with the user's favorite dish
messages = [
{
"role": "user",
"content": f"Provide a step-by-step recipe for {dish_name}."
}
]
# Get the recipe from the model
response = llm.create_chat_completion(messages=messages)
return response['choices'][0]['message']['content']
# Streamlit app
st.title("Cooking Recipe Generator")
# Input for favorite dish
dish_name = st.text_input("Enter your favorite dish")
# Button to generate the recipe
if st.button("Generate Recipe"):
if dish_name:
with st.spinner("Generating recipe..."):
recipe = generate_recipe(dish_name)
st.subheader("Recipe:")
st.write(recipe)
else:
st.error("Please enter a dish name.")