File size: 1,379 Bytes
bf7287c
 
 
 
 
59b1384
 
 
bf7287c
 
 
 
 
9c24a51
bf7287c
ebe2a01
bf7287c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from langchain.prompts import PromptTemplate
from langchain.llms import CTransformers
from langchain import HuggingFaceHub
import os
from dotenv import load_dotenv

load_dotenv()

import warnings
warnings.filterwarnings('ignore')
#streamlit run app.py 
def get_llama_response(inputtext,wordcount,blogstyle):

    template = f"""
    Write a Blog as a {blogstyle} on {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))