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('')