Spaces:
Sleeping
Sleeping
Gayatrikh16
commited on
Upload 3 files
Browse files- app.py +53 -0
- models/llama-2-7b-chat.ggmlv3.q2_K.bin +3 -0
- requirements.txt +7 -0
app.py
ADDED
@@ -0,0 +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\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))
|
models/llama-2-7b-chat.ggmlv3.q2_K.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:45833e0b59c8fe80676c664f556031fc411da8856e0716ac7b8ed201b7221c08
|
3 |
+
size 2866807424
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
sentence-transformers
|
2 |
+
uvicorn
|
3 |
+
ctransformers
|
4 |
+
langchain
|
5 |
+
python-box
|
6 |
+
streamlit
|
7 |
+
langchain-community
|