Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# Load the Gemma-7b text-generation pipeline
|
5 |
+
generator = pipeline("text-generation", model="google/gemma-7b")
|
6 |
+
|
7 |
+
st.title("Project Prompt Generator")
|
8 |
+
|
9 |
+
# User input fields
|
10 |
+
topic = st.text_input("Enter a project topic:")
|
11 |
+
keywords = st.multiselect("Choose relevant keywords:", ["sustainability", "data analysis", "education", "technology"], default=[])
|
12 |
+
|
13 |
+
# Generate prompts button
|
14 |
+
if st.button("Generate Prompts"):
|
15 |
+
prompts = generate_prompts(topic, keywords)
|
16 |
+
|
17 |
+
# Display generated prompts
|
18 |
+
st.subheader("Generated Prompts:")
|
19 |
+
for prompt in prompts:
|
20 |
+
st.write(f"* {prompt}")
|
21 |
+
|
22 |
+
# Function to generate project prompts
|
23 |
+
def generate_prompts(topic, keywords):
|
24 |
+
"""
|
25 |
+
Generates project prompts based on user input.
|
26 |
+
|
27 |
+
Args:
|
28 |
+
topic: The main theme or area of the project.
|
29 |
+
keywords: A list of relevant keywords chosen by the user.
|
30 |
+
|
31 |
+
Returns:
|
32 |
+
A list of generated project prompts.
|
33 |
+
"""
|
34 |
+
prompts = []
|
35 |
+
for _ in range(3): # Generate 3 prompts
|
36 |
+
prompt = generator(
|
37 |
+
prompt=f"Generate a project prompt related to {topic} using the keywords {', '.join(keywords)}.",
|
38 |
+
max_length=150,
|
39 |
+
num_return_sequences=1
|
40 |
+
)[0]["generated_text"]
|
41 |
+
prompts.append(prompt)
|
42 |
+
return prompts
|
43 |
+
|
44 |
+
# Run the app
|
45 |
+
if __name__ == "__main__":
|
46 |
+
st.run()
|