Jacek Zadrożny commited on
Commit
787b7ff
·
1 Parent(s): 77bf306

Add detailed logging and fix read-only filesystem issues

Browse files

- Add verbose logging to agent creation process
- Fix VectorStoreClient to handle read-only filesystem
- Fix EmbeddingsClient cache creation with proper error handling
- Only create directories if they don't exist and we have write permissions
- Better traceback logging for database connection errors

agent/__pycache__/a11y_agent.cpython-312.pyc CHANGED
Binary files a/agent/__pycache__/a11y_agent.cpython-312.pyc and b/agent/__pycache__/a11y_agent.cpython-312.pyc differ
 
agent/a11y_agent.py CHANGED
@@ -175,22 +175,27 @@ def create_agent(language: Optional[str] = None) -> A11yExpertAgent:
175
  """Factory function to create and initialize agent."""
176
  language = language or "en"
177
 
 
178
  settings = get_settings()
179
 
180
- # Create vector store with lazy connection
 
181
  vector_store = VectorStoreClient(uri=settings.lancedb_uri)
182
 
183
  api_key = settings.openai_api_key
184
 
 
185
  client_args = {"api_key": api_key}
186
  if settings.llm_base_url:
187
  client_args["base_url"] = settings.llm_base_url
188
 
189
  llm_client = OpenAI(**client_args)
190
 
 
191
  agent = A11yExpertAgent(
192
  vector_store=vector_store,
193
  llm_client=llm_client,
194
  language=language
195
  )
 
196
  return agent
 
175
  """Factory function to create and initialize agent."""
176
  language = language or "en"
177
 
178
+ logger.info(f"Creating agent with language: {language}")
179
  settings = get_settings()
180
 
181
+ # Create vector store with lazy connection (no DB access yet)
182
+ logger.info("Initializing vector store client...")
183
  vector_store = VectorStoreClient(uri=settings.lancedb_uri)
184
 
185
  api_key = settings.openai_api_key
186
 
187
+ logger.info("Initializing OpenAI client...")
188
  client_args = {"api_key": api_key}
189
  if settings.llm_base_url:
190
  client_args["base_url"] = settings.llm_base_url
191
 
192
  llm_client = OpenAI(**client_args)
193
 
194
+ logger.info("Creating A11yExpertAgent instance...")
195
  agent = A11yExpertAgent(
196
  vector_store=vector_store,
197
  llm_client=llm_client,
198
  language=language
199
  )
200
+ logger.info("Agent creation complete")
201
  return agent
database/__pycache__/vector_store_client.cpython-312.pyc CHANGED
Binary files a/database/__pycache__/vector_store_client.cpython-312.pyc and b/database/__pycache__/vector_store_client.cpython-312.pyc differ
 
database/vector_store_client.py CHANGED
@@ -60,16 +60,21 @@ class VectorStoreClient:
60
  import os
61
  logger.info(f"Connecting to LanceDB at: {self.uri}")
62
 
63
- try:
64
- os.makedirs(self.uri, exist_ok=True)
65
- except Exception as e:
66
- logger.warning(f"Could not create directory {self.uri}: {e}")
 
 
 
67
 
68
  try:
69
  self._db = lancedb.connect(self.uri)
70
- logger.info("✅ Connected to LanceDB")
71
  except Exception as e:
72
  logger.error(f"Failed to connect to LanceDB: {e}")
 
 
73
  raise
74
  return self._db
75
 
 
60
  import os
61
  logger.info(f"Connecting to LanceDB at: {self.uri}")
62
 
63
+ # Only try to create directory if it doesn't exist and we can write
64
+ if not os.path.exists(self.uri):
65
+ try:
66
+ os.makedirs(self.uri, exist_ok=True)
67
+ logger.debug(f"Created directory: {self.uri}")
68
+ except (OSError, PermissionError) as e:
69
+ logger.warning(f"Could not create directory (read-only filesystem?): {e}")
70
 
71
  try:
72
  self._db = lancedb.connect(self.uri)
73
+ logger.info("✅ Connected to LanceDB (read-only mode)")
74
  except Exception as e:
75
  logger.error(f"Failed to connect to LanceDB: {e}")
76
+ import traceback
77
+ logger.error(traceback.format_exc())
78
  raise
79
  return self._db
80
 
models/__pycache__/embeddings.cpython-312.pyc CHANGED
Binary files a/models/__pycache__/embeddings.cpython-312.pyc and b/models/__pycache__/embeddings.cpython-312.pyc differ
 
models/embeddings.py CHANGED
@@ -68,8 +68,15 @@ class EmbeddingsClient:
68
 
69
  # Initialize cache if available
70
  if CACHE_AVAILABLE:
71
- self.cache = Cache(cache_dir)
72
- logger.info(f"✅ EmbeddingsClient initialized (model: {self.model}, cache: enabled)")
 
 
 
 
 
 
 
73
  else:
74
  self.cache = None
75
  logger.info(f"✅ EmbeddingsClient initialized (model: {self.model}, cache: disabled)")
 
68
 
69
  # Initialize cache if available
70
  if CACHE_AVAILABLE:
71
+ try:
72
+ import os
73
+ os.makedirs(cache_dir, exist_ok=True)
74
+ self.cache = Cache(cache_dir)
75
+ logger.info(f"✅ EmbeddingsClient initialized (model: {self.model}, cache: enabled)")
76
+ except (OSError, PermissionError) as e:
77
+ logger.warning(f"Could not create cache directory (read-only?): {e}")
78
+ self.cache = None
79
+ logger.info(f"✅ EmbeddingsClient initialized (model: {self.model}, cache: disabled)")
80
  else:
81
  self.cache = None
82
  logger.info(f"✅ EmbeddingsClient initialized (model: {self.model}, cache: disabled)")