Blaiseboy commited on
Commit
e2a0045
·
verified ·
1 Parent(s): d43fd86

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -56
app.py DELETED
@@ -1,56 +0,0 @@
1
-
2
- import gradio as gr
3
- import os
4
- from medical_chatbot import ColabBioGPTChatbot
5
-
6
- # Instantiate the chatbot
7
- chatbot = ColabBioGPTChatbot(use_gpu=True, use_8bit=True)
8
-
9
- medical_file_uploaded = False
10
-
11
- def upload_and_initialize(file):
12
- try:
13
- chatbot.load_medical_file(file.name)
14
- return "✅ Medical file uploaded and chatbot initialized!", gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
15
- except Exception as e:
16
- return f"❌ Error: {str(e)}", gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
17
-
18
-
19
- def generate_response(user_input):
20
- if not medical_file_uploaded:
21
- return "⚠️ Please upload and initialize medical data first."
22
- return chatbot.chat(user_input)
23
-
24
- with gr.Blocks() as demo:
25
- gr.Markdown("## 🩺 Pediatric Medical Assistant\nUpload a medical .txt file and start chatting.")
26
-
27
- with gr.Row():
28
- file_input = gr.File(label="📁 Upload Medical File", file_types=[".txt"])
29
- upload_btn = gr.Button("📤 Upload and Initialize")
30
-
31
- upload_output = gr.Textbox(label="System Status", interactive=False)
32
-
33
- chatbot_ui = gr.Chatbot(label="🧠 Chat History")
34
- user_input = gr.Textbox(placeholder="Ask a pediatric health question...", lines=2, show_label=False)
35
- submit_btn = gr.Button("Send")
36
-
37
- chatbot_ui.visible = False
38
- user_input.visible = False
39
- submit_btn.visible = False
40
-
41
- upload_btn.click(
42
- fn=upload_and_initialize,
43
- inputs=[file_input],
44
- outputs=[upload_output, chatbot_ui, user_input, submit_btn]
45
- )
46
-
47
- def on_submit(user_message, chat_history):
48
- bot_response = generate_response(user_message)
49
- chat_history.append((user_message, bot_response))
50
- return "", chat_history
51
-
52
- user_input.submit(fn=on_submit, inputs=[user_input, chatbot_ui], outputs=[user_input, chatbot_ui])
53
- submit_btn.click(fn=on_submit, inputs=[user_input, chatbot_ui], outputs=[user_input, chatbot_ui])
54
-
55
- demo.launch(share=True)
56
-