Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from langchain.prompts import PromptTemplate
|
3 |
-
from langchain.llms import CTransformers
|
4 |
-
|
5 |
-
## Function To get response from LLAma 2 model
|
6 |
-
|
7 |
-
def getLLamaresponse(input_text,keywords,blog_style):
|
8 |
-
|
9 |
-
### LLama2 model
|
10 |
-
llm=CTransformers(model="models
|
11 |
-
model_type='llama',
|
12 |
-
config={'max_new_tokens':50,
|
13 |
-
'temperature':0.01})
|
14 |
-
|
15 |
-
## Prompt Template
|
16 |
-
|
17 |
-
template="""
|
18 |
-
Generate sql command for {blog_style} {input_text} {keywords}.
|
19 |
-
"""
|
20 |
-
|
21 |
-
prompt=PromptTemplate(input_variables=["blog_style","input_text",'keywords'],
|
22 |
-
template=template)
|
23 |
-
|
24 |
-
## Generate the ressponse from the LLama 2 model
|
25 |
-
response=llm(prompt.format(blog_style=blog_style,input_text=input_text,keywords=keywords))
|
26 |
-
print(response)
|
27 |
-
return response
|
28 |
-
|
29 |
-
st.set_page_config(page_title="Generate Project Idea",
|
30 |
-
page_icon='🤖',
|
31 |
-
layout='centered',
|
32 |
-
initial_sidebar_state='collapsed')
|
33 |
-
|
34 |
-
st.header("Generate Project Idea 🤖")
|
35 |
-
|
36 |
-
input_text=st.text_input("Enter the Topic")
|
37 |
-
|
38 |
-
|
39 |
-
## creating to more columns for additonal 2 fields
|
40 |
-
|
41 |
-
col1,col2=st.columns([5,5])
|
42 |
-
|
43 |
-
with col1:
|
44 |
-
no_words=st.text_input('Keywords')
|
45 |
-
with col2:
|
46 |
-
blog_style=st.selectbox('Generating project idea for',
|
47 |
-
('Researchers','Data Scientist','Software Developer','Common People', " "),index=0)
|
48 |
-
|
49 |
-
submit=st.button("Generate")
|
50 |
-
|
51 |
-
## Final response
|
52 |
-
if submit:
|
53 |
st.write(getLLamaresponse(input_text,no_words,blog_style))
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain.prompts import PromptTemplate
|
3 |
+
from langchain.llms import CTransformers
|
4 |
+
|
5 |
+
## Function To get response from LLAma 2 model
|
6 |
+
|
7 |
+
def getLLamaresponse(input_text,keywords,blog_style):
|
8 |
+
|
9 |
+
### LLama2 model
|
10 |
+
llm=CTransformers(model="models/llama-2-7b-chat.ggmlv3.q2_K.bin",
|
11 |
+
model_type='llama',
|
12 |
+
config={'max_new_tokens':50,
|
13 |
+
'temperature':0.01})
|
14 |
+
|
15 |
+
## Prompt Template
|
16 |
+
|
17 |
+
template="""
|
18 |
+
Generate sql command for {blog_style} {input_text} {keywords}.
|
19 |
+
"""
|
20 |
+
|
21 |
+
prompt=PromptTemplate(input_variables=["blog_style","input_text",'keywords'],
|
22 |
+
template=template)
|
23 |
+
|
24 |
+
## Generate the ressponse from the LLama 2 model
|
25 |
+
response=llm(prompt.format(blog_style=blog_style,input_text=input_text,keywords=keywords))
|
26 |
+
print(response)
|
27 |
+
return response
|
28 |
+
|
29 |
+
st.set_page_config(page_title="Generate Project Idea",
|
30 |
+
page_icon='🤖',
|
31 |
+
layout='centered',
|
32 |
+
initial_sidebar_state='collapsed')
|
33 |
+
|
34 |
+
st.header("Generate Project Idea 🤖")
|
35 |
+
|
36 |
+
input_text=st.text_input("Enter the Topic")
|
37 |
+
|
38 |
+
|
39 |
+
## creating to more columns for additonal 2 fields
|
40 |
+
|
41 |
+
col1,col2=st.columns([5,5])
|
42 |
+
|
43 |
+
with col1:
|
44 |
+
no_words=st.text_input('Keywords')
|
45 |
+
with col2:
|
46 |
+
blog_style=st.selectbox('Generating project idea for',
|
47 |
+
('Researchers','Data Scientist','Software Developer','Common People', " "),index=0)
|
48 |
+
|
49 |
+
submit=st.button("Generate")
|
50 |
+
|
51 |
+
## Final response
|
52 |
+
if submit:
|
53 |
st.write(getLLamaresponse(input_text,no_words,blog_style))
|