import streamlit as st from langchain.prompts import PromptTemplate from langchain_community.llms import CTransformers import time # List of blog styles BLOG_STYLES = [ 'Researchers', 'Data Scientist', 'Common People', 'Software Engineers', 'Product Managers', 'Healthcare Professionals', 'Teachers', 'Entrepreneurs', 'Marketers', 'Students' ] # Function to get response from LLama 2 model def getLLamaResponse(input_text, no_words, blog_style): # Initialize the LLama 2 model llm = CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin', model_type='llama', config={'max_new_tokens': 256, 'temperature': 0.01}) # Define the prompt template template = """ Write a blog for {blog_style} job profile for a topic {input_text} within {no_words} words. """ prompt = PromptTemplate(input_variables=["blog_style", "input_text", 'no_words'], template=template) # Generate the response from the LLama 2 model response = llm(prompt.format(blog_style=blog_style, input_text=input_text, no_words=no_words)) return response # Function to generate topics from LLama 2 model def generate_topics_from_llama(input_text): # Initialize the LLama 2 model llm = CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin', model_type='llama', config={'max_new_tokens': 256, 'temperature': 0.01}) # Define the prompt template for generating topics topic_template = """ Generate a list of blog topics based on the keywords: {input_text} """ prompt = PromptTemplate(input_variables=["input_text"], template=topic_template) # Generate the topics from the LLama 2 model topics_response = llm(prompt.format(input_text=input_text)) # Split the response into a list of topics topics = topics_response.split('\n') return [topic.strip() for topic in topics if topic.strip()] # Set up the Streamlit page configuration st.set_page_config(page_title="LLAMA 2 Generate Blogs", page_icon='images/favicon.ico', # Updated favicon source layout='centered', initial_sidebar_state='collapsed') # Display image using st.image #st.image('images/ConcertIDC_Logo_Stack.png', width=50, caption='') # Page header with favicon icon st.markdown( """