diff --git a/.changeset/big-mayflies-begin.md b/.changeset/big-mayflies-begin.md new file mode 100644 index 00000000..fae05a98 --- /dev/null +++ b/.changeset/big-mayflies-begin.md @@ -0,0 +1,5 @@ +--- +'@sap-ai-sdk/orchestration': minor +--- + +Update orchestration to 2501a release. diff --git a/packages/orchestration/src/client/api/schema/azure-content-safety-filter-config.ts b/packages/orchestration/src/client/api/schema/azure-content-safety-filter-config.ts index 33afacfc..764c7b3c 100644 --- a/packages/orchestration/src/client/api/schema/azure-content-safety-filter-config.ts +++ b/packages/orchestration/src/client/api/schema/azure-content-safety-filter-config.ts @@ -9,7 +9,7 @@ import type { AzureContentSafety } from './azure-content-safety.js'; */ export type AzureContentSafetyFilterConfig = { /** - * String represents name of the filter provider + * Name of the filter provider type * @example "azure_content_safety" */ type: 'azure_content_safety'; diff --git a/packages/orchestration/src/client/api/schema/chat-completion-tool.ts b/packages/orchestration/src/client/api/schema/chat-completion-tool.ts new file mode 100644 index 00000000..da6247c5 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/chat-completion-tool.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +import type { FunctionObject } from './function-object.js'; +/** + * Representation of the 'ChatCompletionTool' schema. + */ +export type ChatCompletionTool = { + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: 'function'; + function: FunctionObject; +}; diff --git a/packages/orchestration/src/client/api/schema/chat-delta.ts b/packages/orchestration/src/client/api/schema/chat-delta.ts index 598312d0..92a134b5 100644 --- a/packages/orchestration/src/client/api/schema/chat-delta.ts +++ b/packages/orchestration/src/client/api/schema/chat-delta.ts @@ -3,11 +3,16 @@ * * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ - +import type { ToolCallChunk } from './tool-call-chunk.js'; /** * Representation of the 'ChatDelta' schema. */ export type ChatDelta = { role?: string; content: string; + /** + * The refusal message generated by the model. + */ + refusal?: string; + tool_calls?: ToolCallChunk[]; } & Record; diff --git a/packages/orchestration/src/client/api/schema/chat-message.ts b/packages/orchestration/src/client/api/schema/chat-message.ts index 701e1d03..bea7e65b 100644 --- a/packages/orchestration/src/client/api/schema/chat-message.ts +++ b/packages/orchestration/src/client/api/schema/chat-message.ts @@ -3,14 +3,9 @@ * * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ - +import type { SingleChatMessage } from './single-chat-message.js'; +import type { MultiChatMessage } from './multi-chat-message.js'; /** * Representation of the 'ChatMessage' schema. */ -export type ChatMessage = { - /** - * @example "user" - */ - role: string; - content: string; -}; +export type ChatMessage = SingleChatMessage | MultiChatMessage; diff --git a/packages/orchestration/src/client/api/schema/chat-messages.ts b/packages/orchestration/src/client/api/schema/chat-messages.ts index 86a125bf..6205abaa 100644 --- a/packages/orchestration/src/client/api/schema/chat-messages.ts +++ b/packages/orchestration/src/client/api/schema/chat-messages.ts @@ -4,8 +4,7 @@ * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ import type { ChatMessage } from './chat-message.js'; -import type { MultiChatMessage } from './multi-chat-message.js'; /** * Representation of the 'ChatMessages' schema. */ -export type ChatMessages = (ChatMessage | MultiChatMessage)[]; +export type ChatMessages = ChatMessage[]; diff --git a/packages/orchestration/src/client/api/schema/data-repository-type.ts b/packages/orchestration/src/client/api/schema/data-repository-type.ts index cb5e3662..ef1e65f2 100644 --- a/packages/orchestration/src/client/api/schema/data-repository-type.ts +++ b/packages/orchestration/src/client/api/schema/data-repository-type.ts @@ -5,6 +5,6 @@ */ /** - * Representation of the 'DataRepositoryType' schema. + * Only include DataRepositories with the given type. */ -export type DataRepositoryType = 'vector' | any; +export type DataRepositoryType = 'vector' | 'help.sap.com' | any; diff --git a/packages/orchestration/src/client/api/schema/dpi-config.ts b/packages/orchestration/src/client/api/schema/dpi-config.ts index 44667022..d0f574e0 100644 --- a/packages/orchestration/src/client/api/schema/dpi-config.ts +++ b/packages/orchestration/src/client/api/schema/dpi-config.ts @@ -34,5 +34,5 @@ export type DpiConfig = { * controls whether the input to the grounding module will be masked with the configuration supplied in the masking module */ enabled?: boolean; - } & Record; + }; }; diff --git a/packages/orchestration/src/client/api/schema/filter-config.ts b/packages/orchestration/src/client/api/schema/filter-config.ts index c8280014..4f0ec75c 100644 --- a/packages/orchestration/src/client/api/schema/filter-config.ts +++ b/packages/orchestration/src/client/api/schema/filter-config.ts @@ -4,7 +4,10 @@ * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ import type { AzureContentSafetyFilterConfig } from './azure-content-safety-filter-config.js'; +import type { LlamaGuard38BFilterConfig } from './llama-guard-38-b-filter-config.js'; /** * Representation of the 'FilterConfig' schema. */ -export type FilterConfig = AzureContentSafetyFilterConfig; +export type FilterConfig = + | AzureContentSafetyFilterConfig + | LlamaGuard38BFilterConfig; diff --git a/packages/orchestration/src/client/api/schema/function-object.ts b/packages/orchestration/src/client/api/schema/function-object.ts new file mode 100644 index 00000000..8461a122 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/function-object.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +import type { FunctionParameters } from './function-parameters.js'; +/** + * Representation of the 'FunctionObject' schema. + */ +export type FunctionObject = { + /** + * A description of what the function does, used by the model to choose when and how to call the function. + */ + description?: string; + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + */ + name: string; + parameters?: FunctionParameters; + /** + * Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). + */ + strict?: boolean | null; +}; diff --git a/packages/orchestration/src/client/api/schema/function-parameters.ts b/packages/orchestration/src/client/api/schema/function-parameters.ts new file mode 100644 index 00000000..2f60959b --- /dev/null +++ b/packages/orchestration/src/client/api/schema/function-parameters.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. Omitting `parameters` defines a function with an empty parameter list. + */ +export type FunctionParameters = Record; diff --git a/packages/orchestration/src/client/api/schema/grounding-filter-search-configuration.ts b/packages/orchestration/src/client/api/schema/grounding-filter-search-configuration.ts index cdc25cc6..3dd06bc0 100644 --- a/packages/orchestration/src/client/api/schema/grounding-filter-search-configuration.ts +++ b/packages/orchestration/src/client/api/schema/grounding-filter-search-configuration.ts @@ -11,9 +11,9 @@ export type GroundingFilterSearchConfiguration = { /** * Maximum number of chunks to be returned. Cannot be used with 'maxDocumentCount'. */ - max_chunk_count?: number | null; + max_chunk_count?: number; /** * [Only supports 'vector' dataRepositoryType] - Maximum number of documents to be returned. Cannot be used with 'maxChunkCount'. If maxDocumentCount is given, then only one chunk per document is returned. */ - max_document_count?: number | null; -} | null; + max_document_count?: number; +}; diff --git a/packages/orchestration/src/client/api/schema/image-content.ts b/packages/orchestration/src/client/api/schema/image-content.ts index 3029bb98..b6a21b3d 100644 --- a/packages/orchestration/src/client/api/schema/image-content.ts +++ b/packages/orchestration/src/client/api/schema/image-content.ts @@ -15,5 +15,5 @@ export type ImageContent = { * Default: "auto". */ detail?: string; - } & Record; -} & Record; + }; +}; diff --git a/packages/orchestration/src/client/api/schema/index.ts b/packages/orchestration/src/client/api/schema/index.ts index e7d70224..69c74a75 100644 --- a/packages/orchestration/src/client/api/schema/index.ts +++ b/packages/orchestration/src/client/api/schema/index.ts @@ -4,14 +4,19 @@ * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ export * from './completion-post-request.js'; +export * from './chat-message.js'; export * from './chat-messages.js'; export * from './templating-chat-message.js'; -export * from './chat-message.js'; +export * from './single-chat-message.js'; +export * from './response-chat-message.js'; +export * from './response-message-tool-calls.js'; +export * from './response-message-tool-call.js'; export * from './multi-chat-message.js'; export * from './multi-chat-message-content.js'; export * from './text-content.js'; export * from './image-content.js'; export * from './chat-delta.js'; +export * from './tool-call-chunk.js'; export * from './completion-post-response.js'; export * from './completion-post-response-streaming.js'; export * from './orchestration-config.js'; @@ -28,6 +33,13 @@ export * from './llm-choice-streaming.js'; export * from './token-usage.js'; export * from './templating-module-config.js'; export * from './template.js'; +export * from './response-format-text.js'; +export * from './response-format-json-object.js'; +export * from './response-format-json-schema.js'; +export * from './response-format-json-schema-schema.js'; +export * from './chat-completion-tool.js'; +export * from './function-object.js'; +export * from './function-parameters.js'; export * from './template-ref.js'; export * from './template-ref-by-id.js'; export * from './template-ref-by-scenario-name-version.js'; @@ -39,6 +51,8 @@ export * from './filter-config.js'; export * from './azure-content-safety-filter-config.js'; export * from './azure-content-safety.js'; export * from './azure-threshold.js'; +export * from './llama-guard-38-b-filter-config.js'; +export * from './llama-guard-38-b.js'; export * from './masking-module-config.js'; export * from './masking-provider-config.js'; export * from './dpi-config.js'; diff --git a/packages/orchestration/src/client/api/schema/llama-guard-38-b-filter-config.ts b/packages/orchestration/src/client/api/schema/llama-guard-38-b-filter-config.ts new file mode 100644 index 00000000..77ef062b --- /dev/null +++ b/packages/orchestration/src/client/api/schema/llama-guard-38-b-filter-config.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +import type { LlamaGuard38B } from './llama-guard-38-b.js'; +/** + * Representation of the 'LlamaGuard38BFilterConfig' schema. + */ +export type LlamaGuard38BFilterConfig = { + /** + * Name of the filter provider type + * @example "llama_guard_3_8b" + */ + type: 'llama_guard_3_8b'; + config: LlamaGuard38B; +} & Record; diff --git a/packages/orchestration/src/client/api/schema/llama-guard-38-b.ts b/packages/orchestration/src/client/api/schema/llama-guard-38-b.ts new file mode 100644 index 00000000..dd777692 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/llama-guard-38-b.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Filter configuration for Llama Guard 3 8B + */ +export type LlamaGuard38B = { + violent_crimes?: boolean; + non_violent_crimes?: boolean; + sex_crimes?: boolean; + child_exploitation?: boolean; + defamation?: boolean; + specialized_advice?: boolean; + privacy?: boolean; + intellectual_property?: boolean; + indiscriminate_weapons?: boolean; + hate?: boolean; + self_harm?: boolean; + sexual_content?: boolean; + elections?: boolean; + code_interpreter_abuse?: boolean; +}; diff --git a/packages/orchestration/src/client/api/schema/llm-choice.ts b/packages/orchestration/src/client/api/schema/llm-choice.ts index 1fc589af..16aeed0b 100644 --- a/packages/orchestration/src/client/api/schema/llm-choice.ts +++ b/packages/orchestration/src/client/api/schema/llm-choice.ts @@ -3,7 +3,7 @@ * * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ -import type { ChatMessage } from './chat-message.js'; +import type { ResponseChatMessage } from './response-chat-message.js'; /** * Representation of the 'LlmChoice' schema. */ @@ -12,7 +12,7 @@ export type LlmChoice = { * Index of the choice */ index: number; - message: ChatMessage; + message: ResponseChatMessage; /** * Log probabilities */ diff --git a/packages/orchestration/src/client/api/schema/multi-chat-message.ts b/packages/orchestration/src/client/api/schema/multi-chat-message.ts index 2ad05856..5b914cb5 100644 --- a/packages/orchestration/src/client/api/schema/multi-chat-message.ts +++ b/packages/orchestration/src/client/api/schema/multi-chat-message.ts @@ -13,4 +13,4 @@ export type MultiChatMessage = { */ role: string; content: MultiChatMessageContent[]; -} & Record; +}; diff --git a/packages/orchestration/src/client/api/schema/response-chat-message.ts b/packages/orchestration/src/client/api/schema/response-chat-message.ts new file mode 100644 index 00000000..aa4cc76d --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-chat-message.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +import type { SingleChatMessage } from './single-chat-message.js'; +import type { ResponseMessageToolCalls } from './response-message-tool-calls.js'; +/** + * Representation of the 'ResponseChatMessage' schema. + */ +export type ResponseChatMessage = SingleChatMessage & { + /** + * @example "I'm sorry, I can't answer that question." + */ + refusal?: string; + tool_calls?: ResponseMessageToolCalls; +}; diff --git a/packages/orchestration/src/client/api/schema/response-format-json-object.ts b/packages/orchestration/src/client/api/schema/response-format-json-object.ts new file mode 100644 index 00000000..4ba02611 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-format-json-object.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Representation of the 'ResponseFormatJsonObject' schema. + */ +export type ResponseFormatJsonObject = { + /** + * The type of response format being defined: `json_object` + */ + type: 'json_object'; +}; diff --git a/packages/orchestration/src/client/api/schema/response-format-json-schema-schema.ts b/packages/orchestration/src/client/api/schema/response-format-json-schema-schema.ts new file mode 100644 index 00000000..8ca5fe15 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-format-json-schema-schema.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The schema for the response format, described as a JSON Schema object. + */ +export type ResponseFormatJsonSchemaSchema = Record; diff --git a/packages/orchestration/src/client/api/schema/response-format-json-schema.ts b/packages/orchestration/src/client/api/schema/response-format-json-schema.ts new file mode 100644 index 00000000..93fa2f6c --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-format-json-schema.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +import type { ResponseFormatJsonSchemaSchema } from './response-format-json-schema-schema.js'; +/** + * Representation of the 'ResponseFormatJsonSchema' schema. + */ +export type ResponseFormatJsonSchema = { + /** + * The type of response format being defined: `json_schema` + */ + type: 'json_schema'; + json_schema: { + /** + * A description of what the response format is for, used by the model to determine how to respond in the format. + */ + description?: string; + /** + * The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + */ + name: string; + schema?: ResponseFormatJsonSchemaSchema; + /** + * Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + */ + strict?: boolean | null; + }; +}; diff --git a/packages/orchestration/src/client/api/schema/response-format-text.ts b/packages/orchestration/src/client/api/schema/response-format-text.ts new file mode 100644 index 00000000..b752705c --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-format-text.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Representation of the 'ResponseFormatText' schema. + */ +export type ResponseFormatText = { + /** + * The type of response format being defined: `text` + */ + type: 'text'; +}; diff --git a/packages/orchestration/src/client/api/schema/response-message-tool-call.ts b/packages/orchestration/src/client/api/schema/response-message-tool-call.ts new file mode 100644 index 00000000..aefe503b --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-message-tool-call.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Representation of the 'ResponseMessageToolCall' schema. + */ +export type ResponseMessageToolCall = { + /** + * The ID of the tool call. + */ + id: string; + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: 'function'; + /** + * The function that the model called. + */ + function: { + /** + * The name of the function to call. + */ + name: string; + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + */ + arguments: string; + } & Record; +} & Record; diff --git a/packages/orchestration/src/client/api/schema/response-message-tool-calls.ts b/packages/orchestration/src/client/api/schema/response-message-tool-calls.ts new file mode 100644 index 00000000..6aaff6b0 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/response-message-tool-calls.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +import type { ResponseMessageToolCall } from './response-message-tool-call.js'; +/** + * The tool calls generated by the model, such as function calls. + */ +export type ResponseMessageToolCalls = ResponseMessageToolCall[]; diff --git a/packages/orchestration/src/client/api/schema/single-chat-message.ts b/packages/orchestration/src/client/api/schema/single-chat-message.ts new file mode 100644 index 00000000..af96deb3 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/single-chat-message.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Representation of the 'SingleChatMessage' schema. + */ +export type SingleChatMessage = { + /** + * @example "user" + */ + role: string; + content: string; +}; diff --git a/packages/orchestration/src/client/api/schema/template.ts b/packages/orchestration/src/client/api/schema/template.ts index 361b134d..a755ac43 100644 --- a/packages/orchestration/src/client/api/schema/template.ts +++ b/packages/orchestration/src/client/api/schema/template.ts @@ -4,6 +4,10 @@ * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ import type { TemplatingChatMessage } from './templating-chat-message.js'; +import type { ResponseFormatText } from './response-format-text.js'; +import type { ResponseFormatJsonObject } from './response-format-json-object.js'; +import type { ResponseFormatJsonSchema } from './response-format-json-schema.js'; +import type { ChatCompletionTool } from './chat-completion-tool.js'; /** * Representation of the 'Template' schema. * @example { @@ -26,5 +30,19 @@ export type Template = { /** * Optional default values for the template. If a parameter has no default it is required. */ - defaults?: Record; + defaults?: Record; + /** + * Response format that the model output should adhere to. This is the same as the OpenAI definition. + * Compatible with GPT-4o, GPT-4o mini, GPT-4 (Turbo) and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. + * + */ + response_format?: + | ResponseFormatText + | ResponseFormatJsonObject + | ResponseFormatJsonSchema; + /** + * A list of tools the model may call. Used to provide a list of functions the model may generate JSON inputs for. This is the same as the OpenAI definition. + * + */ + tools?: ChatCompletionTool[]; }; diff --git a/packages/orchestration/src/client/api/schema/templating-chat-message.ts b/packages/orchestration/src/client/api/schema/templating-chat-message.ts index dc73d7c6..2e973241 100644 --- a/packages/orchestration/src/client/api/schema/templating-chat-message.ts +++ b/packages/orchestration/src/client/api/schema/templating-chat-message.ts @@ -4,9 +4,8 @@ * This is a generated file powered by the SAP Cloud SDK for JavaScript. */ import type { ChatMessage } from './chat-message.js'; -import type { MultiChatMessage } from './multi-chat-message.js'; /** * Representation of the 'TemplatingChatMessage' schema. * Min Items: 1. */ -export type TemplatingChatMessage = (ChatMessage | MultiChatMessage)[]; +export type TemplatingChatMessage = ChatMessage[]; diff --git a/packages/orchestration/src/client/api/schema/text-content.ts b/packages/orchestration/src/client/api/schema/text-content.ts index 51bf908e..4723422a 100644 --- a/packages/orchestration/src/client/api/schema/text-content.ts +++ b/packages/orchestration/src/client/api/schema/text-content.ts @@ -10,4 +10,4 @@ export type TextContent = { type: 'text'; text: string; -} & Record; +}; diff --git a/packages/orchestration/src/client/api/schema/tool-call-chunk.ts b/packages/orchestration/src/client/api/schema/tool-call-chunk.ts new file mode 100644 index 00000000..70dde4e2 --- /dev/null +++ b/packages/orchestration/src/client/api/schema/tool-call-chunk.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Representation of the 'ToolCallChunk' schema. + */ +export type ToolCallChunk = { + index: number; + /** + * The ID of the tool call. + */ + id?: string; + /** + * The type of the tool. Currently, only `function` is supported. + */ + type?: 'function'; + function?: { + /** + * The name of the function to call. + */ + name?: string; + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + */ + arguments?: string; + } & Record; +} & Record; diff --git a/packages/orchestration/src/spec/api.yaml b/packages/orchestration/src/spec/api.yaml index 4646ebba..46580ead 100644 --- a/packages/orchestration/src/spec/api.yaml +++ b/packages/orchestration/src/spec/api.yaml @@ -1,41 +1,25 @@ openapi: 3.0.0 + info: title: Orchestration description: Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. - version: 0.43.0 -x-sap-shortText: Enhance content generation with additional capabilities for business AI scenarios. + contact: + name: SAP AI Core + version: 0.48.2 + servers: - - url: https://api.ai.{region}.ml.hana.ondemand.com/v2/inference/deployments/{orchestration_deployment_id} - description: Production endpoint for SAP AI Core - variables: - region: - enum: - - prod.eu-central-1.aws - - prodeuonly.eu-central-1.aws - - prod.us-east-1.aws - - prod.ap-northeast-1.aws - - prod.ap-southeast-2.aws - - prod-eu20.westeurope.azure - - prod-us21.eastus.azure - - prod-eu30.europe-west3.gcp - - prod-us30.us-central1.gcp - default: prod.eu-central-1.aws - orchestration_deployment_id: - description: The deployment ID of the orchestration service. To be obtained from the SAP AI Core service using the deployments endpoint. - default: x111111 -externalDocs: - description: Documentation for SAP AI Core - Orchestration - url: https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/orchestration -security: - - Oauth2: [] + - url: '/v1' + tags: - - name: Orchestrated Completion + - name: OrchestrationCompletion description: Run an orchestrated completion inference request + paths: /completion: post: tags: - - Orchestrated Completion + - OrchestrationCompletion + description: Run an orchestrated completion inference request operationId: orchestration.v1.endpoints.create requestBody: required: true @@ -77,22 +61,23 @@ components: - $ref: '#/components/schemas/ChatMessages' description: History of chat messages. Can be used to provide system and assistant messages to set the context of the conversation. Will be merged with the template message + ChatMessage: + oneOf: + - $ref: '#/components/schemas/SingleChatMessage' + - $ref: '#/components/schemas/MultiChatMessage' + ChatMessages: type: array items: - oneOf: - - $ref: '#/components/schemas/ChatMessage' - - $ref: '#/components/schemas/MultiChatMessage' + $ref: '#/components/schemas/ChatMessage' TemplatingChatMessage: type: array minItems: 1 items: - oneOf: - - $ref: '#/components/schemas/ChatMessage' - - $ref: '#/components/schemas/MultiChatMessage' + $ref: '#/components/schemas/ChatMessage' - ChatMessage: + SingleChatMessage: type: object required: - role @@ -105,11 +90,64 @@ components: content: type: string + ResponseChatMessage: + allOf: + - $ref: '#/components/schemas/SingleChatMessage' + - type: object + additionalProperties: false + properties: + refusal: + type: string + example: "I'm sorry, I can't answer that question." + tool_calls: + $ref: '#/components/schemas/ResponseMessageToolCalls' + # below tool message definitions are copied from openai spec: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L11007 + # only renaming them to differentiate them from the openai python classes + ResponseMessageToolCalls: + type: array + description: The tool calls generated by the model, such as function calls. + items: + $ref: '#/components/schemas/ResponseMessageToolCall' + ResponseMessageToolCall: + type: object + properties: + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + description: The function that the model called. + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: + The arguments to call the function with, as generated by the model + in JSON format. Note that the model does not always generate + valid JSON, and may hallucinate parameters not defined by your + function schema. Validate the arguments in your code before + calling your function. + required: + - name + - arguments + required: + - id + - type + - function + MultiChatMessage: type: object required: - role - content + additionalProperties: false properties: role: type: string @@ -129,6 +167,7 @@ components: required: - type - text + additionalProperties: false properties: type: type: string @@ -141,6 +180,7 @@ components: required: - type - image_url + additionalProperties: false properties: type: type: string @@ -149,6 +189,7 @@ components: type: object required: - url + additionalProperties: false properties: url: type: string @@ -166,6 +207,43 @@ components: content: type: string default: '' + refusal: + type: string + description: The refusal message generated by the model. + tool_calls: + type: array + items: + $ref: '#/components/schemas/ToolCallChunk' + # taken from: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L10979C27-L10979C40 + ToolCallChunk: + type: object + properties: + index: + type: integer + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: + The arguments to call the function with, as generated by the model + in JSON format. Note that the model does not always generate + valid JSON, and may hallucinate parameters not defined by your + function schema. Validate the arguments in your code before + calling your function. + required: + - index CompletionPostResponse: type: object @@ -276,7 +354,7 @@ components: description: Model name as in LLM Access configuration example: 'gpt-4' type: string - model_params: + model_params: # optional, default values are used for mandatory model parameters description: Model parameters type: object example: @@ -285,6 +363,7 @@ components: frequency_penalty: 0 presence_penalty: 0 n: 2 + additionalProperties: true model_version: description: Version of the model to use type: string @@ -394,7 +473,7 @@ components: description: Index of the choice example: 0 message: - $ref: '#/components/schemas/ChatMessage' + $ref: '#/components/schemas/ResponseChatMessage' logprobs: type: object description: Log probabilities @@ -458,6 +537,8 @@ components: - $ref: '#/components/schemas/TemplateRef' # --- Templating Module with User Defined Template --- + # response_format api definition taken from: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L12286 + # tools api definition taken from: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L12406 Template: type: object required: @@ -471,6 +552,25 @@ components: defaults: description: Optional default values for the template. If a parameter has no default it is required. type: object + additionalProperties: + type: string + response_format: + description: > + Response format that the model output should adhere to. + This is the same as the OpenAI definition. + + Compatible with GPT-4o, GPT-4o mini, GPT-4 (Turbo) and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. + oneOf: + - $ref: '#/components/schemas/ResponseFormatText' + - $ref: '#/components/schemas/ResponseFormatJsonObject' + - $ref: '#/components/schemas/ResponseFormatJsonSchema' + tools: + type: array + description: > + A list of tools the model may call. Used to provide a list of functions the model may generate JSON inputs for. + This is the same as the OpenAI definition. + items: + $ref: '#/components/schemas/ChatCompletionTool' example: template: - role: user @@ -478,6 +578,129 @@ components: defaults: inputContext: The default text that will be used in the template if inputContext is not set + # below ReponseFormats are copied from openapi spec: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L12286 + ResponseFormatText: + type: object + additionalProperties: false + properties: + type: + type: string + description: 'The type of response format being defined: `text`' + enum: + - text + required: + - type + ResponseFormatJsonObject: + type: object + additionalProperties: false + properties: + type: + type: string + description: 'The type of response format being defined: `json_object`' + enum: + - json_object + required: + - type + ResponseFormatJsonSchema: + type: object + additionalProperties: false + properties: + type: + type: string + description: 'The type of response format being defined: `json_schema`' + enum: + - json_schema + json_schema: + type: object + additionalProperties: false + properties: + description: + type: string + description: + A description of what the response format is for, used by the model + to determine how to respond in the format. + name: + type: string + description: + The name of the response format. Must be a-z, A-Z, 0-9, or contain + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + default: false + description: + Whether to enable strict schema adherence when generating the + output. If set to true, the model will always follow the exact + schema defined in the `schema` field. Only a subset of JSON + Schema is supported when `strict` is `true`. To learn more, read + the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + required: + - name + required: + - type + - json_schema + ResponseFormatJsonSchemaSchema: + type: object + description: The schema for the response format, described as a JSON Schema object. + additionalProperties: true + + # below tool-related definitions are copied from openai spec: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L11547 + ChatCompletionTool: + type: object + additionalProperties: false + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/FunctionObject' + required: + - type + - function + FunctionObject: + type: object + additionalProperties: false + properties: + description: + type: string + description: + A description of what the function does, used by the model to + choose when and how to call the function. + name: + type: string + description: + The name of the function to be called. Must be a-z, A-Z, 0-9, or + contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/FunctionParameters' + strict: + type: boolean + nullable: true + default: false + description: + Whether to enable strict schema adherence when generating the + function call. If set to true, the model will follow the exact + schema defined in the `parameters` field. Only a subset of JSON + Schema is supported when `strict` is `true`. Learn more about + Structured Outputs in the [function calling + guide](docs/guides/function-calling). + required: + - name + FunctionParameters: + type: object + description: >- + The parameters the functions accepts, described as a JSON Schema object. + See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the + [JSON Schema + reference](https://json-schema.org/understanding-json-schema/) for + documentation about the format. + Omitting `parameters` defines a function with an empty parameter list. + additionalProperties: true + # --- Templating Module with reference to Prompt Registry --- TemplateRef: type: object @@ -486,7 +709,6 @@ components: additionalProperties: false properties: template_ref: - type: object description: Reference to a template in the prompt registry by ID or by scenario, name and version oneOf: - $ref: '#/components/schemas/TemplateRefByID' @@ -582,6 +804,7 @@ components: FilterConfig: oneOf: - $ref: '#/components/schemas/AzureContentSafetyFilterConfig' + - $ref: '#/components/schemas/LlamaGuard38bFilterConfig' AzureContentSafetyFilterConfig: type: object @@ -590,7 +813,7 @@ components: additionalProperties: false properties: type: - description: String represents name of the filter provider + description: Name of the filter provider type type: string enum: - azure_content_safety @@ -603,13 +826,13 @@ components: type: object additionalProperties: false properties: - 'Hate': + Hate: $ref: '#/components/schemas/AzureThreshold' - 'SelfHarm': + SelfHarm: $ref: '#/components/schemas/AzureThreshold' - 'Sexual': + Sexual: $ref: '#/components/schemas/AzureThreshold' - 'Violence': + Violence: $ref: '#/components/schemas/AzureThreshold' AzureThreshold: @@ -621,6 +844,56 @@ components: - 6 example: 0 + LlamaGuard38bFilterConfig: + type: object + required: + - type + - config + properties: + type: + description: Name of the filter provider type + type: string + enum: + - llama_guard_3_8b + example: llama_guard_3_8b + config: + $ref: '#/components/schemas/LlamaGuard38b' + + LlamaGuard38b: + description: Filter configuration for Llama Guard 3 8B + type: object + additionalProperties: false + minProperties: 1 + properties: + violent_crimes: + type: boolean + non_violent_crimes: + type: boolean + sex_crimes: + type: boolean + child_exploitation: + type: boolean + defamation: + type: boolean + specialized_advice: + type: boolean + privacy: + type: boolean + intellectual_property: + type: boolean + indiscriminate_weapons: + type: boolean + hate: + type: boolean + self_harm: + type: boolean + sexual_content: + type: boolean + elections: + type: boolean + code_interpreter_abuse: + type: boolean + # --- Masking module --- MaskingModuleConfig: @@ -673,6 +946,7 @@ components: type: string mask_grounding_input: type: object + additionalProperties: false properties: enabled: type: boolean @@ -780,9 +1054,7 @@ components: default: - '*' data_repository_type: - type: string $ref: '#/components/schemas/DataRepositoryType' - description: Only include DataRepositories with the given type. data_repository_metadata: type: array items: @@ -807,18 +1079,15 @@ components: title: Id description: Identifier of this SearchFilter - unique per request. GroundingFilterSearchConfiguration: - nullable: true additionalProperties: false properties: max_chunk_count: - nullable: true type: integer minimum: 0 exclusiveMinimum: true title: Maxchunkcount description: Maximum number of chunks to be returned. Cannot be used with 'maxDocumentCount'. max_document_count: - nullable: true type: integer minimum: 0 exclusiveMinimum: true @@ -830,9 +1099,11 @@ components: DataRepositoryType: type: string + description: Only include DataRepositories with the given type. anyOf: - enum: - vector + - help.sap.com - {} title: DataRepositoryType KeyValueListPair: