pinecone / app.py
abhishek kumar
Add application file
13fab0d
raw
history blame
986 Bytes
import gradio as gr
from indexes import clear_indexes
from conversation import create_conversation
# Hardcoded values
HARDCODED_PINECONE_API_KEY = '228cca47-e537-42af-bcef-569cb18fb7cf'
HARDCODED_PINECONE_ENVIRONMENT = 'us-west1-gcp-free'
HARDCODED_PINECONE_INDEX_NAME = 'chatbot'
HARDCODED_OPENAI_API_KEY = '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'
def update_chat_history(query, chatbot_state):
current_chat_history = chatbot_state if chatbot_state else []
_, updated_chat_history = create_conversation(query, current_chat_history)
return "", updated_chat_history # Return an empty string to clear the textbox
with gr.Blocks() as demo:
chatbot = gr.Chatbot(label='Talk to the Document')
msg = gr.Textbox()
clear = gr.ClearButton([msg, chatbot])
# Link the Gradio interface with the update_chat_history function
msg.submit(update_chat_history, inputs=[msg, chatbot], outputs=[msg, chatbot])
if __name__ == '__main__':
demo.launch()