Skip to content

Instantly share code, notes, and snippets.

@rohitrajiit
Created December 15, 2023 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohitrajiit/6f8fac9fc33d096bc9b153115dc54d7f to your computer and use it in GitHub Desktop.
Save rohitrajiit/6f8fac9fc33d096bc9b153115dc54d7f to your computer and use it in GitHub Desktop.
import gradio as gr
import google.generativeai as genai
apikey = 'xxx' # Replace with your key
genai.configure(api_key=apikey)
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.ClearButton([msg, chatbot])
model = genai.GenerativeModel('gemini-pro')
chat = model.start_chat(history=[])
def respond(message, chat_history):
response = chat.send_message(message)
responsetext = response.text
chat_history.append((message, responsetext))
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
demo.launch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment