File size: 1,726 Bytes
df262b6
71c240e
 
df262b6
71c240e
 
 
 
df262b6
 
 
71c240e
 
 
 
 
 
 
 
df262b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71c240e
 
 
 
 
 
 
 
 
df262b6
71c240e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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")])