Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,40 +25,43 @@ button_clicked = st.button("Create blog!")
|
|
25 |
existing_ideas = load_ideas()
|
26 |
st.sidebar.header("Previous Ideas:")
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
existing_ideas.append({topic:content})
|
59 |
-
keys = [key for idea in existing_ideas for key in idea.keys()]
|
60 |
-
save_ideas(existing_ideas)
|
61 |
-
selected_idea = st.sidebar.selectbox("Select Idea", keys, key="selectbox")
|
62 |
-
selected_idea_from_list = next((idea for idea in existing_ideas if selected_key in idea), None)
|
63 |
-
selected_idea_from_list[selected_idea]
|
64 |
-
st.markdown(selected_idea_from_list[selected_idea])
|
|
|
25 |
existing_ideas = load_ideas()
|
26 |
st.sidebar.header("Previous Ideas:")
|
27 |
|
28 |
+
while(True):
|
29 |
+
if topic:
|
30 |
+
keys = [key for idea in existing_ideas for key in idea.keys()]
|
31 |
+
selected_idea = st.sidebar.selectbox("Select Idea", keys, key="selectbox")
|
32 |
+
selected_idea_from_list = next((idea for idea in existing_ideas if selected_idea in idea), None)
|
33 |
+
st.markdown(selected_idea_from_list[selected_idea])
|
34 |
+
if button_clicked:
|
35 |
|
36 |
+
hub_llm = HuggingFaceHub(repo_id ="HuggingFaceH4/zephyr-7b-beta")
|
37 |
+
prompt = PromptTemplate(
|
38 |
+
input_variables = ['keyword'],
|
39 |
+
template = """
|
40 |
+
Write a comprehensive article about {keyword} covering the following aspects:
|
41 |
+
Introduction, History and Background, Key Concepts and Terminology, Use Cases and Applications, Benefits and Drawbacks, Future Outlook, Conclusion
|
42 |
+
Ensure that the article is well-structured, informative, and at least 1500 words long. Use SEO best practices for content optimization.
|
43 |
+
""")
|
44 |
+
hub_chain = LLMChain(prompt=prompt,llm = hub_llm,verbose=True)
|
45 |
|
46 |
+
content = hub_chain.run(topic)
|
47 |
|
48 |
|
49 |
+
subheadings = [
|
50 |
+
"Introduction:",
|
51 |
+
"History and Background:",
|
52 |
+
"Key Concepts and Terminology:",
|
53 |
+
"Use Cases and Applications:",
|
54 |
+
"Benefits and Drawbacks:",
|
55 |
+
"Future Outlook:",
|
56 |
+
"Conclusion:",
|
57 |
+
]
|
58 |
+
organized_content = ""
|
59 |
|
60 |
+
for subheading in subheadings:
|
61 |
+
if subheading in content:
|
62 |
+
content = content.replace(subheading,"## "+subheading+"\n")
|
63 |
+
|
64 |
+
existing_ideas.append({topic:content})
|
65 |
+
keys = [key for idea in existing_ideas for key in idea.keys()]
|
66 |
+
save_ideas(existing_ideas)
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|