VarsaGupta commited on
Commit
ce3f299
·
verified ·
1 Parent(s): 3b3f005

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +54 -0
  2. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain.prompts import PromptTemplate
3
+ from langchain_community.llms import CTransformers
4
+
5
+ ## Function To get response from LLAMA 2 model
6
+ def getLLamaresponse(input_text,no_words,blog_style):
7
+
8
+ ### LLama2 model
9
+ llm=CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin',
10
+ model_type='llama',
11
+ config={'max_new_tokens':256,
12
+
13
+ 'temperature':0.01})
14
+
15
+ ## Prompt Template
16
+
17
+ template="""
18
+ Write a blog for {blog_style} job profile for a topic {input_text}
19
+ within {no_words} words.
20
+ """
21
+
22
+ prompt=PromptTemplate(input_variables=["blog_style","input_text",'no_words'],
23
+ template=template)
24
+
25
+ ## Generate the ressponse from the LLama 2 model
26
+ response = llm.invoke(prompt.format(blog_style=blog_style, input_text=input_text, no_words=no_words))
27
+
28
+ print(response)
29
+ return response
30
+
31
+ st.set_page_config(page_title="Generate Blogs",
32
+ page_icon='🤖',
33
+ layout='centered',
34
+ initial_sidebar_state='collapsed')
35
+
36
+ st.header("Generate Blogs 🤖")
37
+
38
+ input_text=st.text_input("Enter the Blog Topic")
39
+
40
+ ## creating to more columns for additonal 2 fields
41
+
42
+ col1,col2=st.columns([5,5])
43
+
44
+ with col1:
45
+ no_words=st.text_input('No of Words')
46
+ with col2:
47
+ blog_style=st.selectbox('Writing the blog for',
48
+ ('Researchers','Data Scientist','Common People'),index=0)
49
+
50
+ submit=st.button("Generate")
51
+
52
+ ## Final response
53
+ if submit:
54
+ st.write(getLLamaresponse(input_text,no_words,blog_style))
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ sentence-transformers
2
+ uvicorn
3
+ ctransformers
4
+ langchain
5
+ python-box
6
+ streamlit