Skip to content

Commit

Permalink
feat(typespec,agents-api): Add system tool call types
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Oct 4, 2024
1 parent cb9a1d5 commit 5241358
Show file tree
Hide file tree
Showing 6 changed files with 12,823 additions and 14 deletions.
79 changes: 71 additions & 8 deletions agents-api/agents_api/autogen/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ApiCallDef(BaseModel):
"""
The content as base64 to send with the request
"""
data: dict[str, str] | None = None
data: dict[str, Any] | None = None
"""
The data to send as form data
"""
Expand All @@ -55,6 +55,10 @@ class ApiCallDef(BaseModel):
"""
Follow redirects
"""
timeout: int | None = None
"""
The timeout for the request
"""


class ApiCallDefUpdate(BaseModel):
Expand Down Expand Up @@ -94,7 +98,7 @@ class ApiCallDefUpdate(BaseModel):
"""
The content as base64 to send with the request
"""
data: dict[str, str] | None = None
data: dict[str, Any] | None = None
"""
The data to send as form data
"""
Expand All @@ -114,6 +118,10 @@ class ApiCallDefUpdate(BaseModel):
"""
Follow redirects
"""
timeout: int | None = None
"""
The timeout for the request
"""


class ChosenToolCall(BaseModel):
Expand Down Expand Up @@ -188,9 +196,9 @@ class FunctionDef(BaseModel):
"""
DO NOT USE: This will be overriden by the tool name. Here only for compatibility reasons.
"""
description: str | None = None
description: Any | None = None
"""
Description of the function
DO NOT USE: This will be overriden by the tool description. Here only for compatibility reasons.
"""
parameters: dict[str, Any] | None = None
"""
Expand Down Expand Up @@ -322,9 +330,34 @@ class SystemDef(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
call: str
resource: Literal["agent", "user", "task", "execution", "doc", "session", "job"]
"""
Resource is the name of the resource to use
"""
operation: Literal[
"create",
"update",
"patch",
"create_or_update",
"embed",
"change_status",
"search",
"chat",
"history",
"delete",
"get",
"list",
]
"""
The name of the system call
Operation is the name of the operation to perform
"""
resource_id: UUID | None = None
"""
Resource id (if applicable)
"""
subresource: Literal["tool", "doc", "execution", "transition"] | None = None
"""
Sub-resource type (if applicable)
"""
arguments: dict[str, Any] | None = None
"""
Expand All @@ -340,9 +373,39 @@ class SystemDefUpdate(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
call: str | None = None
resource: (
Literal["agent", "user", "task", "execution", "doc", "session", "job"] | None
) = None
"""
Resource is the name of the resource to use
"""
operation: (
Literal[
"create",
"update",
"patch",
"create_or_update",
"embed",
"change_status",
"search",
"chat",
"history",
"delete",
"get",
"list",
]
| None
) = None
"""
Operation is the name of the operation to perform
"""
resource_id: UUID | None = None
"""
Resource id (if applicable)
"""
subresource: Literal["tool", "doc", "execution", "transition"] | None = None
"""
The name of the system call
Sub-resource type (if applicable)
"""
arguments: dict[str, Any] | None = None
"""
Expand Down
9 changes: 8 additions & 1 deletion typespec/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
/tsp-output/
# Ignore everything in tsp-output
tsp-output/**/*.*

# Don't ignore the openapi3 directory
!tsp-output/@typespec/openapi3/

# But don't ignore openapi-*.yaml files in tsp-output/@typespec/openapi3/
!tsp-output/@typespec/openapi3/openapi-*.yaml
58 changes: 53 additions & 5 deletions typespec/tools/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ model FunctionDef {
/** DO NOT USE: This will be overriden by the tool name. Here only for compatibility reasons. */
name?: null = null;

/** Description of the function */
description?: string;
/** DO NOT USE: This will be overriden by the tool description. Here only for compatibility reasons. */
description?: null = null;

/** The parameters the function accepts */
parameters?: FunctionParameters;
Expand All @@ -57,10 +57,55 @@ model IntegrationDef {
arguments?: FunctionParameters;
}

//
// SYSTEM TOOL MODELS
//

alias resourceType = (
| "agent"
| "user"
| "task"
| "execution"
| "doc"
| "session"
| "job"
);

alias subresourceType = (
| "tool"
| "doc"
| "execution"
| "transition"
);

alias operationType = (
| "create"
| "update"
| "patch"
| "create_or_update"
| "embed"
| "change_status"
| "search"
| "chat"
| "history"
| "delete"
| "get"
| "list"
);

/** System definition */
model SystemDef {
/** The name of the system call */
call: string;
/** Resource is the name of the resource to use */
resource: resourceType;

/** Operation is the name of the operation to perform */
operation: operationType;

/** Resource id (if applicable) */
resource_id?: uuid;

/** Sub-resource type (if applicable) */
subresource?: subresourceType;

/** The arguments to pre-apply to the system call */
arguments?: FunctionParameters;
Expand All @@ -81,7 +126,7 @@ model ApiCallDef {
content?: string;

/** The data to send as form data */
data?: Record<string>;
data?: Record<unknown>;

/** JSON body to send with the request */
json?: Record<unknown>;
Expand All @@ -94,6 +139,9 @@ model ApiCallDef {

/** Follow redirects */
follow_redirects?: boolean;

/** The timeout for the request */
timeout?: uint8;
}


Expand Down
Loading

0 comments on commit 5241358

Please sign in to comment.