File size: 2,105 Bytes
6bf29c8
 
 
 
 
33bd8df
6bf29c8
 
 
089b91a
6bf29c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51


from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.llms import HuggingFaceEndpoint
import streamlit as st

# prepare Falcon Huggingface API
llm = HuggingFaceEndpoint(
            endpoint_url= f"https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta",
            huggingfacehub_api_token='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',
            task="text-generation",
            model_kwargs = {
                "min_length": 8192,
                "max_length":8192,
                "temperature":0.1,
                "max_new_tokens":4000,
                "num_return_sequences":1
            }
        )


topics_template = PromptTemplate(
    input_variables = ['keyword'],
    template = """
    I want you to Write a comprehensive article about "{keyword}" covering the following aspects:

    Introduction: Provide an engaging introduction to the topic, highlighting its relevance and significance.
    History and Background: Explain the historical context and background of {keyword}.
    Key Concepts and Terminology: Define important terms and concepts related to {keyword}.
    Current State of {keyword}: Discuss the current trends, developments, and challenges in the field of {keyword}.
    Use Cases and Applications: Explore practical applications and use cases of {keyword} in various industries.
    Benefits and Drawbacks: Highlight the advantages and disadvantages of {keyword}.
    Future Outlook: Predict the future trends and potential advancements in {keyword}.
    Conclusion: Summarize the key points and reiterate the importance of {keyword}.

    Ensure that the article is well-structured, informative, and at least 1500 words long. Use SEO best practices for content optimization.
    """)


st.title("Blog Writer")
keyword = st.text_input("Input the keyword you wish to write about")

topic_writing_chain = LLMChain(llm= llm, prompt=topics_template, verbose = True)


with st.spinner('Wait for it...'):
    if keyword:
        topics = topic_writing_chain(keyword)
        st.write(topics)
    st.success('')