File size: 1,404 Bytes
f5a396a
 
 
ac462f6
2bd2884
 
f5a396a
 
 
 
 
 
 
 
 
2bd2884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)