|
50 | 50 | SHOW_DEBUG_LOGS, |
51 | 51 | ) |
52 | 52 | from .logger.logger import UILogHandler |
53 | | -from .llm.client import create_llm, ollama_model_exists, ollama_pull_model |
54 | 53 | from .llm.worker import LLMWorker |
55 | | -from langchain_core.messages import AIMessage |
56 | 54 | from .prompts.system import GENERAL_SYSTEM_PROMPT |
57 | 55 | from .utils.canvas_refresh import ( |
58 | 56 | RefreshDispatcher, |
@@ -374,14 +372,15 @@ def _ensure_dependencies_installed(self): |
374 | 372 | data = tomllib.loads(content) |
375 | 373 | deps = data.get("project", {}).get("dependencies", []) or [] |
376 | 374 | except Exception: |
377 | | - m = re.search(r"dependencies\s*=\s*\[(.*?)\]", content, re.S) |
| 375 | + m = re.search(r"dependencies\s*=\s*\[(.*)\]", content, re.DOTALL) |
378 | 376 | if m: |
379 | 377 | raw = m.group(1) |
380 | 378 | for line in raw.splitlines(): |
381 | 379 | line = line.strip().strip(",") |
382 | 380 | if not line: |
383 | 381 | continue |
384 | | - if line.startswith('"') and line.endswith('"'): |
| 382 | + # handle both single and double quoted strings |
| 383 | + if (line.startswith('"') and line.endswith('"')) or (line.startswith("'") and line.endswith("'")): |
385 | 384 | deps.append(line[1:-1]) |
386 | 385 | except Exception: |
387 | 386 | deps = [] |
@@ -946,6 +945,14 @@ def _initialize_agent( |
946 | 945 | max_tokens: Maximum tokens for response |
947 | 946 | mode: Either 'general' or 'processing' |
948 | 947 | """ |
| 948 | + try: |
| 949 | + from .llm.client import create_llm, ollama_model_exists, ollama_pull_model |
| 950 | + except Exception as e: |
| 951 | + self._log_error("_initialize_agent", e) |
| 952 | + raise RuntimeError( |
| 953 | + "Failed to import LLM client module. Ensure dependencies are installed." |
| 954 | + ) from e |
| 955 | + |
949 | 956 | try: |
950 | 957 | if model_name not in SUPPORTED_MODELS: |
951 | 958 | raise ValueError(f"Unsupported model: {model_name}") |
|
0 commit comments