pasupuletkarthiksai commited on
Commit
5891550
Β·
verified Β·
1 Parent(s): 1f4e1a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
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
- def start_bot(userid, password, api_key_input=None):
 
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](https://console.groq.com/keys)")
 
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", interactive=False)
 
65
 
66
  # Chat Section (Initially hidden)
67
  with gr.Column(visible=False) as chat_section:
68
  gr.ChatInterface(
69
- answer,
70
- title="🩺 Medico-Bot",
71
- examples=["briefly explain me about cancer", "types of skin diseases?"],
72
- flagging_options=['Like', 'Dislike'],
73
- chatbot=gr.Chatbot(type="messages") # Use new messages format
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
- app.launch(server_name="0.0.0.0", server_port=7860)
 
 
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()