Query ToolInstance in the database. Default version_no=0 queries the draft version. Args: agent_id: Agent ID for filtering, mandatory tool_id: Tool ID for filtering, mandatory tenant_id: Tenant ID for filtering, mandatory version_no: Version number to fi
(agent_id: int, tool_id: int, tenant_id: str, version_no: int = 0)
| 98 | |
| 99 | |
| 100 | def query_tool_instances_by_id(agent_id: int, tool_id: int, tenant_id: str, version_no: int = 0): |
| 101 | """ |
| 102 | Query ToolInstance in the database. |
| 103 | Default version_no=0 queries the draft version. |
| 104 | |
| 105 | Args: |
| 106 | agent_id: Agent ID for filtering, mandatory |
| 107 | tool_id: Tool ID for filtering, mandatory |
| 108 | tenant_id: Tenant ID for filtering, mandatory |
| 109 | version_no: Version number to filter. Default 0 = draft/editing state |
| 110 | |
| 111 | Returns: |
| 112 | ToolInstance object or None |
| 113 | """ |
| 114 | with get_db_session() as session: |
| 115 | query = session.query(ToolInstance).filter( |
| 116 | ToolInstance.tenant_id == tenant_id, |
| 117 | ToolInstance.agent_id == agent_id, |
| 118 | ToolInstance.tool_id == tool_id, |
| 119 | ToolInstance.version_no == version_no, |
| 120 | ToolInstance.delete_flag != 'Y') |
| 121 | tool_instance = query.first() |
| 122 | if tool_instance: |
| 123 | return as_dict(tool_instance) |
| 124 | else: |
| 125 | return None |
| 126 | |
| 127 | |
| 128 | def query_tools_by_ids(tool_id_list: List[int]): |