From 984c813fa79bdbc073175d1a46a91f126097e2c6 Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Tue, 3 Sep 2024 10:53:44 -0400 Subject: [PATCH] feat: Add TODOs and fix typescript generated code Signed-off-by: Diwank Singh Tomer --- .github/workflows/changelog-ci.yml | 1 + .github/workflows/generate-docs.yml | 1 + .github/workflows/lint-and-format.yml | 1 + .github/workflows/push-to-hub.yml | 1 + .../activities/task_steps/__init__.py | 1 + .../activities/task_steps/get_value_step.py | 26 ++++++++++++ .../activities/task_steps/set_value_step.py | 1 + agents-api/agents_api/autogen/Chat.py | 4 +- agents-api/agents_api/autogen/Tools.py | 42 ++++++++++--------- .../tasks/stream_transitions_events.py | 3 +- agents-api/poetry.lock | 6 +-- embedding-service/docker-compose.yml | 1 + sdks/python/poetry.lock | 6 +-- sdks/ts/src/api/index.ts | 2 - sdks/ts/src/api/models/Chat_ChatInputData.ts | 4 +- .../src/api/models/Tools_CreateToolRequest.ts | 6 ++- sdks/ts/src/api/models/Tools_FunctionTool.ts | 15 ------- .../src/api/models/Tools_PatchToolRequest.ts | 4 ++ sdks/ts/src/api/models/Tools_Tool.ts | 6 ++- .../src/api/models/Tools_UpdateToolRequest.ts | 6 ++- .../ts/src/api/schemas/$Chat_ChatInputData.ts | 2 +- .../api/schemas/$Tools_CreateToolRequest.ts | 13 +++++- .../ts/src/api/schemas/$Tools_FunctionTool.ts | 38 ----------------- .../api/schemas/$Tools_PatchToolRequest.ts | 11 ++++- sdks/ts/src/api/schemas/$Tools_Tool.ts | 13 +++++- .../api/schemas/$Tools_UpdateToolRequest.ts | 13 +++++- typespec/chat/models.tsp | 2 +- typespec/tools/models.tsp | 16 +++---- 28 files changed, 140 insertions(+), 105 deletions(-) create mode 100644 agents-api/agents_api/activities/task_steps/get_value_step.py delete mode 100644 sdks/ts/src/api/models/Tools_FunctionTool.ts delete mode 100644 sdks/ts/src/api/schemas/$Tools_FunctionTool.ts diff --git a/.github/workflows/changelog-ci.yml b/.github/workflows/changelog-ci.yml index 11ea4fc95..2a1ab6c30 100644 --- a/.github/workflows/changelog-ci.yml +++ b/.github/workflows/changelog-ci.yml @@ -1,5 +1,6 @@ name: Changelog CI +# TODO: This is currently not working. Need to fix it on: pull_request: types: [ opened, synchronize ] diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index 74acd372e..9c6952e6e 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -1,6 +1,7 @@ name: Generate docs on merge to dev run-name: ${{ github.actor }} is generating documentation +# TODO: This is currently not working. Need to fix it on: push: branches: diff --git a/.github/workflows/lint-and-format.yml b/.github/workflows/lint-and-format.yml index a58ec8737..e99febeaa 100644 --- a/.github/workflows/lint-and-format.yml +++ b/.github/workflows/lint-and-format.yml @@ -1,6 +1,7 @@ name: Lint and typecheck APIs and SDKs run-name: ${{ github.actor }} is linting and typechecking the code +# TODO: This is currently not working. Need to fix it on: [pull_request] jobs: diff --git a/.github/workflows/push-to-hub.yml b/.github/workflows/push-to-hub.yml index 9e8b6a428..ee848d755 100644 --- a/.github/workflows/push-to-hub.yml +++ b/.github/workflows/push-to-hub.yml @@ -1,6 +1,7 @@ name: Build and push images to docker hub on merge to dev run-name: ${{ github.actor }} is building and pushing images to docker hub +# TODO: This is currently not working. Need to fix it on: push: branches: diff --git a/agents-api/agents_api/activities/task_steps/__init__.py b/agents-api/agents_api/activities/task_steps/__init__.py index 132a40d34..573884629 100644 --- a/agents-api/agents_api/activities/task_steps/__init__.py +++ b/agents-api/agents_api/activities/task_steps/__init__.py @@ -4,6 +4,7 @@ from .cozo_query_step import cozo_query_step from .evaluate_step import evaluate_step from .for_each_step import for_each_step +from .get_value_step import get_value_step from .if_else_step import if_else_step from .log_step import log_step from .map_reduce_step import map_reduce_step diff --git a/agents-api/agents_api/activities/task_steps/get_value_step.py b/agents-api/agents_api/activities/task_steps/get_value_step.py new file mode 100644 index 000000000..ab59840c4 --- /dev/null +++ b/agents-api/agents_api/activities/task_steps/get_value_step.py @@ -0,0 +1,26 @@ +from typing import Any + +from beartype import beartype +from temporalio import activity + +from ...activities.utils import simple_eval_dict +from ...common.protocol.tasks import StepContext, StepOutcome +from ...env import testing + + +# TODO: We should use this step to query the parent workflow and get the value from the workflow context +@beartype +async def get_value_step( + context: StepContext, + key: str, +) -> StepOutcome: + raise NotImplementedError("Not implemented yet") + + +# Note: This is here just for clarity. We could have just imported get_value_step directly +# They do the same thing, so we dont need to mock the get_value_step function +mock_get_value_step = get_value_step + +get_value_step = activity.defn(name="get_value_step")( + get_value_step if not testing else mock_get_value_step +) diff --git a/agents-api/agents_api/activities/task_steps/set_value_step.py b/agents-api/agents_api/activities/task_steps/set_value_step.py index f9d5ecb2c..8a0823755 100644 --- a/agents-api/agents_api/activities/task_steps/set_value_step.py +++ b/agents-api/agents_api/activities/task_steps/set_value_step.py @@ -8,6 +8,7 @@ from ...env import testing +# TODO: We should use this step to signal to the parent workflow and set the value on the workflow context @beartype async def set_value_step( context: StepContext, diff --git a/agents-api/agents_api/autogen/Chat.py b/agents-api/agents_api/autogen/Chat.py index 849ff0f2e..1af7018f6 100644 --- a/agents-api/agents_api/autogen/Chat.py +++ b/agents-api/agents_api/autogen/Chat.py @@ -10,7 +10,7 @@ from .Common import LogitBias from .Docs import DocReference -from .Tools import FunctionTool, NamedToolChoice +from .Tools import NamedToolChoice, Tool class BaseChatOutput(BaseModel): @@ -71,7 +71,7 @@ class ChatInputData(BaseModel): """ A list of new input messages comprising the conversation so far. """ - tools: list[FunctionTool] = [] + tools: list[Tool] = [] """ (Advanced) List of tools that are provided in addition to agent's default set of tools. """ diff --git a/agents-api/agents_api/autogen/Tools.py b/agents-api/agents_api/autogen/Tools.py index b28334041..21ba2f7ea 100644 --- a/agents-api/agents_api/autogen/Tools.py +++ b/agents-api/agents_api/autogen/Tools.py @@ -36,7 +36,7 @@ class CreateToolRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - type: Literal["function", "integration", "system", "api_call"] + type: Literal["function", "integration", "system", "api_call"] = "function" """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ @@ -44,7 +44,11 @@ class CreateToolRequest(BaseModel): """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ - function: FunctionDef | None = None + background: Literal[False] = False + function: FunctionDef + """ + The function to call + """ integration: Any | None = None system: Any | None = None api_call: Any | None = None @@ -111,7 +115,7 @@ class PatchToolRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - type: Literal["function", "integration", "system", "api_call"] | None = None + type: Literal["function", "integration", "system", "api_call"] = "function" """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ @@ -119,7 +123,11 @@ class PatchToolRequest(BaseModel): """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ + background: Literal[False] = False function: FunctionDef | None = None + """ + The function to call + """ integration: Any | None = None system: Any | None = None api_call: Any | None = None @@ -129,7 +137,7 @@ class Tool(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - type: Literal["function", "integration", "system", "api_call"] + type: Literal["function", "integration", "system", "api_call"] = "function" """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ @@ -137,7 +145,11 @@ class Tool(BaseModel): """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ - function: FunctionDef | None = None + background: Literal[False] = False + function: FunctionDef + """ + The function to call + """ integration: Any | None = None system: Any | None = None api_call: Any | None = None @@ -171,7 +183,7 @@ class UpdateToolRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - type: Literal["function", "integration", "system", "api_call"] + type: Literal["function", "integration", "system", "api_call"] = "function" """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ @@ -179,7 +191,11 @@ class UpdateToolRequest(BaseModel): """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ - function: FunctionDef | None = None + background: Literal[False] = False + function: FunctionDef + """ + The function to call + """ integration: Any | None = None system: Any | None = None api_call: Any | None = None @@ -196,18 +212,6 @@ class ChosenFunctionCall(ChosenToolCall): """ -class FunctionTool(Tool): - model_config = ConfigDict( - populate_by_name=True, - ) - type: Literal["function"] = "function" - background: Literal[False] = False - function: FunctionDef - """ - The function to call - """ - - class NamedFunctionChoice(NamedToolChoice): model_config = ConfigDict( populate_by_name=True, diff --git a/agents-api/agents_api/routers/tasks/stream_transitions_events.py b/agents-api/agents_api/routers/tasks/stream_transitions_events.py index 9be7f67f2..92af98860 100644 --- a/agents-api/agents_api/routers/tasks/stream_transitions_events.py +++ b/agents-api/agents_api/routers/tasks/stream_transitions_events.py @@ -34,6 +34,7 @@ async def event_publisher( async with inner_send_chan: try: async for event in history_events: + # TODO: We should get the workflow-completed event as well and use that to close the stream if event.event_type == EventType.EVENT_TYPE_ACTIVITY_TASK_COMPLETED: payloads = ( event.activity_task_completed_event_attributes.result.payloads @@ -51,7 +52,6 @@ async def event_publisher( continue # FIXME: This does NOT return the last event (and maybe other events) - # Need to fix this. I think we need to grab events from child workflows too transition_event_dict = dict( type=data_item.type, output=data_item.output, @@ -92,6 +92,7 @@ async def stream_transitions_events( execution_id=execution_id, ) + # TODO: Need to get all the events for child workflows too. Maybe try the `run_id` or something? workflow_handle = await get_workflow_handle( handle_id=temporal_data["id"], ) diff --git a/agents-api/poetry.lock b/agents-api/poetry.lock index e91ee6c97..ae11ef24b 100644 --- a/agents-api/poetry.lock +++ b/agents-api/poetry.lock @@ -3810,13 +3810,13 @@ tornado = ["tornado (>=6)"] [[package]] name = "setuptools" -version = "74.1.0" +version = "74.1.1" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-74.1.0-py3-none-any.whl", hash = "sha256:cee604bd76cc092355a4e43ec17aee5369095974f41f088676724dc6bc2c9ef8"}, - {file = "setuptools-74.1.0.tar.gz", hash = "sha256:bea195a800f510ba3a2bc65645c88b7e016fe36709fefc58a880c4ae8a0138d7"}, + {file = "setuptools-74.1.1-py3-none-any.whl", hash = "sha256:fc91b5f89e392ef5b77fe143b17e32f65d3024744fba66dc3afe07201684d766"}, + {file = "setuptools-74.1.1.tar.gz", hash = "sha256:2353af060c06388be1cecbf5953dcdb1f38362f87a2356c480b6b4d5fcfc8847"}, ] [package.extras] diff --git a/embedding-service/docker-compose.yml b/embedding-service/docker-compose.yml index fc732be07..0e7f1cf93 100644 --- a/embedding-service/docker-compose.yml +++ b/embedding-service/docker-compose.yml @@ -33,6 +33,7 @@ x--shared-environment: &shared-environment TRUNCATE_EMBED_TEXT: ${TRUNCATE_EMBED_TEXT:-True} WORKER_URL: ${WORKER_URL:-temporal:7233} +# TODO: We should switch to Alibaba-NLP/gte-Qwen2-1.5B-instruct instead of gte-large-en-v1.5 services: text-embeddings-inference-cpu: diff --git a/sdks/python/poetry.lock b/sdks/python/poetry.lock index 4f56c476d..1e9fe2f95 100644 --- a/sdks/python/poetry.lock +++ b/sdks/python/poetry.lock @@ -2931,13 +2931,13 @@ win32 = ["pywin32"] [[package]] name = "setuptools" -version = "74.1.0" +version = "74.1.1" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-74.1.0-py3-none-any.whl", hash = "sha256:cee604bd76cc092355a4e43ec17aee5369095974f41f088676724dc6bc2c9ef8"}, - {file = "setuptools-74.1.0.tar.gz", hash = "sha256:bea195a800f510ba3a2bc65645c88b7e016fe36709fefc58a880c4ae8a0138d7"}, + {file = "setuptools-74.1.1-py3-none-any.whl", hash = "sha256:fc91b5f89e392ef5b77fe143b17e32f65d3024744fba66dc3afe07201684d766"}, + {file = "setuptools-74.1.1.tar.gz", hash = "sha256:2353af060c06388be1cecbf5953dcdb1f38362f87a2356c480b6b4d5fcfc8847"}, ] [package.extras] diff --git a/sdks/ts/src/api/index.ts b/sdks/ts/src/api/index.ts index 6c59c5aa7..e54e51806 100644 --- a/sdks/ts/src/api/index.ts +++ b/sdks/ts/src/api/index.ts @@ -126,7 +126,6 @@ export type { Tools_ChosenToolCall } from "./models/Tools_ChosenToolCall"; export type { Tools_CreateToolRequest } from "./models/Tools_CreateToolRequest"; export type { Tools_FunctionCallOption } from "./models/Tools_FunctionCallOption"; export type { Tools_FunctionDef } from "./models/Tools_FunctionDef"; -export type { Tools_FunctionTool } from "./models/Tools_FunctionTool"; export type { Tools_NamedFunctionChoice } from "./models/Tools_NamedFunctionChoice"; export type { Tools_NamedToolChoice } from "./models/Tools_NamedToolChoice"; export type { Tools_PatchToolRequest } from "./models/Tools_PatchToolRequest"; @@ -257,7 +256,6 @@ export { $Tools_ChosenToolCall } from "./schemas/$Tools_ChosenToolCall"; export { $Tools_CreateToolRequest } from "./schemas/$Tools_CreateToolRequest"; export { $Tools_FunctionCallOption } from "./schemas/$Tools_FunctionCallOption"; export { $Tools_FunctionDef } from "./schemas/$Tools_FunctionDef"; -export { $Tools_FunctionTool } from "./schemas/$Tools_FunctionTool"; export { $Tools_NamedFunctionChoice } from "./schemas/$Tools_NamedFunctionChoice"; export { $Tools_NamedToolChoice } from "./schemas/$Tools_NamedToolChoice"; export { $Tools_PatchToolRequest } from "./schemas/$Tools_PatchToolRequest"; diff --git a/sdks/ts/src/api/models/Chat_ChatInputData.ts b/sdks/ts/src/api/models/Chat_ChatInputData.ts index a30958cc1..34cfbaa56 100644 --- a/sdks/ts/src/api/models/Chat_ChatInputData.ts +++ b/sdks/ts/src/api/models/Chat_ChatInputData.ts @@ -3,8 +3,8 @@ /* tslint:disable */ /* eslint-disable */ import type { Entries_ChatMLRole } from "./Entries_ChatMLRole"; -import type { Tools_FunctionTool } from "./Tools_FunctionTool"; import type { Tools_NamedToolChoice } from "./Tools_NamedToolChoice"; +import type { Tools_Tool } from "./Tools_Tool"; export type Chat_ChatInputData = { /** * A list of new input messages comprising the conversation so far. @@ -30,7 +30,7 @@ export type Chat_ChatInputData = { /** * (Advanced) List of tools that are provided in addition to agent's default set of tools. */ - tools: Array; + tools: Array; /** * Can be one of existing tools given to the agent earlier or the ones provided in this request. */ diff --git a/sdks/ts/src/api/models/Tools_CreateToolRequest.ts b/sdks/ts/src/api/models/Tools_CreateToolRequest.ts index 51024282c..b6f898e2b 100644 --- a/sdks/ts/src/api/models/Tools_CreateToolRequest.ts +++ b/sdks/ts/src/api/models/Tools_CreateToolRequest.ts @@ -17,7 +17,11 @@ export type Tools_CreateToolRequest = { * Name of the tool (must be unique for this agent and a valid python identifier string ) */ name: Common_validPythonIdentifier; - function?: Tools_FunctionDef; + background: boolean; + /** + * The function to call + */ + function: Tools_FunctionDef; integration?: any; system?: any; api_call?: any; diff --git a/sdks/ts/src/api/models/Tools_FunctionTool.ts b/sdks/ts/src/api/models/Tools_FunctionTool.ts deleted file mode 100644 index 37e2e713f..000000000 --- a/sdks/ts/src/api/models/Tools_FunctionTool.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { Tools_FunctionDef } from "./Tools_FunctionDef"; -import type { Tools_Tool } from "./Tools_Tool"; -export type Tools_FunctionTool = Tools_Tool & { - function: Tools_FunctionDef; - type: "function"; - background: boolean; - /** - * The function to call - */ - function: Tools_FunctionDef; -}; diff --git a/sdks/ts/src/api/models/Tools_PatchToolRequest.ts b/sdks/ts/src/api/models/Tools_PatchToolRequest.ts index 6ab88a01f..2f7f1c740 100644 --- a/sdks/ts/src/api/models/Tools_PatchToolRequest.ts +++ b/sdks/ts/src/api/models/Tools_PatchToolRequest.ts @@ -17,6 +17,10 @@ export type Tools_PatchToolRequest = { * Name of the tool (must be unique for this agent and a valid python identifier string ) */ name?: Common_validPythonIdentifier; + background?: boolean; + /** + * The function to call + */ function?: Tools_FunctionDef; integration?: any; system?: any; diff --git a/sdks/ts/src/api/models/Tools_Tool.ts b/sdks/ts/src/api/models/Tools_Tool.ts index d2b4e9dba..1f493710e 100644 --- a/sdks/ts/src/api/models/Tools_Tool.ts +++ b/sdks/ts/src/api/models/Tools_Tool.ts @@ -15,7 +15,11 @@ export type Tools_Tool = { * Name of the tool (must be unique for this agent and a valid python identifier string ) */ name: Common_validPythonIdentifier; - function?: Tools_FunctionDef; + background: boolean; + /** + * The function to call + */ + function: Tools_FunctionDef; integration?: any; system?: any; api_call?: any; diff --git a/sdks/ts/src/api/models/Tools_UpdateToolRequest.ts b/sdks/ts/src/api/models/Tools_UpdateToolRequest.ts index 6a964fc8c..00c7808e9 100644 --- a/sdks/ts/src/api/models/Tools_UpdateToolRequest.ts +++ b/sdks/ts/src/api/models/Tools_UpdateToolRequest.ts @@ -17,7 +17,11 @@ export type Tools_UpdateToolRequest = { * Name of the tool (must be unique for this agent and a valid python identifier string ) */ name: Common_validPythonIdentifier; - function?: Tools_FunctionDef; + background: boolean; + /** + * The function to call + */ + function: Tools_FunctionDef; integration?: any; system?: any; api_call?: any; diff --git a/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts b/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts index 7bbc76a72..ed8168884 100644 --- a/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts +++ b/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts @@ -49,7 +49,7 @@ export const $Chat_ChatInputData = { tools: { type: "array", contains: { - type: "Tools_FunctionTool", + type: "Tools_Tool", }, isRequired: true, }, diff --git a/sdks/ts/src/api/schemas/$Tools_CreateToolRequest.ts b/sdks/ts/src/api/schemas/$Tools_CreateToolRequest.ts index bea3b4740..9430480b5 100644 --- a/sdks/ts/src/api/schemas/$Tools_CreateToolRequest.ts +++ b/sdks/ts/src/api/schemas/$Tools_CreateToolRequest.ts @@ -25,8 +25,19 @@ export const $Tools_CreateToolRequest = { ], isRequired: true, }, + background: { + type: "boolean", + isRequired: true, + }, function: { - type: "Tools_FunctionDef", + type: "all-of", + description: `The function to call`, + contains: [ + { + type: "Tools_FunctionDef", + }, + ], + isRequired: true, }, integration: { properties: {}, diff --git a/sdks/ts/src/api/schemas/$Tools_FunctionTool.ts b/sdks/ts/src/api/schemas/$Tools_FunctionTool.ts deleted file mode 100644 index 382bc923b..000000000 --- a/sdks/ts/src/api/schemas/$Tools_FunctionTool.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $Tools_FunctionTool = { - type: "all-of", - contains: [ - { - type: "Tools_Tool", - }, - { - properties: { - function: { - type: "Tools_FunctionDef", - isRequired: true, - }, - type: { - type: "Enum", - isRequired: true, - }, - background: { - type: "boolean", - isRequired: true, - }, - function: { - type: "all-of", - description: `The function to call`, - contains: [ - { - type: "Tools_FunctionDef", - }, - ], - isRequired: true, - }, - }, - }, - ], -} as const; diff --git a/sdks/ts/src/api/schemas/$Tools_PatchToolRequest.ts b/sdks/ts/src/api/schemas/$Tools_PatchToolRequest.ts index 316eccd14..507c5f971 100644 --- a/sdks/ts/src/api/schemas/$Tools_PatchToolRequest.ts +++ b/sdks/ts/src/api/schemas/$Tools_PatchToolRequest.ts @@ -23,8 +23,17 @@ export const $Tools_PatchToolRequest = { }, ], }, + background: { + type: "boolean", + }, function: { - type: "Tools_FunctionDef", + type: "all-of", + description: `The function to call`, + contains: [ + { + type: "Tools_FunctionDef", + }, + ], }, integration: { properties: {}, diff --git a/sdks/ts/src/api/schemas/$Tools_Tool.ts b/sdks/ts/src/api/schemas/$Tools_Tool.ts index 2785b6a28..1f6ff2a76 100644 --- a/sdks/ts/src/api/schemas/$Tools_Tool.ts +++ b/sdks/ts/src/api/schemas/$Tools_Tool.ts @@ -24,8 +24,19 @@ export const $Tools_Tool = { ], isRequired: true, }, + background: { + type: "boolean", + isRequired: true, + }, function: { - type: "Tools_FunctionDef", + type: "all-of", + description: `The function to call`, + contains: [ + { + type: "Tools_FunctionDef", + }, + ], + isRequired: true, }, integration: { properties: {}, diff --git a/sdks/ts/src/api/schemas/$Tools_UpdateToolRequest.ts b/sdks/ts/src/api/schemas/$Tools_UpdateToolRequest.ts index 4e8373fbf..bd3c37b6e 100644 --- a/sdks/ts/src/api/schemas/$Tools_UpdateToolRequest.ts +++ b/sdks/ts/src/api/schemas/$Tools_UpdateToolRequest.ts @@ -25,8 +25,19 @@ export const $Tools_UpdateToolRequest = { ], isRequired: true, }, + background: { + type: "boolean", + isRequired: true, + }, function: { - type: "Tools_FunctionDef", + type: "all-of", + description: `The function to call`, + contains: [ + { + type: "Tools_FunctionDef", + }, + ], + isRequired: true, }, integration: { properties: {}, diff --git a/typespec/chat/models.tsp b/typespec/chat/models.tsp index ffce16ce2..3ebe62623 100644 --- a/typespec/chat/models.tsp +++ b/typespec/chat/models.tsp @@ -159,7 +159,7 @@ model ChatInputData { messages: InputChatMLMessage[]; /** (Advanced) List of tools that are provided in addition to agent's default set of tools. */ - tools: FunctionTool[] = #[]; + tools: Tool[] = #[]; /** Can be one of existing tools given to the agent earlier or the ones provided in this request. */ tool_choice?: ToolChoiceOption; diff --git a/typespec/tools/models.tsp b/typespec/tools/models.tsp index 1938611c9..bb31b5ca8 100644 --- a/typespec/tools/models.tsp +++ b/typespec/tools/models.tsp @@ -42,15 +42,17 @@ model FunctionDef { } -@discriminator("type") +// TODO: We should use this model for all tools, not just functions and discriminate on the type model Tool { /** Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) */ - type: ToolType; + type: ToolType = ToolType.function; /** Name of the tool (must be unique for this agent and a valid python identifier string )*/ name: validPythonIdentifier; + background: false = false; - function?: FunctionDef; + /** The function to call */ + function: FunctionDef; integration?: unknown; system?: unknown; api_call?: unknown; @@ -59,14 +61,6 @@ model Tool { ...HasId; } -model FunctionTool extends Tool { - type: ToolType.function; - background: false = false; - - /** The function to call */ - function: FunctionDef; -} - model FunctionCallOption { /** The name of the function */ name: string;