mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-19 23:24:42 +00:00
feat: agents and skills
This commit is contained in:
@@ -50,8 +50,9 @@ def classify_tool(func: AgentFunction) -> ToolType:
|
||||
"""
|
||||
Classify a tool based on its properties.
|
||||
|
||||
Currently the SDK exposes:
|
||||
- agent_functions: API functions with request_type
|
||||
Types:
|
||||
- AGENT_SKILL: is_agent_skill=True
|
||||
- API_FUNCTION: has request_type
|
||||
|
||||
Args:
|
||||
func: AgentFunction from TF SDK
|
||||
@@ -59,6 +60,10 @@ def classify_tool(func: AgentFunction) -> ToolType:
|
||||
Returns:
|
||||
ToolType enum value
|
||||
"""
|
||||
# Agent skills have is_agent_skill=True
|
||||
if getattr(func, 'is_agent_skill', None) is True:
|
||||
return ToolType.AGENT_SKILL
|
||||
|
||||
# All agent_functions with request_type are API Functions
|
||||
if func.request_type:
|
||||
return ToolType.API_FUNCTION
|
||||
@@ -89,6 +94,10 @@ def parse_function(func: AgentFunction) -> SyncedTool:
|
||||
# or may use TF proxy
|
||||
auth_via = "user_provided" if func.authorisation_type == "api_key" else "tf_proxy"
|
||||
|
||||
# Agent skills use skill script
|
||||
if tool_type == ToolType.AGENT_SKILL:
|
||||
auth_via = "tf_skill"
|
||||
|
||||
return SyncedTool(
|
||||
id=func.id,
|
||||
name=func.name,
|
||||
@@ -98,6 +107,7 @@ def parse_function(func: AgentFunction) -> SyncedTool:
|
||||
url=func.url,
|
||||
authorisation_type=func.authorisation_type,
|
||||
auth_via=auth_via,
|
||||
is_agent_skill=tool_type == ToolType.AGENT_SKILL,
|
||||
)
|
||||
|
||||
|
||||
@@ -126,7 +136,8 @@ def sync_tools(config: TFConfig) -> ToolSyncResult:
|
||||
Sync all tools from ToothFairyAI workspace using SDK.
|
||||
|
||||
Includes:
|
||||
- Agent Functions (API Functions)
|
||||
- Agent Functions (API Functions with request_type)
|
||||
- Agent Skills (functions with is_agent_skill=True)
|
||||
- Coder Agents (agents with mode='coder')
|
||||
|
||||
Args:
|
||||
@@ -138,7 +149,7 @@ def sync_tools(config: TFConfig) -> ToolSyncResult:
|
||||
try:
|
||||
client = config.get_client()
|
||||
|
||||
# Sync agent functions
|
||||
# Sync agent functions (includes API Functions and Agent Skills)
|
||||
func_result = client.agent_functions.list()
|
||||
tools = [parse_function(f) for f in func_result.items]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user