SimpleSallap:SimpleMCP:Update toolcall to suite calls needed

This commit is contained in:
hanishkvc 2025-12-06 01:43:31 +05:30
parent 452e610095
commit 47bd2bbc90
1 changed files with 23 additions and 7 deletions

View File

@ -3,6 +3,9 @@
from typing import Any, TypeAlias from typing import Any, TypeAlias
from dataclasses import dataclass from dataclasses import dataclass
import http
import http.client
import urllib.parse
# #
@ -32,6 +35,8 @@ fetchurlraw_meta = {
# Dataclasses to help with Tool Calls # Dataclasses to help with Tool Calls
# #
TCInArgs: TypeAlias = dict[str, Any]
@dataclass @dataclass
class TCInProperty(): class TCInProperty():
type: str type: str
@ -63,21 +68,32 @@ class TollCallResponse():
name: str name: str
content: str = "" content: str = ""
@dataclass(frozen=True)
class TCOutResponse:
"""
Used to return result from tool call.
"""
callOk: bool
statusCode: int
statusMsg: str = ""
contentType: str = ""
contentData: bytes = b""
@dataclass
class ToolCall(): class ToolCall():
name: str
name: str = ""
def tcf_meta(self) -> TCFunction|None: def tcf_meta(self) -> TCFunction|None:
return None return None
def tc_handle(self, args: TCInProperties) -> tuple[bool, str]: def tc_handle(self, args: TCInArgs, inHeaders: http.client.HTTPMessage) -> TCOutResponse:
return (False, "") return TCOutResponse(False, 500)
def meta(self) -> ToolCallMeta: def meta(self) -> ToolCallMeta:
tcf = self.tcf_meta() tcf = self.tcf_meta()
return ToolCallMeta("function", tcf) return ToolCallMeta("function", tcf)
def handler(self, callId: str, args: Any) -> TollCallResponse: def handler(self, callId: str, args: Any, inHeaders: http.client.HTTPMessage) -> TollCallResponse:
got = self.tc_handle(args) got = self.tc_handle(args, inHeaders)
return TollCallResponse(got[0], callId, self.name, got[1]) return TollCallResponse(got.callOk, callId, self.name, got.contentData.decode('utf-8'))