File size: 827 Bytes
899cd11
 
 
 
 
 
 
623992f
 
899cd11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a029187
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
import gradio as gr
import random
import time
import os

from chat import RetrievalChatbot

api_key = os.environ["OPENAI_API_KEY"]
#api_key = 'sk-api-NTwb26YCf5prxxfEXP0GT3BlbkFJMyqibpALZQBxqxks1uQ0'
print(api_key)
api_base=''#os.environ["OPENAI_API_BASE"]
pdf_dir = "D:\\BaiduNetdiskDownload\\papers_all"
model_name="gpt-4-1106-preview"

RetrievalChatbot = RetrievalChatbot(api_key, api_base,model_name)

with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.ClearButton([msg, chatbot])

    def respond(message, chat_history):
        bot_message = RetrievalChatbot.get_response(chat_history, message)
        chat_history.append((message, bot_message))
        return "", chat_history

    msg.submit(respond, [msg, chatbot], [msg, chatbot])

if __name__ == "__main__":
    demo.launch()