Chat / app.py
CosmoAI's picture
Update app.py
e67766f
raw
history blame
1.25 kB
import gradio as gr
import requests
import time
import os
import json
import google.generativeai as genai
genai.configure(
api_key=os.environ['API_KEY'])
model = genai.GenerativeModel(
model_name='gemini-pro')
def bardChat(data):
prompt = data
respo = model.generate_content(
prompt,
generation_config={
'temperature': 0,
'max_output_tokens': 100
}
)
return json.dumps(respo.text)
def responsenew(data):
return bardChat(data)
gradio_interface = gr.Interface(
fn = responsenew,
inputs = "text",
outputs = "text"
)
gradio_interface.launch()
# remind_val = ["create a reminder", "create reminder", "remind me"]
# if remind_val in data:
# return "Reminder created!"
# else:
# return bardChat(data)
# with gr.Blocks() as demo:
# chatbot = gr.Chatbot()
# msg = gr.Textbox()
# clear = gr.ClearButton([msg, chatbot])
# def respond(message, chat_history):
# bot_message = responsenew(message)
# chat_history.append((message, bot_message))
# time.sleep(2)
# return "", chat_history
# msg.submit(respond, [msg, chatbot], [msg, chatbot])
# if __name__ == "__main__":
# demo.launch()