Balaji commited on
Commit
9fd4070
·
1 Parent(s): 92569f4

Upload 2 files

Browse files
blog_generating_ai.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,no_words,blog_style):
8
+
9
+ ### LLama2 model
10
+ llm=CTransformers(model='llama-2-7b-chat.ggmlv3.q2_K.bin',
11
+ model_type='llama',
12
+ config={'max_new_tokens':256,
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(prompt.format(blog_style=blog_style,input_text=input_text,no_words=no_words))
27
+ print(response)
28
+ return response
29
+
30
+
31
+
32
+
33
+ st.set_page_config(page_title="Generate Blogs",
34
+ page_icon='🤖',
35
+ layout='centered',
36
+ initial_sidebar_state='collapsed')
37
+
38
+ st.header("Generate Blogs 🤖")
39
+
40
+ input_text=st.text_input("Enter the Blog Topic")
41
+
42
+ ## creating to more columns for additonal 2 fields
43
+
44
+ col1,col2=st.columns([5,5])
45
+
46
+ with col1:
47
+ no_words=st.text_input('No of Words')
48
+ with col2:
49
+ blog_style=st.selectbox('Writing the blog for',
50
+ ('Researchers','Data Scientist','Common People'),index=0)
51
+
52
+ submit=st.button("Generate")
53
+
54
+ ## Final response
55
+ if submit:
56
+ st.write(getLLamaresponse(input_text,no_words,blog_style))
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