|
11 | 11 | import jsonref |
12 | 12 | from mcpadapt.smolagents_adapter import _sanitize_function_name |
13 | 13 |
|
14 | | -from consts.const import DEFAULT_USER_ID, LOCAL_MCP_SERVER |
| 14 | +from consts.const import DEFAULT_USER_ID, LOCAL_MCP_SERVER, DATA_PROCESS_SERVICE |
15 | 15 | from consts.exceptions import MCPConnectionError, ToolExecutionException, NotFoundException |
16 | 16 | from consts.model import ToolInstanceInfoRequest, ToolInfo, ToolSourceEnum, ToolValidateRequest |
17 | 17 | from database.remote_mcp_db import get_mcp_records_by_tenant, get_mcp_server_by_name_and_tenant |
|
23 | 23 | search_last_tool_instance_by_tool_id, |
24 | 24 | ) |
25 | 25 | from database.user_tenant_db import get_all_tenant_ids |
| 26 | +from services.file_management_service import get_llm_model |
26 | 27 | from services.vectordatabase_service import get_embedding_model, get_vector_db_core |
27 | 28 | from services.tenant_config_service import get_selected_knowledge_list |
| 29 | +from database.client import minio_client |
| 30 | +from services.image_service import get_vlm_model |
28 | 31 |
|
29 | 32 | logger = logging.getLogger("tool_configuration_service") |
30 | 33 |
|
@@ -613,6 +616,27 @@ def _validate_local_tool( |
613 | 616 | 'embedding_model': embedding_model, |
614 | 617 | } |
615 | 618 | tool_instance = tool_class(**params) |
| 619 | + elif tool_name == "analyze_image": |
| 620 | + if not tenant_id or not user_id: |
| 621 | + raise ToolExecutionException(f"Tenant ID and User ID are required for {tool_name} validation") |
| 622 | + image_to_text_model = get_vlm_model(tenant_id=tenant_id) |
| 623 | + params = { |
| 624 | + **instantiation_params, |
| 625 | + 'vlm_model': image_to_text_model, |
| 626 | + 'storage_client': minio_client |
| 627 | + } |
| 628 | + tool_instance = tool_class(**params) |
| 629 | + elif tool_name == "analyze_text_file": |
| 630 | + if not tenant_id or not user_id: |
| 631 | + raise ToolExecutionException(f"Tenant ID and User ID are required for {tool_name} validation") |
| 632 | + long_text_to_text_model = get_llm_model(tenant_id=tenant_id) |
| 633 | + params = { |
| 634 | + **instantiation_params, |
| 635 | + 'llm_model': long_text_to_text_model, |
| 636 | + 'storage_client': minio_client, |
| 637 | + "data_process_service_url": DATA_PROCESS_SERVICE |
| 638 | + } |
| 639 | + tool_instance = tool_class(**params) |
616 | 640 | else: |
617 | 641 | tool_instance = tool_class(**instantiation_params) |
618 | 642 |
|
|
0 commit comments