Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,8 @@ load_dotenv()
|
|
| 10 |
|
| 11 |
bot = None # Initially, no bot is created until the user logs in or registers
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
global bot
|
| 15 |
login_status = handle_login(userid, password, api_key_input)
|
| 16 |
|
|
@@ -28,6 +29,7 @@ def start_bot(userid, password, api_key_input=None):
|
|
| 28 |
gr.update(visible=False) # Keep chat section hidden
|
| 29 |
)
|
| 30 |
|
|
|
|
| 31 |
def answer(message, history):
|
| 32 |
answer_md, tables_display, images_display, retrieved_display = bot.get_answer(message)
|
| 33 |
|
|
@@ -40,7 +42,10 @@ def answer(message, history):
|
|
| 40 |
|
| 41 |
return combined_response
|
| 42 |
|
|
|
|
|
|
|
| 43 |
with gr.Blocks(fill_height=True, fill_width=True) as app:
|
|
|
|
| 44 |
with gr.Column(visible=True) as login_register_section:
|
| 45 |
gr.Markdown("# π MediBot Login & Registration")
|
| 46 |
with gr.Tabs():
|
|
@@ -52,7 +57,8 @@ with gr.Blocks(fill_height=True, fill_width=True) as app:
|
|
| 52 |
|
| 53 |
with gr.TabItem("Register"):
|
| 54 |
gr.Markdown("## π Enter Your Groq Cloud API Key")
|
| 55 |
-
gr.Markdown("You can create an API key at [Groq Cloud Console]
|
|
|
|
| 56 |
userid_register = gr.Textbox(label="UserID")
|
| 57 |
password_register = gr.Textbox(label="Password", type="password")
|
| 58 |
api_key_register = gr.Textbox(
|
|
@@ -61,17 +67,18 @@ with gr.Blocks(fill_height=True, fill_width=True) as app:
|
|
| 61 |
placeholder="sk-... (required)"
|
| 62 |
)
|
| 63 |
register_btn = gr.Button("Register")
|
| 64 |
-
register_output = gr.Textbox(label="Registration Status",
|
|
|
|
| 65 |
|
| 66 |
# Chat Section (Initially hidden)
|
| 67 |
with gr.Column(visible=False) as chat_section:
|
| 68 |
gr.ChatInterface(
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
# Function connections
|
| 77 |
login_btn.click(
|
|
@@ -86,4 +93,5 @@ with gr.Blocks(fill_height=True, fill_width=True) as app:
|
|
| 86 |
outputs=[register_output, login_register_section, chat_section]
|
| 87 |
)
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
| 10 |
|
| 11 |
bot = None # Initially, no bot is created until the user logs in or registers
|
| 12 |
|
| 13 |
+
|
| 14 |
+
def start_bot(userid, password, api_key_input):
|
| 15 |
global bot
|
| 16 |
login_status = handle_login(userid, password, api_key_input)
|
| 17 |
|
|
|
|
| 29 |
gr.update(visible=False) # Keep chat section hidden
|
| 30 |
)
|
| 31 |
|
| 32 |
+
|
| 33 |
def answer(message, history):
|
| 34 |
answer_md, tables_display, images_display, retrieved_display = bot.get_answer(message)
|
| 35 |
|
|
|
|
| 42 |
|
| 43 |
return combined_response
|
| 44 |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
with gr.Blocks(fill_height=True, fill_width=True) as app:
|
| 48 |
+
|
| 49 |
with gr.Column(visible=True) as login_register_section:
|
| 50 |
gr.Markdown("# π MediBot Login & Registration")
|
| 51 |
with gr.Tabs():
|
|
|
|
| 57 |
|
| 58 |
with gr.TabItem("Register"):
|
| 59 |
gr.Markdown("## π Enter Your Groq Cloud API Key")
|
| 60 |
+
gr.Markdown("You can create an API key at [Groq Cloud Console]"
|
| 61 |
+
"(https://console.groq.com/keys)")
|
| 62 |
userid_register = gr.Textbox(label="UserID")
|
| 63 |
password_register = gr.Textbox(label="Password", type="password")
|
| 64 |
api_key_register = gr.Textbox(
|
|
|
|
| 67 |
placeholder="sk-... (required)"
|
| 68 |
)
|
| 69 |
register_btn = gr.Button("Register")
|
| 70 |
+
register_output = gr.Textbox(label="Registration Status",
|
| 71 |
+
interactive=False)
|
| 72 |
|
| 73 |
# Chat Section (Initially hidden)
|
| 74 |
with gr.Column(visible=False) as chat_section:
|
| 75 |
gr.ChatInterface(
|
| 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(
|
|
|
|
| 93 |
outputs=[register_output, login_register_section, chat_section]
|
| 94 |
)
|
| 95 |
|
| 96 |
+
|
| 97 |
+
app.launch()
|