Mo-alaa commited on
Commit
2bd2884
·
1 Parent(s): 278ff47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -3
app.py CHANGED
@@ -2,7 +2,8 @@ from langchain.chains import LLMChain
2
  from langchain.llms import HuggingFaceHub
3
  from langchain.prompts import PromptTemplate
4
  import streamlit as st
5
- import os
 
6
  topic = st.text_input("Enter Topic for the bog")
7
  hub_llm = HuggingFaceHub(repo_id ="HuggingFaceH4/zephyr-7b-beta")
8
  prompt = PromptTemplate(
@@ -12,5 +13,28 @@ prompt = PromptTemplate(
12
  Introduction, History and Background, Key Concepts and Terminology, Use Cases and Applications, Benefits and Drawbacks, Future Outlook, Conclusion
13
  Ensure that the article is well-structured, informative, and at least 1500 words long. Use SEO best practices for content optimization.
14
  """)
15
- hub_chain = LLMChain(prompt=prompt,llm = hub_llm,verbose=True)
16
- st.write(hub_chain.run(topic))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from langchain.llms import HuggingFaceHub
3
  from langchain.prompts import PromptTemplate
4
  import streamlit as st
5
+ HUGGINGFACEHUB_API_TOKEN = st.secrets("HUGGINGFACEHUB_API_TOKEN")
6
+
7
  topic = st.text_input("Enter Topic for the bog")
8
  hub_llm = HuggingFaceHub(repo_id ="HuggingFaceH4/zephyr-7b-beta")
9
  prompt = PromptTemplate(
 
13
  Introduction, History and Background, Key Concepts and Terminology, Use Cases and Applications, Benefits and Drawbacks, Future Outlook, Conclusion
14
  Ensure that the article is well-structured, informative, and at least 1500 words long. Use SEO best practices for content optimization.
15
  """)
16
+
17
+ button_clicked = st.button("Create blog!")
18
+ if button_clicked:
19
+ hub_chain = LLMChain(prompt=prompt,llm = hub_llm,verbose=True)
20
+
21
+ content = hub_chain.run(topic)
22
+
23
+
24
+ subheadings = [
25
+ "Introduction:",
26
+ "History and Background:",
27
+ "Key Concepts and Terminology:",
28
+ "Use Cases and Applications:",
29
+ "Benefits and Drawbacks:",
30
+ "Future Outlook:",
31
+ "Conclusion:"
32
+ ]
33
+ organized_content = ""
34
+
35
+ for subheading in subheadings:
36
+ if subheading in content:
37
+ content = content.replace(subheading,"## "+subheading+"\n")
38
+
39
+
40
+ st.markdown(content)