From 44e254f2ce68dba93c15b5a3e6262eb18b4a0f89 Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Tue, 29 Oct 2024 14:39:16 -0400 Subject: [PATCH 1/3] feat(typespec): Add types for computer-use tools Signed-off-by: Diwank Singh Tomer --- agents-api/agents_api/autogen/Chat.py | 18 +- agents-api/agents_api/autogen/Entries.py | 23 +- agents-api/agents_api/autogen/Tools.py | 215 +++++++++++-- agents-api/notebooks/04-remove-messages.ipynb | 0 .../integrations/autogen/Chat.py | 18 +- .../integrations/autogen/Entries.py | 23 +- .../integrations/autogen/Tools.py | 215 +++++++++++-- typespec/tools/anthropic.tsp | 110 +++++++ typespec/tools/main.tsp | 1 + typespec/tools/models.tsp | 41 ++- .../@typespec/openapi3/openapi-1.0.0.yaml | 287 ++++++++++++++++-- 11 files changed, 875 insertions(+), 76 deletions(-) delete mode 100644 agents-api/notebooks/04-remove-messages.ipynb create mode 100644 typespec/tools/anthropic.tsp diff --git a/agents-api/agents_api/autogen/Chat.py b/agents-api/agents_api/autogen/Chat.py index d0d42d298..882997dfa 100644 --- a/agents-api/agents_api/autogen/Chat.py +++ b/agents-api/agents_api/autogen/Chat.py @@ -10,7 +10,14 @@ from .Common import LogitBias from .Docs import DocReference -from .Tools import ChosenToolCall, NamedToolChoice, Tool +from .Tools import ( + ChosenBash20241022, + ChosenComputer20241022, + ChosenFunctionCall, + ChosenTextEditor20241022, + NamedToolChoice, + Tool, +) class BaseChatOutput(BaseModel): @@ -287,7 +294,14 @@ class MessageModel(BaseModel): Name """ tool_calls: Annotated[ - list[ChosenToolCall] | None, Field(json_schema_extra={"readOnly": True}) + list[ + ChosenFunctionCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 + ] + | None, + Field(json_schema_extra={"readOnly": True}), ] = [] """ Tool calls generated by the model. diff --git a/agents-api/agents_api/autogen/Entries.py b/agents-api/agents_api/autogen/Entries.py index 530209320..6e5d297c2 100644 --- a/agents-api/agents_api/autogen/Entries.py +++ b/agents-api/agents_api/autogen/Entries.py @@ -8,7 +8,14 @@ from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel -from .Tools import ChosenToolCall, Tool, ToolResponse +from .Tools import ( + ChosenBash20241022, + ChosenComputer20241022, + ChosenFunctionCall, + ChosenTextEditor20241022, + Tool, + ToolResponse, +) class BaseEntry(BaseModel): @@ -31,11 +38,21 @@ class BaseEntry(BaseModel): content: ( list[Content | ContentModel] | Tool - | ChosenToolCall + | ChosenFunctionCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 | str | ToolResponse | list[ - list[Content | ContentModel] | Tool | ChosenToolCall | str | ToolResponse + list[Content | ContentModel] + | Tool + | ChosenFunctionCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 + | str + | ToolResponse ] ) source: Literal[ diff --git a/agents-api/agents_api/autogen/Tools.py b/agents-api/agents_api/autogen/Tools.py index 1ba1972d3..71623a28e 100644 --- a/agents-api/agents_api/autogen/Tools.py +++ b/agents-api/agents_api/autogen/Tools.py @@ -6,7 +6,15 @@ from typing import Annotated, Any, Literal from uuid import UUID -from pydantic import AnyUrl, AwareDatetime, BaseModel, ConfigDict, Field, StrictBool +from pydantic import ( + AnyUrl, + AwareDatetime, + BaseModel, + ConfigDict, + Field, + RootModel, + StrictBool, +) class ApiCallDef(BaseModel): @@ -124,6 +132,39 @@ class ApiCallDefUpdate(BaseModel): """ +class BaseChosenToolCall(BaseModel): + """ + The response tool value generated by the model + """ + + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal[ + "function", + "integration", + "system", + "api_call", + "computer_20241022", + "text_editor_20241022", + "bash_20241022", + ] + """ + Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) + """ + function: FunctionCallOption | None = None + integration: Any | None = None + system: Any | None = None + api_call: Any | None = None + computer_20241022: ChosenComputer20241022 | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: ChosenTextEditor20241022 | None = None + bash_20241022: ChosenBash20241022 | None = None + id: Annotated[UUID | None, Field(json_schema_extra={"readOnly": True})] = None + + class BaseIntegrationDef(BaseModel): """ Integration definition @@ -183,6 +224,18 @@ class BaseIntegrationDefUpdate(BaseModel): """ +class Bash20241022Def(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["bash_20241022"] = "bash_20241022" + name: str = "bash" + + +class Bash20241022DefUpdate(Bash20241022Def): + pass + + class BraveIntegrationDef(BaseIntegrationDef): """ Brave integration definition @@ -291,20 +344,121 @@ class BraveSearchSetupUpdate(BaseModel): """ -class ChosenToolCall(BaseModel): +class ChosenBash20241022(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + command: str | None = None """ - The response tool value generated by the model + The bash command to run + """ + restart: StrictBool = False """ + Whether to restart the tool + """ + +class ChosenComputer20241022(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - type: Literal["function", "integration", "system", "api_call"] + action: Literal[ + "key", + "type", + "cursor_position", + "mouse_move", + "left_click", + "right_click", + "middle_click", + "double_click", + "screenshot", + ] """ - Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) + The action to perform + """ + text: str | None = None + """ + The text to type + """ + coordinate: list[int] | None = None + """ + The (x, y) pixel coordinate to move the cursor to + """ + + +class ChosenFunctionCall(BaseChosenToolCall): + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["function"] = "function" + function: FunctionCallOption + """ + The function to call + """ + + +class ChosenTextEditor20241022(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + command: Literal["str_replace", "insert", "view", "undo_edit"] + """ + The command to run + """ + path: str + """ + The path to the file + """ + file_text: str | None = None + """ + The content of the file to be created + """ + insert_line: int | None = None + """ + The line to insert the new string after + """ + new_str: str | None = None + """ + The new string to insert + """ + old_str: str | None = None + """ + The string in the file to replace + """ + view_range: list[int] | None = None + """ + The line range to view + """ + + +class Computer20241022Def(BaseModel): + """ + Anthropic new tools + """ + + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["computer_20241022"] = "computer_20241022" + name: str = "computer" + display_width_px: Annotated[int, Field(ge=600)] = 1024 + """ + The display width in pixels + """ + display_height_px: Annotated[int, Field(ge=400)] = 768 + """ + The display height in pixels + """ + display_number: Annotated[int, Field(ge=1, le=10)] = 1 + """ + The display number to use + """ + + +class Computer20241022DefUpdate(Computer20241022Def): + """ + Anthropic new tools """ - function: FunctionCallOption | None = None - id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] class CreateToolRequest(BaseModel): @@ -347,6 +501,12 @@ class CreateToolRequest(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022Def | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022Def | None = None + bash_20241022: Bash20241022Def | None = None class DummyIntegrationDef(BaseIntegrationDef): @@ -598,6 +758,12 @@ class PatchToolRequest(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022DefUpdate | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022DefUpdate | None = None + bash_20241022: Bash20241022DefUpdate | None = None class SpiderFetchArguments(BaseModel): @@ -815,6 +981,18 @@ class SystemDefUpdate(BaseModel): """ +class TextEditor20241022Def(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["text_editor_20241022"] = "text_editor_20241022" + name: str = "str_replace_editor" + + +class TextEditor20241022DefUpdate(TextEditor20241022Def): + pass + + class Tool(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -851,6 +1029,12 @@ class Tool(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022Def | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022Def | None = None + bash_20241022: Bash20241022Def | None = None created_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})] """ When this resource was created as UTC date-time @@ -913,6 +1097,12 @@ class UpdateToolRequest(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022Def | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022Def | None = None + bash_20241022: Bash20241022Def | None = None class WeatherGetArguments(BaseModel): @@ -1109,14 +1299,3 @@ class WikipediaSearchArgumentsUpdate(BaseModel): """ Maximum number of documents to load """ - - -class ChosenFunctionCall(ChosenToolCall): - model_config = ConfigDict( - populate_by_name=True, - ) - type: Literal["function"] = "function" - function: FunctionCallOption - """ - The function to call - """ diff --git a/agents-api/notebooks/04-remove-messages.ipynb b/agents-api/notebooks/04-remove-messages.ipynb deleted file mode 100644 index e69de29bb..000000000 diff --git a/integrations-service/integrations/autogen/Chat.py b/integrations-service/integrations/autogen/Chat.py index d0d42d298..882997dfa 100644 --- a/integrations-service/integrations/autogen/Chat.py +++ b/integrations-service/integrations/autogen/Chat.py @@ -10,7 +10,14 @@ from .Common import LogitBias from .Docs import DocReference -from .Tools import ChosenToolCall, NamedToolChoice, Tool +from .Tools import ( + ChosenBash20241022, + ChosenComputer20241022, + ChosenFunctionCall, + ChosenTextEditor20241022, + NamedToolChoice, + Tool, +) class BaseChatOutput(BaseModel): @@ -287,7 +294,14 @@ class MessageModel(BaseModel): Name """ tool_calls: Annotated[ - list[ChosenToolCall] | None, Field(json_schema_extra={"readOnly": True}) + list[ + ChosenFunctionCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 + ] + | None, + Field(json_schema_extra={"readOnly": True}), ] = [] """ Tool calls generated by the model. diff --git a/integrations-service/integrations/autogen/Entries.py b/integrations-service/integrations/autogen/Entries.py index 530209320..6e5d297c2 100644 --- a/integrations-service/integrations/autogen/Entries.py +++ b/integrations-service/integrations/autogen/Entries.py @@ -8,7 +8,14 @@ from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel -from .Tools import ChosenToolCall, Tool, ToolResponse +from .Tools import ( + ChosenBash20241022, + ChosenComputer20241022, + ChosenFunctionCall, + ChosenTextEditor20241022, + Tool, + ToolResponse, +) class BaseEntry(BaseModel): @@ -31,11 +38,21 @@ class BaseEntry(BaseModel): content: ( list[Content | ContentModel] | Tool - | ChosenToolCall + | ChosenFunctionCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 | str | ToolResponse | list[ - list[Content | ContentModel] | Tool | ChosenToolCall | str | ToolResponse + list[Content | ContentModel] + | Tool + | ChosenFunctionCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 + | str + | ToolResponse ] ) source: Literal[ diff --git a/integrations-service/integrations/autogen/Tools.py b/integrations-service/integrations/autogen/Tools.py index 1ba1972d3..71623a28e 100644 --- a/integrations-service/integrations/autogen/Tools.py +++ b/integrations-service/integrations/autogen/Tools.py @@ -6,7 +6,15 @@ from typing import Annotated, Any, Literal from uuid import UUID -from pydantic import AnyUrl, AwareDatetime, BaseModel, ConfigDict, Field, StrictBool +from pydantic import ( + AnyUrl, + AwareDatetime, + BaseModel, + ConfigDict, + Field, + RootModel, + StrictBool, +) class ApiCallDef(BaseModel): @@ -124,6 +132,39 @@ class ApiCallDefUpdate(BaseModel): """ +class BaseChosenToolCall(BaseModel): + """ + The response tool value generated by the model + """ + + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal[ + "function", + "integration", + "system", + "api_call", + "computer_20241022", + "text_editor_20241022", + "bash_20241022", + ] + """ + Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) + """ + function: FunctionCallOption | None = None + integration: Any | None = None + system: Any | None = None + api_call: Any | None = None + computer_20241022: ChosenComputer20241022 | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: ChosenTextEditor20241022 | None = None + bash_20241022: ChosenBash20241022 | None = None + id: Annotated[UUID | None, Field(json_schema_extra={"readOnly": True})] = None + + class BaseIntegrationDef(BaseModel): """ Integration definition @@ -183,6 +224,18 @@ class BaseIntegrationDefUpdate(BaseModel): """ +class Bash20241022Def(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["bash_20241022"] = "bash_20241022" + name: str = "bash" + + +class Bash20241022DefUpdate(Bash20241022Def): + pass + + class BraveIntegrationDef(BaseIntegrationDef): """ Brave integration definition @@ -291,20 +344,121 @@ class BraveSearchSetupUpdate(BaseModel): """ -class ChosenToolCall(BaseModel): +class ChosenBash20241022(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + command: str | None = None """ - The response tool value generated by the model + The bash command to run + """ + restart: StrictBool = False """ + Whether to restart the tool + """ + +class ChosenComputer20241022(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - type: Literal["function", "integration", "system", "api_call"] + action: Literal[ + "key", + "type", + "cursor_position", + "mouse_move", + "left_click", + "right_click", + "middle_click", + "double_click", + "screenshot", + ] """ - Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) + The action to perform + """ + text: str | None = None + """ + The text to type + """ + coordinate: list[int] | None = None + """ + The (x, y) pixel coordinate to move the cursor to + """ + + +class ChosenFunctionCall(BaseChosenToolCall): + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["function"] = "function" + function: FunctionCallOption + """ + The function to call + """ + + +class ChosenTextEditor20241022(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + command: Literal["str_replace", "insert", "view", "undo_edit"] + """ + The command to run + """ + path: str + """ + The path to the file + """ + file_text: str | None = None + """ + The content of the file to be created + """ + insert_line: int | None = None + """ + The line to insert the new string after + """ + new_str: str | None = None + """ + The new string to insert + """ + old_str: str | None = None + """ + The string in the file to replace + """ + view_range: list[int] | None = None + """ + The line range to view + """ + + +class Computer20241022Def(BaseModel): + """ + Anthropic new tools + """ + + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["computer_20241022"] = "computer_20241022" + name: str = "computer" + display_width_px: Annotated[int, Field(ge=600)] = 1024 + """ + The display width in pixels + """ + display_height_px: Annotated[int, Field(ge=400)] = 768 + """ + The display height in pixels + """ + display_number: Annotated[int, Field(ge=1, le=10)] = 1 + """ + The display number to use + """ + + +class Computer20241022DefUpdate(Computer20241022Def): + """ + Anthropic new tools """ - function: FunctionCallOption | None = None - id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] class CreateToolRequest(BaseModel): @@ -347,6 +501,12 @@ class CreateToolRequest(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022Def | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022Def | None = None + bash_20241022: Bash20241022Def | None = None class DummyIntegrationDef(BaseIntegrationDef): @@ -598,6 +758,12 @@ class PatchToolRequest(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022DefUpdate | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022DefUpdate | None = None + bash_20241022: Bash20241022DefUpdate | None = None class SpiderFetchArguments(BaseModel): @@ -815,6 +981,18 @@ class SystemDefUpdate(BaseModel): """ +class TextEditor20241022Def(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + type: Literal["text_editor_20241022"] = "text_editor_20241022" + name: str = "str_replace_editor" + + +class TextEditor20241022DefUpdate(TextEditor20241022Def): + pass + + class Tool(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -851,6 +1029,12 @@ class Tool(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022Def | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022Def | None = None + bash_20241022: Bash20241022Def | None = None created_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})] """ When this resource was created as UTC date-time @@ -913,6 +1097,12 @@ class UpdateToolRequest(BaseModel): """ The API call to make """ + computer_20241022: Computer20241022Def | None = None + """ + (Alpha) Anthropic new tools + """ + text_editor_20241022: TextEditor20241022Def | None = None + bash_20241022: Bash20241022Def | None = None class WeatherGetArguments(BaseModel): @@ -1109,14 +1299,3 @@ class WikipediaSearchArgumentsUpdate(BaseModel): """ Maximum number of documents to load """ - - -class ChosenFunctionCall(ChosenToolCall): - model_config = ConfigDict( - populate_by_name=True, - ) - type: Literal["function"] = "function" - function: FunctionCallOption - """ - The function to call - """ diff --git a/typespec/tools/anthropic.tsp b/typespec/tools/anthropic.tsp new file mode 100644 index 000000000..2718b42e6 --- /dev/null +++ b/typespec/tools/anthropic.tsp @@ -0,0 +1,110 @@ +import "../common"; + +using Common; + +namespace Tools; + + +/** + * Anthropic new tools + */ + + +model Computer20241022Def { + type: "computer_20241022" = "computer_20241022"; + name?: string = "computer"; + + /** The display width in pixels */ + @minValue(600) + display_width_px: uint16 = 1024; + + /** The display height in pixels */ + @minValue(400) + display_height_px: uint16 = 768; + + /** The display number to use */ + @minValue(1) + @maxValue(10) + display_number?: uint16 = 1; +} + +model TextEditor20241022Def { + type: "text_editor_20241022" = "text_editor_20241022"; + name?: string = "str_replace_editor"; +} + +model Bash20241022Def { + type: "bash_20241022" = "bash_20241022"; + name?: string = "bash"; +} + +enum Computer20241022Action { + /** Press a key or key-combination on the keyboard */ + key, + + /** Type a string of text on the keyboard */ + type, + + /** Get the current (x, y) pixel coordinate of the cursor on the screen */ + cursor_position, + + /** Move the cursor to a specified (x, y) pixel coordinate on the screen */ + mouse_move, + + /** Click the left mouse button */ + left_click, + + /** Click the right mouse button */ + right_click, + + /** Click the middle mouse button */ + middle_click, + + /** Double-click the left mouse button */ + double_click, + + /** Take a screenshot of the screen */ + screenshot, +} + +model ChosenComputer20241022 { + /** The action to perform */ + action: Computer20241022Action; + + /** The text to type */ + text?: string; + + /** The (x, y) pixel coordinate to move the cursor to */ + coordinate?: uint16[]; +} + +model ChosenTextEditor20241022 { + /** The command to run */ + command: "str_replace" | "insert" | "view" | "undo_edit"; + + /** The path to the file */ + path: string; + + /** The content of the file to be created */ + file_text?: string; + + /** The line to insert the new string after */ + insert_line?: uint16; + + /** The new string to insert */ + new_str?: string; + + /** The string in the file to replace */ + old_str?: string; + + /** The line range to view */ + view_range?: uint16[]; +} + +model ChosenBash20241022 { + /** The bash command to run */ + command?: string; + + /** Whether to restart the tool */ + restart?: boolean = false; +} diff --git a/typespec/tools/main.tsp b/typespec/tools/main.tsp index 351dc92af..d80641354 100644 --- a/typespec/tools/main.tsp +++ b/typespec/tools/main.tsp @@ -1,5 +1,6 @@ import "./endpoints.tsp"; import "./models.tsp"; +import "./anthropic.tsp"; import "./brave.tsp"; import "./email.tsp"; import "./spider.tsp"; diff --git a/typespec/tools/models.tsp b/typespec/tools/models.tsp index c41a01668..f641d473a 100644 --- a/typespec/tools/models.tsp +++ b/typespec/tools/models.tsp @@ -36,6 +36,11 @@ enum ToolType { /** A tool that makes an API call */ api_call, + + /** (Alpha) Anthropic new tools */ + computer_20241022, + text_editor_20241022, + bash_20241022, } /** The parameters the functions accepts, described as a JSON Schema object. */ @@ -58,8 +63,6 @@ model FunctionDef { } -// TODO: Add granular definitions for each integration - /** Integration definition */ @discriminator("provider") model BaseIntegrationDef { @@ -219,6 +222,11 @@ model Tool { /** The API call to make */ api_call?: ApiCallDef; + /** (Alpha) Anthropic new tools */ + computer_20241022?: Computer20241022Def; + text_editor_20241022?: TextEditor20241022Def; + bash_20241022?: Bash20241022Def; + ...HasTimestamps; ...HasId; } @@ -258,22 +266,37 @@ model UpdateToolRequest { model PatchToolRequest is UpdateToolRequest {} /** The response tool value generated by the model */ -@discriminator("type") -model ChosenToolCall { +model BaseChosenToolCall { /** Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) */ type: ToolType; function?: FunctionCallOption; - integration?: never; - system?: never; - api_call?: never; + integration?: unknown; // ChosenIntegrationCall + system?: unknown; // ChosenSystemCall + api_call?: unknown; // ChosenApiCall - ...HasId; + /** (Alpha) Anthropic new tools */ + computer_20241022?: ChosenComputer20241022; + text_editor_20241022?: ChosenTextEditor20241022; + bash_20241022?: ChosenBash20241022; + + @visibility("read") + id?: uuid; } -model ChosenFunctionCall extends ChosenToolCall { +model ChosenFunctionCall extends BaseChosenToolCall { type: ToolType.function; /** The function to call */ function: FunctionCallOption; } + +alias ChosenToolCall = ( + | ChosenFunctionCall + // | ChosenIntegrationCall + // | ChosenSystemCall + // | ChosenApiCall + | ChosenComputer20241022 + | ChosenTextEditor20241022 + | ChosenBash20241022 +); diff --git a/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml b/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml index 40e35ca8c..1be957f04 100644 --- a/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml +++ b/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml @@ -2139,7 +2139,11 @@ components: tool_calls: type: array items: - $ref: '#/components/schemas/Tools.ChosenToolCall' + anyOf: + - $ref: '#/components/schemas/Tools.ChosenFunctionCall' + - $ref: '#/components/schemas/Tools.ChosenComputer20241022' + - $ref: '#/components/schemas/Tools.ChosenTextEditor20241022' + - $ref: '#/components/schemas/Tools.ChosenBash20241022' nullable: true description: Tool calls generated by the model. default: [] @@ -2283,7 +2287,11 @@ components: tool_calls: type: array items: - $ref: '#/components/schemas/Tools.ChosenToolCall' + anyOf: + - $ref: '#/components/schemas/Tools.ChosenFunctionCall' + - $ref: '#/components/schemas/Tools.ChosenComputer20241022' + - $ref: '#/components/schemas/Tools.ChosenTextEditor20241022' + - $ref: '#/components/schemas/Tools.ChosenBash20241022' nullable: true description: Tool calls generated by the model. default: [] @@ -2759,7 +2767,10 @@ components: description: The type (fixed to 'image_url') default: image_url - $ref: '#/components/schemas/Tools.Tool' - - $ref: '#/components/schemas/Tools.ChosenToolCall' + - $ref: '#/components/schemas/Tools.ChosenFunctionCall' + - $ref: '#/components/schemas/Tools.ChosenComputer20241022' + - $ref: '#/components/schemas/Tools.ChosenTextEditor20241022' + - $ref: '#/components/schemas/Tools.ChosenBash20241022' - type: string - $ref: '#/components/schemas/Tools.ToolResponse' - type: array @@ -2808,7 +2819,10 @@ components: description: The type (fixed to 'image_url') default: image_url - $ref: '#/components/schemas/Tools.Tool' - - $ref: '#/components/schemas/Tools.ChosenToolCall' + - $ref: '#/components/schemas/Tools.ChosenFunctionCall' + - $ref: '#/components/schemas/Tools.ChosenComputer20241022' + - $ref: '#/components/schemas/Tools.ChosenTextEditor20241022' + - $ref: '#/components/schemas/Tools.ChosenBash20241022' - type: string - $ref: '#/components/schemas/Tools.ToolResponse' source: @@ -5789,6 +5803,33 @@ components: format: uint8 description: The timeout for the request description: API call definition + Tools.BaseChosenToolCall: + type: object + required: + - type + properties: + type: + allOf: + - $ref: '#/components/schemas/Tools.ToolType' + description: Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) + function: + $ref: '#/components/schemas/Tools.FunctionCallOption' + integration: {} + system: {} + api_call: {} + computer_20241022: + allOf: + - $ref: '#/components/schemas/Tools.ChosenComputer20241022' + description: (Alpha) Anthropic new tools + text_editor_20241022: + $ref: '#/components/schemas/Tools.ChosenTextEditor20241022' + bash_20241022: + $ref: '#/components/schemas/Tools.ChosenBash20241022' + id: + allOf: + - $ref: '#/components/schemas/Common.uuid' + readOnly: true + description: The response tool value generated by the model Tools.BaseIntegrationDef: type: object required: @@ -5851,6 +5892,30 @@ components: wikipedia: '#/components/schemas/Tools.WikipediaIntegrationDefUpdate' weather: '#/components/schemas/Tools.WeatherIntegrationDefUpdate' description: Integration definition + Tools.Bash20241022Def: + type: object + required: + - type + properties: + type: + type: string + enum: + - bash_20241022 + default: bash_20241022 + name: + type: string + default: bash + Tools.Bash20241022DefUpdate: + type: object + properties: + type: + type: string + enum: + - bash_20241022 + default: bash_20241022 + name: + type: string + default: bash Tools.BraveIntegrationDef: type: object required: @@ -5931,6 +5996,34 @@ components: type: string description: The api key for Brave Search description: Integration definition for Brave Search + Tools.ChosenBash20241022: + type: object + properties: + command: + type: string + description: The bash command to run + restart: + type: boolean + description: Whether to restart the tool + default: false + Tools.ChosenComputer20241022: + type: object + required: + - action + properties: + action: + allOf: + - $ref: '#/components/schemas/Tools.Computer20241022Action' + description: The action to perform + text: + type: string + description: The text to type + coordinate: + type: array + items: + type: integer + format: uint16 + description: The (x, y) pixel coordinate to move the cursor to Tools.ChosenFunctionCall: type: object required: @@ -5946,28 +6039,121 @@ components: - $ref: '#/components/schemas/Tools.FunctionCallOption' description: The function to call allOf: - - $ref: '#/components/schemas/Tools.ChosenToolCall' - Tools.ChosenToolCall: + - $ref: '#/components/schemas/Tools.BaseChosenToolCall' + Tools.ChosenTextEditor20241022: type: object required: + - command + - path + properties: + command: + type: string + enum: + - str_replace + - insert + - view + - undo_edit + description: The command to run + path: + type: string + description: The path to the file + file_text: + type: string + description: The content of the file to be created + insert_line: + type: integer + format: uint16 + description: The line to insert the new string after + new_str: + type: string + description: The new string to insert + old_str: + type: string + description: The string in the file to replace + view_range: + type: array + items: + type: integer + format: uint16 + description: The line range to view + Tools.Computer20241022Action: + type: string + enum: + - key - type - - id + - cursor_position + - mouse_move + - left_click + - right_click + - middle_click + - double_click + - screenshot + Tools.Computer20241022Def: + type: object + required: + - type + - display_width_px + - display_height_px properties: type: - allOf: - - $ref: '#/components/schemas/Tools.ToolType' - description: Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) - function: - $ref: '#/components/schemas/Tools.FunctionCallOption' - id: - allOf: - - $ref: '#/components/schemas/Common.uuid' - readOnly: true - discriminator: - propertyName: type - mapping: - function: '#/components/schemas/Tools.ChosenFunctionCall' - description: The response tool value generated by the model + type: string + enum: + - computer_20241022 + default: computer_20241022 + name: + type: string + default: computer + display_width_px: + type: integer + format: uint16 + minimum: 600 + description: The display width in pixels + default: 1024 + display_height_px: + type: integer + format: uint16 + minimum: 400 + description: The display height in pixels + default: 768 + display_number: + type: integer + format: uint16 + minimum: 1 + maximum: 10 + description: The display number to use + default: 1 + description: Anthropic new tools + Tools.Computer20241022DefUpdate: + type: object + properties: + type: + type: string + enum: + - computer_20241022 + default: computer_20241022 + name: + type: string + default: computer + display_width_px: + type: integer + format: uint16 + minimum: 600 + description: The display width in pixels + default: 1024 + display_height_px: + type: integer + format: uint16 + minimum: 400 + description: The display height in pixels + default: 768 + display_number: + type: integer + format: uint16 + minimum: 1 + maximum: 10 + description: The display number to use + default: 1 + description: Anthropic new tools Tools.CreateToolRequest: type: object required: @@ -6001,6 +6187,14 @@ components: allOf: - $ref: '#/components/schemas/Tools.ApiCallDef' description: The API call to make + computer_20241022: + allOf: + - $ref: '#/components/schemas/Tools.Computer20241022Def' + description: (Alpha) Anthropic new tools + text_editor_20241022: + $ref: '#/components/schemas/Tools.TextEditor20241022Def' + bash_20241022: + $ref: '#/components/schemas/Tools.Bash20241022Def' description: Payload for creating a tool Tools.DummyIntegrationDef: type: object @@ -6208,6 +6402,14 @@ components: allOf: - $ref: '#/components/schemas/Tools.ApiCallDefUpdate' description: The API call to make + computer_20241022: + allOf: + - $ref: '#/components/schemas/Tools.Computer20241022DefUpdate' + description: (Alpha) Anthropic new tools + text_editor_20241022: + $ref: '#/components/schemas/Tools.TextEditor20241022DefUpdate' + bash_20241022: + $ref: '#/components/schemas/Tools.Bash20241022DefUpdate' description: Payload for patching a tool Tools.SpiderFetchArguments: type: object @@ -6408,6 +6610,30 @@ components: additionalProperties: {} description: The arguments to pre-apply to the system call description: System definition + Tools.TextEditor20241022Def: + type: object + required: + - type + properties: + type: + type: string + enum: + - text_editor_20241022 + default: text_editor_20241022 + name: + type: string + default: str_replace_editor + Tools.TextEditor20241022DefUpdate: + type: object + properties: + type: + type: string + enum: + - text_editor_20241022 + default: text_editor_20241022 + name: + type: string + default: str_replace_editor Tools.Tool: type: object required: @@ -6444,6 +6670,14 @@ components: allOf: - $ref: '#/components/schemas/Tools.ApiCallDef' description: The API call to make + computer_20241022: + allOf: + - $ref: '#/components/schemas/Tools.Computer20241022Def' + description: (Alpha) Anthropic new tools + text_editor_20241022: + $ref: '#/components/schemas/Tools.TextEditor20241022Def' + bash_20241022: + $ref: '#/components/schemas/Tools.Bash20241022Def' created_at: type: string format: date-time @@ -6477,6 +6711,9 @@ components: - integration - system - api_call + - computer_20241022 + - text_editor_20241022 + - bash_20241022 Tools.UpdateToolRequest: type: object required: @@ -6510,6 +6747,14 @@ components: allOf: - $ref: '#/components/schemas/Tools.ApiCallDef' description: The API call to make + computer_20241022: + allOf: + - $ref: '#/components/schemas/Tools.Computer20241022Def' + description: (Alpha) Anthropic new tools + text_editor_20241022: + $ref: '#/components/schemas/Tools.TextEditor20241022Def' + bash_20241022: + $ref: '#/components/schemas/Tools.Bash20241022Def' description: Payload for updating a tool Tools.WeatherGetArguments: type: object From 0db5d9123752f8f85827349bfd3c9666f8e6598a Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Tue, 29 Oct 2024 15:00:14 -0400 Subject: [PATCH 2/3] fix(agents-api): Fix broken import coz of typespec changes Signed-off-by: Diwank Singh Tomer --- agents-api/agents_api/autogen/openapi_model.py | 4 ++-- agents-api/pytype.toml | 4 +++- agents-api/tests/test_docs_routes.py | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/agents-api/agents_api/autogen/openapi_model.py b/agents-api/agents_api/autogen/openapi_model.py index aabc775f2..2e84c818a 100644 --- a/agents-api/agents_api/autogen/openapi_model.py +++ b/agents-api/agents_api/autogen/openapi_model.py @@ -320,13 +320,13 @@ def validate_subworkflows(self): ChatMLContent = ( list[ChatMLTextContentPart | ChatMLImageContentPart] | Tool - | ChosenToolCall + | BaseChosenToolCall | str | ToolResponse | list[ list[ChatMLTextContentPart | ChatMLImageContentPart] | Tool - | ChosenToolCall + | BaseChosenToolCall | str | ToolResponse ] diff --git a/agents-api/pytype.toml b/agents-api/pytype.toml index b591601cc..e3995a98e 100644 --- a/agents-api/pytype.toml +++ b/agents-api/pytype.toml @@ -8,7 +8,9 @@ exclude = [ # Space-separated list of files or directories to process. inputs = [ - '.', + 'agents_api', + 'migrations', + 'tests', ] # Keep going past errors to analyze as many files as possible. diff --git a/agents-api/tests/test_docs_routes.py b/agents-api/tests/test_docs_routes.py index d61bfbcb7..fbd7f1990 100644 --- a/agents-api/tests/test_docs_routes.py +++ b/agents-api/tests/test_docs_routes.py @@ -1,3 +1,4 @@ +import asyncio from ward import test from tests.fixtures import ( @@ -135,6 +136,7 @@ def _(make_request=make_request, agent=test_agent): # TODO: Fix this test. It fails sometimes and sometimes not. @test("route: search agent docs") async def _(make_request=make_request, agent=test_agent, doc=test_doc): + await asyncio.sleep(0.5) search_params = dict( text=doc.content[0], limit=1, @@ -155,7 +157,8 @@ async def _(make_request=make_request, agent=test_agent, doc=test_doc): @test("route: search user docs") -def _(make_request=make_request, user=test_user, doc=test_user_doc): +async def _(make_request=make_request, user=test_user, doc=test_user_doc): + await asyncio.sleep(0.5) search_params = dict( text=doc.content[0], limit=1, From d2a2be5532f161f21d33468923392ee5657b44d5 Mon Sep 17 00:00:00 2001 From: creatorrr Date: Tue, 29 Oct 2024 19:00:54 +0000 Subject: [PATCH 3/3] refactor: Lint agents-api (CI) --- agents-api/tests/test_docs_routes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/agents-api/tests/test_docs_routes.py b/agents-api/tests/test_docs_routes.py index fbd7f1990..ef33cb9f8 100644 --- a/agents-api/tests/test_docs_routes.py +++ b/agents-api/tests/test_docs_routes.py @@ -1,4 +1,5 @@ import asyncio + from ward import test from tests.fixtures import (