AashitaK commited on
Commit
f3f49bc
·
verified ·
1 Parent(s): 89cb69d

Update utils/chatbot_interface3.py

Browse files
Files changed (1) hide show
  1. utils/chatbot_interface3.py +5 -12
utils/chatbot_interface3.py CHANGED
@@ -32,8 +32,6 @@ class ChatbotInterface:
32
  self.input_label = self.config["chatbot_input_label"]
33
  self.input_placeholder = self.config["chatbot_input_placeholder"]
34
  self.output_label = self.config["chatbot_output_label"]
35
- self.reset_button = self.config["chatbot_reset_button"]
36
- self.submit_button = self.config["chatbot_submit_button"]
37
 
38
  # Initialize ResponseManager with custom parameters
39
  try:
@@ -46,21 +44,19 @@ class ChatbotInterface:
46
  api_key=api_key,
47
  meta_prompt_file=meta_prompt_file
48
  )
 
49
  logging.info(
50
  "ChatbotInterface initialized with the following parameters:\n"
51
  f" - Model: {model}\n"
52
  f" - Temperature: {temperature}\n"
53
  f" - Max Output Tokens: {max_output_tokens}\n"
54
  f" - Max Number of Results: {max_num_results}\n"
55
- f" - Vector Store ID: {vector_store_id}\n"
56
- f" - API Key: {'Provided' if api_key else 'Not Provided'}\n"
57
- f" - Meta Prompt File: {meta_prompt_file or 'Default'}"
58
  )
 
59
  except Exception as e:
60
  logging.error(f"Failed to initialize ResponseManager: {e}")
61
  raise
62
-
63
-
64
  @staticmethod
65
  def load_config(config_path: str) -> dict:
66
  """
@@ -81,6 +77,7 @@ class ChatbotInterface:
81
  "chatbot_input_placeholder", "chatbot_output_label",
82
  "chatbot_reset_button", "chatbot_submit_button"
83
  ]
 
84
  for key in required_keys:
85
  if key not in config:
86
  logging.error(f"Missing required configuration key: {key}")
@@ -89,8 +86,7 @@ class ChatbotInterface:
89
  logging.info("Configuration loaded successfully.")
90
  return config
91
 
92
-
93
-
94
  def create_interface(self) -> gr.Blocks:
95
  """
96
  Create the Gradio Blocks interface that displays a single container including both
@@ -99,7 +95,6 @@ class ChatbotInterface:
99
  """
100
  logging.info("Creating Gradio interface...")
101
 
102
-
103
  with gr.Blocks() as demo:
104
  # Title and description area.
105
  gr.Markdown(f"## {self.title}\n{self.description}")
@@ -139,7 +134,6 @@ class ChatbotInterface:
139
  """
140
  updated_history = self.response_manager.generate_response(user_message, chat_history)
141
  return updated_history, ""
142
-
143
 
144
  # Bind the reset button click to the reset function
145
  reset.click(
@@ -148,7 +142,6 @@ class ChatbotInterface:
148
  outputs=[chatbot_output, user_input]
149
  )
150
 
151
-
152
  # Bind the Enter key (textbox submit) to the same processing function
153
  user_input.submit(
154
  fn=process_input,
 
32
  self.input_label = self.config["chatbot_input_label"]
33
  self.input_placeholder = self.config["chatbot_input_placeholder"]
34
  self.output_label = self.config["chatbot_output_label"]
 
 
35
 
36
  # Initialize ResponseManager with custom parameters
37
  try:
 
44
  api_key=api_key,
45
  meta_prompt_file=meta_prompt_file
46
  )
47
+
48
  logging.info(
49
  "ChatbotInterface initialized with the following parameters:\n"
50
  f" - Model: {model}\n"
51
  f" - Temperature: {temperature}\n"
52
  f" - Max Output Tokens: {max_output_tokens}\n"
53
  f" - Max Number of Results: {max_num_results}\n"
 
 
 
54
  )
55
+
56
  except Exception as e:
57
  logging.error(f"Failed to initialize ResponseManager: {e}")
58
  raise
59
+
 
60
  @staticmethod
61
  def load_config(config_path: str) -> dict:
62
  """
 
77
  "chatbot_input_placeholder", "chatbot_output_label",
78
  "chatbot_reset_button", "chatbot_submit_button"
79
  ]
80
+
81
  for key in required_keys:
82
  if key not in config:
83
  logging.error(f"Missing required configuration key: {key}")
 
86
  logging.info("Configuration loaded successfully.")
87
  return config
88
 
89
+
 
90
  def create_interface(self) -> gr.Blocks:
91
  """
92
  Create the Gradio Blocks interface that displays a single container including both
 
95
  """
96
  logging.info("Creating Gradio interface...")
97
 
 
98
  with gr.Blocks() as demo:
99
  # Title and description area.
100
  gr.Markdown(f"## {self.title}\n{self.description}")
 
134
  """
135
  updated_history = self.response_manager.generate_response(user_message, chat_history)
136
  return updated_history, ""
 
137
 
138
  # Bind the reset button click to the reset function
139
  reset.click(
 
142
  outputs=[chatbot_output, user_input]
143
  )
144
 
 
145
  # Bind the Enter key (textbox submit) to the same processing function
146
  user_input.submit(
147
  fn=process_input,