Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,24 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
from transformers import AutoTokenizer
|
7 |
-
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained('mistralai/mathstral-7B-v0.1')
|
9 |
-
|
10 |
-
|
11 |
-
def getLLamaresponse(input_text, keywords, blog_style):
|
12 |
-
# Load the LLaMA 2 model from Hugging Face
|
13 |
-
model_name = MistralForCausalLM.from_pretrained('mistralai/mathstral-7B-v0.1')
|
14 |
-
#llm = pipeline('text-generation', model=model_name)
|
15 |
|
|
|
|
|
16 |
# Prompt Template
|
17 |
template = """
|
18 |
-
|
19 |
"""
|
20 |
-
|
21 |
-
# Format the prompt
|
22 |
prompt = template.format(blog_style=blog_style, input_text=input_text, keywords=keywords)
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
response = model.generate(prompt, max_length=250, temperature=0.01)
|
26 |
-
return response[0]['generated_text']
|
27 |
-
|
28 |
st.set_page_config(page_title="Generate Project Idea",
|
29 |
page_icon='🤖',
|
30 |
layout='centered',
|
@@ -38,14 +32,14 @@ input_text = st.text_input("Enter the Topic")
|
|
38 |
col1, col2 = st.columns([5, 5])
|
39 |
|
40 |
with col1:
|
41 |
-
|
42 |
with col2:
|
43 |
blog_style = st.selectbox('Generating project idea for',
|
44 |
-
('Researchers', 'Data Scientist', 'Software Developer', 'Common People'
|
45 |
-
|
46 |
submit = st.button("Generate")
|
47 |
|
48 |
# Final response
|
49 |
if submit:
|
50 |
-
response =
|
51 |
st.write(response)
|
|
|
1 |
import streamlit as st
|
2 |
+
from langchain.prompts import PromptTemplate
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
# Initialize the Hugging Face pipeline
|
6 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
# Function to get response from the model
|
9 |
+
def get_response(input_text, keywords, blog_style):
|
10 |
# Prompt Template
|
11 |
template = """
|
12 |
+
Generate technical project ideas for {blog_style} job profile for a topic {input_text} using these keywords: {keywords}.
|
13 |
"""
|
14 |
+
|
|
|
15 |
prompt = template.format(blog_style=blog_style, input_text=input_text, keywords=keywords)
|
16 |
+
|
17 |
+
# Generate the response from the model
|
18 |
+
response = pipe(prompt)
|
19 |
+
return response[0]['generated_text'] # Extract the generated text
|
20 |
|
21 |
+
# Streamlit configuration
|
|
|
|
|
|
|
22 |
st.set_page_config(page_title="Generate Project Idea",
|
23 |
page_icon='🤖',
|
24 |
layout='centered',
|
|
|
32 |
col1, col2 = st.columns([5, 5])
|
33 |
|
34 |
with col1:
|
35 |
+
keywords = st.text_input('Keywords')
|
36 |
with col2:
|
37 |
blog_style = st.selectbox('Generating project idea for',
|
38 |
+
('Researchers', 'Data Scientist', 'Software Developer', 'Common People'), index=0)
|
39 |
+
|
40 |
submit = st.button("Generate")
|
41 |
|
42 |
# Final response
|
43 |
if submit:
|
44 |
+
response = get_response(input_text, keywords, blog_style)
|
45 |
st.write(response)
|