refactor(api): type tool service dicts with TypedDict (#33836)

This commit is contained in:
BitToby
2026-03-21 04:43:49 +02:00
committed by GitHub
parent 609258f42d
commit 55cc24fed7
2 changed files with 12 additions and 4 deletions

View File

@ -1,10 +1,10 @@
import json
import logging
from collections.abc import Mapping
from typing import Any, cast
from httpx import get
from sqlalchemy import select
from typing_extensions import TypedDict
from core.entities.provider_entities import ProviderConfig
from core.tools.__base.tool_runtime import ToolRuntime
@ -28,9 +28,16 @@ from services.tools.tools_transform_service import ToolTransformService
logger = logging.getLogger(__name__)
class ApiSchemaParseResult(TypedDict):
schema_type: str
parameters_schema: list[dict[str, Any]]
credentials_schema: list[dict[str, Any]]
warning: dict[str, str]
class ApiToolManageService:
@staticmethod
def parser_api_schema(schema: str) -> Mapping[str, Any]:
def parser_api_schema(schema: str) -> ApiSchemaParseResult:
"""
parse api schema to tool bundle
"""
@ -71,7 +78,7 @@ class ApiToolManageService:
]
return cast(
Mapping,
ApiSchemaParseResult,
jsonable_encoder(
{
"schema_type": schema_type,