File size: 1,490 Bytes
cfd509f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
import gradio as gr
from ingest import configure_retriever
from chain import my_chain

def chatbot(input_text, history,uploaded_file):
    
    if uploaded_file is not None:
        ret=configure_retriever(uploaded_files=uploaded_file)
    else:
        ret =configure_retriever("")
    
    response =my_chain(ret,input_text)

    return response

demo = gr.ChatInterface(chatbot, 
                        additional_inputs=[
                            gr.File(file_types=["pdf", "csv"], file_count="multiple")
                        ],
                        title="RAG chain built using Langchain",
                        description="Upload your documents in the additional input section and enjoy",
                       )

demo.launch()

# import gradio as gr
# from ingest import configure_retriever
# from chain import my_chain

# def chatbot(input_text, uploaded_file):
#     # Your chatbot logic here
    
#     print("checkpoint1")
#     if uploaded_file is not None:
#         # Process the uploaded file (you can replace this with your own logic)
#         ret=configure_retriever(uploaded_files=uploaded_file)
    
#     response =my_chain(ret,input_text)

#     return response

# iface = gr.Interface(
#     fn=chatbot,
#     inputs=[
#         gr.Textbox(placeholder="Enter your text here"),
#         gr.UploadButton("Click to Upload a File", file_types=["pdf", "csv"], file_count="multiple")
#     ],
#     outputs=gr.Textbox(label="Response")
# )

# iface.launch()