sadpandajoe commented on code in PR #42805: URL: https://github.com/apache/superset/pull/42805#discussion_r4032878088
########## superset/ai/tools/base.py: ########## @@ -0,0 +1,606 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +The tool contract and the registry that dispatches to it. + +A tool is a small, self-authorizing unit of work. "Self-authorizing" is the +important half: the registry does not check permissions on a tool's behalf, and +neither does the policy chain in :mod:`superset.ai.policy`, which answers the +coarser question of whether a *shape* of call should be attempted at all. Any +tool that returns or mutates a data-bearing object performs its own +``security_manager`` check, because that is the only place with enough context to +know which object is being touched. + +A tool returns two things. :attr:`ToolOutput.content` is what the model reads. +:attr:`ToolOutput.display` is a summary for the UI, so a user can expand what the +assistant did and see the SQL it ran and the rows it got back. Both are +size-bounded here rather than in each tool: ``display`` is persisted on the +message and shipped to the browser, so an unbounded one would be a second way to +blow up a response. +""" + +from __future__ import annotations + +import logging +import time +from abc import ABC, abstractmethod +from dataclasses import dataclass, field +from typing import Any, ClassVar + +from superset.ai.llm.base import ToolCall, ToolDefinition, ToolResult +from superset.mcp_service.utils.sanitization import ( Review Comment: Could this be updated for the current target branch sanitizer API? The target branch no longer exports these four delimiter constants, so after this branch is merged/rebased the top-level import raises `ImportError` when the tool registry loads, preventing the AI tools from starting. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
