mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
Feat: support local provider for code exec component & remove some outdated models (#14637)
### What problem does this PR solve? Feat: support local provider for code exec component & remove some outdated models ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -357,6 +357,7 @@ class CodeExec(ToolBase, ABC):
|
||||
# Try using the new sandbox provider system first
|
||||
try:
|
||||
from agent.sandbox.client import execute_code as sandbox_execute_code
|
||||
from agent.sandbox.providers.base import SandboxProviderConfigError
|
||||
|
||||
if self.check_if_canceled("CodeExec execution"):
|
||||
return
|
||||
@@ -376,8 +377,16 @@ class CodeExec(ToolBase, ABC):
|
||||
execution_metadata=result.metadata,
|
||||
)
|
||||
|
||||
except (ImportError, RuntimeError) as provider_error:
|
||||
# Provider system not available or not configured, fall back to HTTP
|
||||
except SandboxProviderConfigError as provider_error:
|
||||
self.set_output("_ERROR", str(provider_error))
|
||||
return self.output()
|
||||
except ImportError as provider_error:
|
||||
# Provider modules are unavailable, fall back to legacy HTTP sandbox.
|
||||
logging.info(f"[CodeExec]: Provider system not available, using HTTP fallback: {provider_error}")
|
||||
except RuntimeError as provider_error:
|
||||
if not self._should_fallback_to_http(provider_error):
|
||||
self.set_output("_ERROR", f"Provider system execution failed: {provider_error}")
|
||||
return self.output()
|
||||
logging.info(f"[CodeExec]: Provider system not available, using HTTP fallback: {provider_error}")
|
||||
|
||||
# Fallback to direct HTTP request
|
||||
@@ -487,6 +496,15 @@ class CodeExec(ToolBase, ABC):
|
||||
return metadata.get("result_value"), False
|
||||
return self._deserialize_stdout(stdout), True
|
||||
|
||||
@staticmethod
|
||||
def _should_fallback_to_http(provider_error: RuntimeError) -> bool:
|
||||
message = str(provider_error).lower()
|
||||
fallback_markers = (
|
||||
"no sandbox provider configured",
|
||||
"sandbox provider type not configured",
|
||||
)
|
||||
return any(marker in message for marker in fallback_markers)
|
||||
|
||||
@classmethod
|
||||
def _ensure_bucket_lifecycle(cls):
|
||||
if cls._lifecycle_configured:
|
||||
|
||||
Reference in New Issue
Block a user