Spaces:
Sleeping
Sleeping
from langchain.chains import LLMChain | |
from langchain.llms import HuggingFaceHub | |
from langchain.prompts import PromptTemplate | |
import streamlit as st | |
HUGGINGFACEHUB_API_TOKEN = st.secrets("HUGGINGFACEHUB_API_TOKEN") | |
topic = st.text_input("Enter Topic for the bog") | |
hub_llm = HuggingFaceHub(repo_id ="HuggingFaceH4/zephyr-7b-beta") | |
prompt = PromptTemplate( | |
input_variables = ['keyword'], | |
template = """ | |
Write a comprehensive article about {keyword} covering the following aspects: | |
Introduction, History and Background, Key Concepts and Terminology, Use Cases and Applications, Benefits and Drawbacks, Future Outlook, Conclusion | |
Ensure that the article is well-structured, informative, and at least 1500 words long. Use SEO best practices for content optimization. | |
""") | |
button_clicked = st.button("Create blog!") | |
if button_clicked: | |
hub_chain = LLMChain(prompt=prompt,llm = hub_llm,verbose=True) | |
content = hub_chain.run(topic) | |
subheadings = [ | |
"Introduction:", | |
"History and Background:", | |
"Key Concepts and Terminology:", | |
"Use Cases and Applications:", | |
"Benefits and Drawbacks:", | |
"Future Outlook:", | |
"Conclusion:" | |
] | |
organized_content = "" | |
for subheading in subheadings: | |
if subheading in content: | |
content = content.replace(subheading,"## "+subheading+"\n") | |
st.markdown(content) |