udayr commited on
Commit
573bb9d
·
verified ·
1 Parent(s): ddf2513

Delete app.py

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