hruday96 commited on
Commit
c182e4e
1 Parent(s): 0572c4c

Create prod-desc-app.py

Browse files
Files changed (1) hide show
  1. prod-desc-app.py +43 -0
prod-desc-app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Set up the LLaMA 3.2 model (using Hugging Face pipeline)
5
+ @st.cache_resource
6
+ def load_llama_model():
7
+ return pipeline('text-generation', model='meta-llama/Llama-2-7b-hf')
8
+
9
+ # Load the model
10
+ llama_generator = load_llama_model()
11
+
12
+ # Streamlit app layout
13
+ st.title('Personalized Product Description Writer')
14
+
15
+ # Input fields for the product details
16
+ st.subheader("Enter Product Details:")
17
+ product_name = st.text_input('Product Name', '')
18
+ product_features = st.text_area('Product Features (comma separated)', '')
19
+ target_audience = st.text_input('Target Audience', '')
20
+
21
+ # Button to trigger the description generation
22
+ if st.button('Generate Description'):
23
+ if product_name and product_features and target_audience:
24
+ # Construct the prompt for the LLaMA model
25
+ prompt = (f"Write a product description for a product called '{product_name}' targeting {target_audience}. "
26
+ f"Features include: {product_features}.")
27
+
28
+ # Generate the description using LLaMA 3.2 model
29
+ description = llama_generator(prompt, max_length=100, num_return_sequences=1)[0]['generated_text']
30
+
31
+ # Display the generated description
32
+ st.subheader("Generated Product Description:")
33
+ st.write(description)
34
+ else:
35
+ st.warning("Please fill in all the fields.")
36
+
37
+ # Additional optional features
38
+ st.sidebar.subheader("Customize Description")
39
+ length = st.sidebar.slider('Max Length', 50, 200, 100)
40
+
41
+ # Footer
42
+ st.sidebar.markdown("---")
43
+ st.sidebar.markdown("Built with 🧠 by Hruday & Ollama")