Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from llama_cpp import Llama
|
3 |
+
|
4 |
+
# Initialize the Llama model
|
5 |
+
llm = Llama.from_pretrained(
|
6 |
+
repo_id="RichardErkhov/mrm8488_-_gpt2-finetuned-recipes-cooking-gguf",
|
7 |
+
filename="gpt2-finetuned-recipes-cooking.IQ3_M.gguf",
|
8 |
+
)
|
9 |
+
|
10 |
+
def generate_recipe(dish_name):
|
11 |
+
# Create a prompt with the user's favorite dish
|
12 |
+
messages = [
|
13 |
+
{
|
14 |
+
"role": "user",
|
15 |
+
"content": f"Provide a step-by-step recipe for {dish_name}."
|
16 |
+
}
|
17 |
+
]
|
18 |
+
# Get the recipe from the model
|
19 |
+
response = llm.create_chat_completion(messages=messages)
|
20 |
+
return response['choices'][0]['message']['content']
|
21 |
+
|
22 |
+
# Streamlit app
|
23 |
+
st.title("Cooking Recipe Generator")
|
24 |
+
|
25 |
+
# Input for favorite dish
|
26 |
+
dish_name = st.text_input("Enter your favorite dish")
|
27 |
+
|
28 |
+
# Button to generate the recipe
|
29 |
+
if st.button("Generate Recipe"):
|
30 |
+
if dish_name:
|
31 |
+
with st.spinner("Generating recipe..."):
|
32 |
+
recipe = generate_recipe(dish_name)
|
33 |
+
st.subheader("Recipe:")
|
34 |
+
st.write(recipe)
|
35 |
+
else:
|
36 |
+
st.error("Please enter a dish name.")
|