Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import os
|
2 |
import gradio as gr
|
3 |
from src.auth.auth import handle_login
|
4 |
from src.auth.db import initialize_db
|
@@ -9,8 +8,6 @@ from src.interface import Interface
|
|
9 |
initialize_db()
|
10 |
load_dotenv()
|
11 |
|
12 |
-
os.getenv("OPENAI_API_KEY")
|
13 |
-
|
14 |
bot = None # Initially, no bot is created until the user logs in or registers
|
15 |
|
16 |
|
@@ -34,22 +31,17 @@ def start_bot(userid, password, api_key_input):
|
|
34 |
|
35 |
|
36 |
def answer(message, history):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
combined_response
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
combined_response += "\n\n" + "\n\n".join(images_display)
|
49 |
-
|
50 |
-
return combined_response
|
51 |
-
except Exception as e:
|
52 |
-
return f"An error occurred: {e}"
|
53 |
|
54 |
|
55 |
with gr.Blocks(fill_height=True, fill_width=True) as app:
|
@@ -84,14 +76,14 @@ with gr.Blocks(fill_height=True, fill_width=True) as app:
|
|
84 |
answer,
|
85 |
title="🩺 Medico-Bot",
|
86 |
examples=["briefly explain me about cancer", "types of skin diseases?"],
|
87 |
-
flagging_options = ['Like', 'Dislike']
|
88 |
)
|
89 |
|
90 |
|
91 |
# Function connections
|
92 |
login_btn.click(
|
93 |
start_bot,
|
94 |
-
inputs=[userid_login, password_login
|
95 |
outputs=[login_output, login_register_section, chat_section]
|
96 |
)
|
97 |
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from src.auth.auth import handle_login
|
3 |
from src.auth.db import initialize_db
|
|
|
8 |
initialize_db()
|
9 |
load_dotenv()
|
10 |
|
|
|
|
|
11 |
bot = None # Initially, no bot is created until the user logs in or registers
|
12 |
|
13 |
|
|
|
31 |
|
32 |
|
33 |
def answer(message, history):
|
34 |
+
answer_md, tables_display, images_display, retrieved_display = bot.get_answer(message)
|
35 |
+
|
36 |
+
# Combine all parts into a single response string for chat
|
37 |
+
combined_response = f"{answer_md}\n\n{tables_display}"
|
38 |
+
|
39 |
+
# Add images as markdown
|
40 |
+
if images_display:
|
41 |
+
combined_response += "\n\n" + "\n\n".join(images_display)
|
42 |
+
|
43 |
+
return combined_response
|
44 |
+
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
with gr.Blocks(fill_height=True, fill_width=True) as app:
|
|
|
76 |
answer,
|
77 |
title="🩺 Medico-Bot",
|
78 |
examples=["briefly explain me about cancer", "types of skin diseases?"],
|
79 |
+
flagging_options = ['Like', 'Dislike']
|
80 |
)
|
81 |
|
82 |
|
83 |
# Function connections
|
84 |
login_btn.click(
|
85 |
start_bot,
|
86 |
+
inputs=[userid_login, password_login],
|
87 |
outputs=[login_output, login_register_section, chat_section]
|
88 |
)
|
89 |
|