karthiksagarn commited on
Commit
8a752b2
β€’
1 Parent(s): 6caf972

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +46 -0
  2. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain.llms import CTransformers
3
+ from langchain.prompts import PromptTemplate
4
+
5
+
6
+ ## Function to get response form the LLama2 Model
7
+ def getLLamaResponse(input_text, no_of_words, blog_style):
8
+ llm = CTransformers(model='/Users/karthiksagar/BlogGeneration/llama-2-7b-chat.bin',
9
+ model_type='llama',
10
+ config={"max_new_tokens": 256,
11
+ 'temperature': 0.01})
12
+ template = """
13
+ write a blog for {blog_style} job profile for a topic {input_text}
14
+ within {no_of_words} words.
15
+ """
16
+ prompt = PromptTemplate(input_variables=["blog_style", "input_text", "no_of_words"],
17
+ template=template)
18
+ response = llm(prompt.format(blog_style=blog_style, input_text=input_text, no_of_words=no_of_words))
19
+ st.write(response)
20
+ return response
21
+
22
+
23
+ st.set_page_config(page_title= "Generate Blogs",
24
+ page_icon="πŸ€–",
25
+ layout='centered',
26
+ initial_sidebar_state="collapsed")
27
+
28
+ st.header("Generate Blogs πŸ€–")
29
+
30
+ input_text = st.text_input("Enter the Blog Topic")
31
+
32
+ ## creating two columns for additional two fields
33
+
34
+ col1, col2 = st.columns([5,5])
35
+
36
+ with col1:
37
+ no_of_words = st.text_input("Enter the No. of words")
38
+ with col2:
39
+ blog_style = st.selectbox("writing the blog for",
40
+ ('Researchers', 'Data Scientists', 'ML Engineers', 'Common People'),
41
+ index=0)
42
+ submit = st.button("Generate")
43
+
44
+ #final respponse
45
+ if submit:
46
+ st.write(getLLamaResponse(input_text, no_of_words, blog_style))
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ sentence-transformers
2
+ uvicorn
3
+ streamlit
4
+ langchain
5
+ ctransformers
6
+ python-box
7
+ ipykernel