ARBAJSSHAIKH commited on
Commit
7d95b88
·
verified ·
1 Parent(s): d508529

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain.prompts import PromptTemplate
3
+ from langchain_community.llms import CTransformers
4
+
5
+
6
+ def GetLLMResponse(input_text,no_words,blog_type):
7
+ llm=CTransformers(model="models\llama-2-7b-chat.ggmlv3.q8_0.bin",
8
+ model_type='llama',
9
+ config={'max_new_tokens':200,
10
+ 'temperature':0.01})
11
+
12
+ template=" wtite a blog for {blog_type} on topic of {input_text} in {no_words} words."
13
+
14
+ prompt=PromptTemplate(input_variables=['blog_type','input_text','no_words'],template=template)
15
+
16
+ response=llm(prompt.format(blog_type=blog_type,input_text=input_text,no_words=no_words))
17
+ return response
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ st.set_page_config(page_title="Generative AI Blog",
28
+ layout="centered",
29
+ initial_sidebar_state='collapsed')
30
+ st.header("Blog Generater")
31
+
32
+ input_text=st.text_input('ENTER THE TOPIC')
33
+
34
+ col1,col2=st.columns([5,5])
35
+
36
+ with col1:
37
+ no_words=st.text_input("ENTER THE NUMBER OF WORDS")
38
+
39
+ with col2:
40
+ blog_type=st.selectbox("SELECT BLOG FOR",('SCIENTIST','TEACHER','STUDENT'))
41
+
42
+ submit=st.button("GENERATE")
43
+
44
+ if submit:
45
+ st.write(GetLLMResponse(input_text,no_words,blog_type))