import streamlit as st from ctransformers import AutoModelForCausalLM llm = AutoModelForCausalLM.from_pretrained("TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF") # Streamlit UI st.set_page_config(page_title="GenBlog Demo", page_icon="📚", layout="centered", initial_sidebar_state='collapsed') st.header("GenBlog Demo 📚") st.subheader('This is a demo of the GenBlog assistant', divider='rainbow') st.write("Enter a blog topic and the blog style to generate a blog post.") st.write(f"Based on the TinyLlama 🦙 model.") st.divider() input_text=st.text_input("Enter the Blog Topic") blog_style=st.selectbox("Select the Blog Style", ["Personal", "Casual", "Proffesional"]) submit=st.button("Generate Blog Post") st.divider() response_field = st.empty() if submit: prompt = f""" As a professional writer skilled in {blog_style.lower()} style, your task is to create an engaging and informative blog post about '{input_text}'. Begin with a captivating title that reflects the essence of the topic. Follow with an introduction that sets the stage for the discussion. Please ensure the main body delves into the details of the topic, providing insight, analysis, and relevant examples that illuminate the subject for the readers. Conclude with a summary that reinforces the main points and offers a call to action or a thought-provoking question to engage the readers further. The post should be well-structured, clearly written, and reflecting a professional tone suitable for an audience interested in {blog_style.lower()} topics. """ st.write_stream(llm(prompt, stream=True, max_new_tokens=400, temperature=0.5))