Spaces:
Build error
Build error
| 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() |