Spaces:
Sleeping
Sleeping
prompt changes
Browse files
README.md
CHANGED
@@ -9,8 +9,12 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
# Blogger
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
# The Blogger π
|
13 |
|
14 |
+
[The Blogger π - Playground](https://huggingface.co/spaces/thivav/llama2-blogger)
|
15 |
|
16 |
+
This application generates an article based on your query and gener.
|
17 |
+
|
18 |
+
- For **The Blogger** following technologies were used:
|
19 |
+
- **llama2** with **langchain** used to generate the blog.
|
20 |
+
- [The TheBloke/Llama-2-7B-Chat-GGML llama2 model used](https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML)
|
app.py
CHANGED
@@ -20,7 +20,6 @@ def load_model():
|
|
20 |
|
21 |
|
22 |
# request for blog content
|
23 |
-
@st.cache_data
|
24 |
def generate_blog(query, word_count, genre):
|
25 |
"""generate blog"""
|
26 |
|
@@ -28,11 +27,7 @@ def generate_blog(query, word_count, genre):
|
|
28 |
As a you a blogger, please write a blog for the topic {query} and under gener {genre}.
|
29 |
Please write the blog in {word_count} words.
|
30 |
Your blog strictly should be in markdown language.
|
31 |
-
Also, come with an appropriate title for the blog and set it at the top in bold letters.
|
32 |
-
|
33 |
-
Example:
|
34 |
-
## **YOUR TITLE**
|
35 |
-
YOUR BLOG COME HERE
|
36 |
"""
|
37 |
|
38 |
prompt = PromptTemplate(
|
@@ -46,42 +41,57 @@ def generate_blog(query, word_count, genre):
|
|
46 |
return response
|
47 |
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
page_icon="π",
|
52 |
-
layout="centered",
|
53 |
-
initial_sidebar_state="collapsed",
|
54 |
-
)
|
55 |
|
56 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
no_of_words = st.selectbox(
|
63 |
-
"Number of words", ("200", "250", "300", "350", "400", "500")
|
64 |
-
)
|
65 |
-
with col_2:
|
66 |
-
blog_genres = st.selectbox(
|
67 |
-
"Genre of the blog",
|
68 |
-
(
|
69 |
-
"Business",
|
70 |
-
"Food",
|
71 |
-
"Music",
|
72 |
-
"Fitness",
|
73 |
-
"Travel",
|
74 |
-
"Gaming",
|
75 |
-
"Finance",
|
76 |
-
"Sports",
|
77 |
-
"Movie",
|
78 |
-
"Science & Technology",
|
79 |
-
"Lifestyle",
|
80 |
-
),
|
81 |
-
index=0,
|
82 |
)
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
# request for blog content
|
|
|
23 |
def generate_blog(query, word_count, genre):
|
24 |
"""generate blog"""
|
25 |
|
|
|
27 |
As a you a blogger, please write a blog for the topic {query} and under gener {genre}.
|
28 |
Please write the blog in {word_count} words.
|
29 |
Your blog strictly should be in markdown language.
|
30 |
+
Also, come with an appropriate title for the blog and set it at the top in bold letters.
|
|
|
|
|
|
|
|
|
31 |
"""
|
32 |
|
33 |
prompt = PromptTemplate(
|
|
|
41 |
return response
|
42 |
|
43 |
|
44 |
+
def main():
|
45 |
+
"main"
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
st.set_page_config(
|
48 |
+
page_title="The Blogger",
|
49 |
+
page_icon="π",
|
50 |
+
layout="centered",
|
51 |
+
initial_sidebar_state="collapsed",
|
52 |
+
)
|
53 |
|
54 |
+
st.header("The Blogger π", divider="rainbow")
|
55 |
|
56 |
+
st.subheader(
|
57 |
+
"This application generates an :red[article] based on your :green[topic] and :blue[gener]. :sunglasses:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
)
|
59 |
|
60 |
+
st.markdown("[check out the repository](https://github.com/ThivaV/llama2_blogger)")
|
61 |
+
|
62 |
+
user_input = st.text_input("Enter the topic you wanted the blog")
|
63 |
+
|
64 |
+
col_1, col_2 = st.columns([5, 5])
|
65 |
+
with col_1:
|
66 |
+
no_of_words = st.selectbox(
|
67 |
+
"Number of words", ("200", "250", "300", "350", "400", "500")
|
68 |
+
)
|
69 |
+
with col_2:
|
70 |
+
blog_genres = st.selectbox(
|
71 |
+
"Genre of the blog",
|
72 |
+
(
|
73 |
+
"Science & Technology",
|
74 |
+
"Business",
|
75 |
+
"Food",
|
76 |
+
"Music",
|
77 |
+
"Fitness",
|
78 |
+
"Travel",
|
79 |
+
"Gaming",
|
80 |
+
"Finance",
|
81 |
+
"Sports",
|
82 |
+
"Movie",
|
83 |
+
"Lifestyle",
|
84 |
+
),
|
85 |
+
index=0,
|
86 |
+
)
|
87 |
+
|
88 |
+
submit = st.button("Start Blogging")
|
89 |
+
if submit:
|
90 |
+
with st.spinner("Blogging started, Please wait.."):
|
91 |
+
blog = generate_blog(user_input, no_of_words, blog_genres)
|
92 |
+
st.write(blog)
|
93 |
+
st.success("Done!")
|
94 |
+
|
95 |
+
|
96 |
+
if __name__ == "__main__":
|
97 |
+
main()
|