testspace / app.py
kalpapathiraja's picture
Update app.py
94a8ec6 verified
import gradio as gr
import google.generativeai as genai
genai.configure(api_key="AIzaSyCY2Zx8eqRSW_V0uSAFw_4Ii6F3cNb13D8")
model = genai.GenerativeModel('gemini-pro')
def process(text1):
response = model.generate_content(text1)
return response.text
def happy_tone(text2):
response = model.generate_content(text2+" write it in a happy tone")
return response.text
def sad_tone(text2):
response = model.generate_content(text2+" write it in a sad tone")
return response.text
def excited_tone(text2):
response = model.generate_content(text2+" write it in a excited tone")
return response.text
with gr.Blocks() as demo:
with gr.Row():
with gr.Column(scale=1, min_width=600):
text1 = gr.Textbox(label="Input Text")
process_btn = gr.Button("Process")
text2 = gr.Textbox(label="prompt",interactive=False)
process_btn.click(fn=process, inputs=text1, outputs=text2, api_name="process")
with gr.Row():
happy_btn = gr.Button("Happy")
sad_btn = gr.Button("Sad")
excited_btn = gr.Button("Excited")
text5 = gr.Textbox(label="prompt After Tone",interactive=False)
happy_btn.click(fn=happy_tone, inputs=text2, outputs=text5, api_name="happy_tone")
sad_btn.click(fn=sad_tone, inputs=text2, outputs=text5, api_name="sad_tone")
excited_btn.click(fn=excited_tone, inputs=text2, outputs=text5, api_name="excited_tone")
demo.launch()