Mo-alaa commited on
Commit
27c445c
·
1 Parent(s): e31c5ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -31
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
- if button_clicked:
 
 
 
 
 
 
29
 
30
- hub_llm = HuggingFaceHub(repo_id ="HuggingFaceH4/zephyr-7b-beta")
31
- prompt = PromptTemplate(
32
- input_variables = ['keyword'],
33
- template = """
34
- Write a comprehensive article about {keyword} covering the following aspects:
35
- Introduction, History and Background, Key Concepts and Terminology, Use Cases and Applications, Benefits and Drawbacks, Future Outlook, Conclusion
36
- Ensure that the article is well-structured, informative, and at least 1500 words long. Use SEO best practices for content optimization.
37
- """)
38
- hub_chain = LLMChain(prompt=prompt,llm = hub_llm,verbose=True)
39
 
40
- content = hub_chain.run(topic)
41
 
42
 
43
- subheadings = [
44
- "Introduction:",
45
- "History and Background:",
46
- "Key Concepts and Terminology:",
47
- "Use Cases and Applications:",
48
- "Benefits and Drawbacks:",
49
- "Future Outlook:",
50
- "Conclusion:",
51
- ]
52
- organized_content = ""
53
 
54
- for subheading in subheadings:
55
- if subheading in content:
56
- content = content.replace(subheading,"## "+subheading+"\n")
 
 
 
 
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