import streamlit as st from langchain.prompts import PromptTemplate from langchain.llms import CTransformers from langchain import HuggingFaceHub import os import warnings warnings.filterwarnings('ignore') #streamlit run app.py def get_llama_response(inputtext,wordcount,blogstyle): ### LLama2 Model Calling.. # llm = CTransformers(model="model/llama-2-7b-chat.ggmlv3.q2_K.bin", # model_type='llama', # config={'max_new_tokens':256, # 'temperature':0.01}) template = f""" Write a Blog for {blogstyle} job profile for a topic {inputtext} within {wordcount} words. """ llm_hugg = HuggingFaceHub(repo_id="google/flan-t5-large",model_kwargs={'temperature':0.6, "max_length":64}) promptTemp = PromptTemplate(input_variables=['blogstyle','inputtext','wordcount'], template=template) response = llm_hugg(promptTemp.format(blogstyle=blogstyle,inputtext=inputtext,wordcount=wordcount)) return response st.set_page_config(page_title='Blog Generation',page_icon="🧊",layout="centered",initial_sidebar_state="collapsed") st.header("Generate Blogs") input_text = st.text_input("Enter the Blog Topic") col1,col2 = st.columns([5,5]) with col1: num_words = st.text_input("No Of Words") with col2: blog_style = st.selectbox("Writing the Blog For," ,("Researchers","Data Scientist","Common People"),index=0) submit =st.button("Generate") if submit: st.subheader("The Response is:") st.write(get_llama_response(input_text,num_words,blog_style))