Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +33 -0
- models/llama-2-7b-chat.ggmlv3.q8_0.bin +3 -0
- requirements.txt +6 -0
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain.prompts import PromptTemplate
|
| 3 |
+
from langchain.llms import CTransformers
|
| 4 |
+
|
| 5 |
+
def get_blog_response(blog_context,blog_length,style):
|
| 6 |
+
llm = CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin',
|
| 7 |
+
model_type='llama',
|
| 8 |
+
config={'max_new_tokens':256,
|
| 9 |
+
'temperature':0.01})
|
| 10 |
+
template = """write a blog for {style} job profile for a topic {text} within {n_words} words."""
|
| 11 |
+
prompt = PromptTemplate(input_variables=['style','text','n_words'],template=template)
|
| 12 |
+
response = llm(prompt.format(style=style,text=blog_context,n_words=blog_length))
|
| 13 |
+
return response
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
st.set_page_config(page_title="Generate blogs",
|
| 18 |
+
page_icon = "X",
|
| 19 |
+
layout='centered',
|
| 20 |
+
initial_sidebar_state = 'collapsed')
|
| 21 |
+
|
| 22 |
+
st.header("Generate blogs")
|
| 23 |
+
input_text = st.text_input("Enter the blog topic")
|
| 24 |
+
col1,col2 = st.columns([5,5])
|
| 25 |
+
|
| 26 |
+
with col1:
|
| 27 |
+
no_words = st.text_input('No of words')
|
| 28 |
+
with col2:
|
| 29 |
+
blog_style = st.selectbox('writing the blog for',('Researchers','Data Scientist','Common People'),index=0)
|
| 30 |
+
submit = st.button("Generate")
|
| 31 |
+
|
| 32 |
+
if submit:
|
| 33 |
+
st.write(get_blog_response(input_text,no_words,blog_style))
|
models/llama-2-7b-chat.ggmlv3.q8_0.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3bfdde943555c78294626a6ccd40184162d066d39774bd2c98dae24943d32cc3
|
| 3 |
+
size 7160799872
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sentence-transformers
|
| 2 |
+
uvicorn
|
| 3 |
+
ctransformers
|
| 4 |
+
langchain
|
| 5 |
+
python-box
|
| 6 |
+
streamlit
|