Jeremy Live commited on
Commit
8a155b4
·
1 Parent(s): a1d301f

I've fixed the agent initialization issue

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -251,17 +251,26 @@ logger.info("="*50)
251
  logger.info("Starting application initialization...")
252
  logger.info(f"Python version: {sys.version}")
253
  logger.info(f"Current working directory: {os.getcwd()}")
254
- logger.info(f"Files in working directory: {os.listdir('.')}")
255
 
256
- # Check environment variables
257
  logger.info("Checking environment variables...")
258
- required_vars = ["DB_USER", "DB_HOST", "DB_NAME", "GOOGLE_API_KEY"]
259
- for var in required_vars:
260
  logger.info(f"{var}: {'*' * 8 if os.getenv(var) else 'NOT SET'}")
261
 
262
- # Initialize agent
 
 
 
 
 
 
 
 
 
 
263
  logger.info("Initializing agent...")
264
- agent, agent_error = create_agent()
265
  db_connected = agent is not None
266
 
267
  if agent:
 
251
  logger.info("Starting application initialization...")
252
  logger.info(f"Python version: {sys.version}")
253
  logger.info(f"Current working directory: {os.getcwd()}")
254
+ logger.info(f"Files in working directory: {os.listdir()}")
255
 
256
+ # Verificar las variables de entorno
257
  logger.info("Checking environment variables...")
258
+ for var in ["DB_USER", "DB_PASSWORD", "DB_HOST", "DB_NAME", "GOOGLE_API_KEY"]:
 
259
  logger.info(f"{var}: {'*' * 8 if os.getenv(var) else 'NOT SET'}")
260
 
261
+ # Initialize components
262
+ logger.info("Initializing database connection...")
263
+ db_connection, db_error = setup_database_connection()
264
+ if db_error:
265
+ logger.error(f"Failed to initialize database: {db_error}")
266
+
267
+ logger.info("Initializing language model...")
268
+ llm, llm_error = initialize_llm()
269
+ if llm_error:
270
+ logger.error(f"Failed to initialize language model: {llm_error}")
271
+
272
  logger.info("Initializing agent...")
273
+ agent, agent_error = create_agent(llm, db_connection)
274
  db_connected = agent is not None
275
 
276
  if agent: