isekai-toolkit/agentkit/types.py

95 lines
1.9 KiB
Python

from __future__ import annotations
from typing import Any, Callable, List, Optional, TypedDict
class ConfigSelectItem(TypedDict):
label: str
value: Any
class PluginConfigParam(TypedDict):
id: str
type: str
name: str
description: str
default: Any
required: bool
min: Optional[float]
max: Optional[float]
options: Optional[list[ConfigSelectItem]]
class HookInfo(TypedDict):
id: str
name: str
description: str
class_: Callable
class BaseMessage(TypedDict):
role: str
content: str
function_call: Optional[Any]
tool_calls: Optional[list]
tool_call_id: Optional[str]
class LLMFunctionInfo(TypedDict):
name_for_llm: str
name_for_human: str
description: str
params: dict
class LLMFunctionResponse(TypedDict):
response: str
"""The response text generated by the function."""
direct_return: bool
"""Directly return the response to the user, without further processing."""
class AgentKitFlowStep(TypedDict):
type: str
comment: str
class AgentKitFlowCall(AgentKitFlowStep):
# type: "call"
id: str
comment: str
config: dict[str, Any]
output_map: dict[str, str]
class AgentKitFlowIfElse(AgentKitFlowStep):
# type: "if_else"
condition: str
condition_input: dict[str, Any]
true_branch: list
false_branch: list
class AgentKitLoop(AgentKitFlowStep):
# type: "loop"
loop_num: int
loop_body: list
index_var: Optional[str]
class AgentKitBreakLoop(AgentKitFlowStep):
# type: "break_loop"
pass
class AgentKitSetVar(AgentKitFlowStep):
# type: "set_var"
var_name: str
var_value_expr: str
OnProgressCallback = Callable[[str, int, int], Any]
OnTaskStartCallback = Callable[[str, str], Any]
OnTaskProgressCallback = Callable[[int, Optional[int], Optional[str]], Any]
OnTaskCompleteCallback = Callable[[str], Any]