Spaces:
Build error
Build error
| import gradio as gr | |
| import os | |
| from chat import RetrievalChatbot | |
| api_key = os.environ["OPENAI_API_KEY"] | |
| api_base = os.environ["OPENAI_API_BASE"] | |
| pdf_dir = "papers_all" | |
| model_name = "gpt-4-1106-preview" | |
| RetrievalChatbot = RetrievalChatbot(api_key, api_base, pdf_dir, 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() |