arahrooh commited on
Commit
237ee8e
·
1 Parent(s): 0d730d5

Fix AttributeError: use bot.args.model instead of bot.current_model

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -175,6 +175,7 @@ class InferenceAPIBot:
175
  self.bot = bot # Use bot for vector DB and formatting
176
  self.client = InferenceClient(api_key=hf_token)
177
  self.current_model = bot.args.model
 
178
  logger.info(f"InferenceAPIBot initialized with model: {self.current_model}")
179
 
180
  def generate_answer(self, prompt: str, **kwargs) -> str:
@@ -311,7 +312,11 @@ class GradioRAGInterface:
311
  self.bot = initial_bot
312
  self.use_inference_api = False
313
 
314
- self.current_model = self.bot.current_model
 
 
 
 
315
  self.data_dir = initial_bot.args.data_dir
316
  logger.info("GradioRAGInterface initialized")
317
 
@@ -850,6 +855,8 @@ def create_demo_for_spaces():
850
  # We still need the vector database
851
  # Set a flag to skip model loading
852
  args.skip_model_loading = True
 
 
853
  bot = RAGBot(args)
854
 
855
  # Don't load the model - we'll use Inference API
 
175
  self.bot = bot # Use bot for vector DB and formatting
176
  self.client = InferenceClient(api_key=hf_token)
177
  self.current_model = bot.args.model
178
+ self.args = bot.args # Expose args for compatibility
179
  logger.info(f"InferenceAPIBot initialized with model: {self.current_model}")
180
 
181
  def generate_answer(self, prompt: str, **kwargs) -> str:
 
312
  self.bot = initial_bot
313
  self.use_inference_api = False
314
 
315
+ # Get current model from bot args (not a direct attribute)
316
+ self.current_model = self.bot.args.model if hasattr(self.bot, 'args') else getattr(self.bot, 'current_model', None)
317
+ if self.current_model is None and hasattr(self.bot, 'bot'):
318
+ # If using InferenceAPIBot, get from the wrapped bot
319
+ self.current_model = self.bot.bot.args.model
320
  self.data_dir = initial_bot.args.data_dir
321
  logger.info("GradioRAGInterface initialized")
322
 
 
855
  # We still need the vector database
856
  # Set a flag to skip model loading
857
  args.skip_model_loading = True
858
+
859
+ # Create bot - it will skip model loading due to the flag
860
  bot = RAGBot(args)
861
 
862
  # Don't load the model - we'll use Inference API