Spaces:
Runtime error
Runtime error
import gradio as gr | |
import os | |
from indexes import create_indexes #,clear_indexes | |
from conversation import create_conversation | |
from dotenv import load_dotenv | |
load_dotenv() | |
openai_api_key=os.getenv('OPENAI_API_KEY') | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
collection_name = gr.components.Textbox( | |
label='Document name') | |
# pinecone_environment = gr.components.Textbox( | |
# label='Pinecone environment') | |
# pinecone_index_name = gr.components.Textbox( | |
# label='Pinecone index name') | |
# openai_api_key = gr.components.Textbox( | |
# label='Openai API key', type='password') | |
with gr.Row(): | |
with gr.Column(): | |
file = gr.components.File( | |
label='Upload your pdf file', | |
file_count='single', | |
file_types=['.pdf']) | |
with gr.Row(): | |
upload = gr.components.Button( | |
value='Upload', variant='primary') | |
label = gr.components.Textbox(label='Status of uploaded file') | |
chatbot = gr.Chatbot(label='Talk to the Document') | |
msg = gr.Textbox(label='Ask a question') | |
clear = gr.ClearButton([msg, chatbot]) | |
upload.click(create_indexes, [ | |
file,collection_name], [label]) | |
# index_clear_btn.click(clear_indexes, [ | |
# pinecone_api_key, pinecone_environment, pinecone_index_name], [label, file]) | |
msg.submit(create_conversation, [msg, chatbot, collection_name], [msg, chatbot]) | |
# def same_auth((username, password)): | |
# username: ('LawGPT0','') | |
# password: ('GPT089!') | |
# return username == password | |
#if __name__ == '__main__': | |
demo.launch(auth=[("admin", "pass1234"),("razzan", "rosli")]) | |