diff --git a/eslint.config.js b/eslint.config.js index 404c701b4..19af1a260 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -20,7 +20,8 @@ export default [ '**/*.d.ts', '**/dist/**/*', '**/coverage/**/*', - 'packages/ai-api/src/client/**/*' + 'packages/ai-api/src/client/**/*', + 'packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-system-assigned-managed-identity-authentication-options.ts', ] }, { @@ -33,6 +34,12 @@ export default [ 'jsdoc/require-jsdoc': 'off' } }, + { + files: ['packages/foundation-models/src/azure-openai/client/inference/schema/*.ts'], + rules: { + 'jsdoc/check-indentation': 'off' + } + }, { ignores: ['**/dist-cjs/**/*'] } diff --git a/package.json b/package.json index 6430f16a5..379ae309d 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@sap-cloud-sdk/generator-common": "^3.21.0", "@sap-cloud-sdk/http-client": "^3.21.0", "@sap-cloud-sdk/util": "^3.21.0", + "@sap-cloud-sdk/openapi-generator": "^3.21.0", "@types/jest": "^29.5.13", "@types/jsonwebtoken": "^9.0.7", "@types/mock-fs": "^4.13.4", diff --git a/packages/ai-api/package.json b/packages/ai-api/package.json index d7fbfebc1..e45b4fb2e 100644 --- a/packages/ai-api/package.json +++ b/packages/ai-api/package.json @@ -32,7 +32,6 @@ "@sap-ai-sdk/core": "workspace:^" }, "devDependencies": { - "typescript": "^5.6.2", - "@sap-cloud-sdk/openapi-generator": "^3.21.0" + "typescript": "^5.6.2" } } diff --git a/packages/foundation-models/package.json b/packages/foundation-models/package.json index 5e7cdf740..21fdd4ebd 100644 --- a/packages/foundation-models/package.json +++ b/packages/foundation-models/package.json @@ -20,14 +20,16 @@ "internal.d.ts" ], "scripts": { - "compile": "pnpm run generate-zod && tsc", + "compile": "tsc", "compile:cjs": "tsc -p tsconfig.cjs.json", - "test": "pnpm run generate-zod && NODE_OPTIONS=--experimental-vm-modules jest", + "test": "NODE_OPTIONS=--experimental-vm-modules jest", "lint": "eslint \"**/*.ts\" && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c", "lint:fix": "eslint \"**/*.ts\" --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error", "check:public-api": "node --loader ts-node/esm ../../scripts/check-public-api-cli.ts", - "generate-zod": "ts-to-zod src/azure-openai/azure-openai-types.ts src/azure-openai/azure-openai-types-schema.ts", - "postgenerate-zod": "sed -i'' -e \"s|export const|\\/**\\n * @internal\\n *\\/\\nexport const|\" src/azure-openai/azure-openai-types-schema.ts" + "generate:azure-openai": "openapi-generator --generateESM --clearOutputDir -i ./src/azure-openai/spec/inference.yaml -o ./src/azure-openai/client --schemaPrefix AzureOpenAi", + "postgenerate:azure-openai": "rm ./src/azure-openai/client/inference/*.ts && pnpm lint:fix", + "generate-zod": "ts-to-zod src/azure-openai/azure-openai-embedding-types.ts src/azure-openai/ts-to-zod/azure-openai-embedding-types.zod.ts", + "postgenerate-zod": "sed -i'' -e \"s|export const|\\/**\\n * @internal\\n *\\/\\nexport const|\" src/azure-openai/ts-to-zod/azure-openai-embedding-types.zod.ts" }, "dependencies": { "@sap-ai-sdk/ai-api": "workspace:^", @@ -38,7 +40,6 @@ "@sap-cloud-sdk/util": "^3.21.0" }, "devDependencies": { - "@sap-cloud-sdk/openapi-generator": "^3.21.0", "nock": "^13.5.5", "ts-to-zod": "^3.13.0", "typescript": "^5.6.2", diff --git a/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts b/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts index a7f524b6d..2dfbc9323 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts @@ -4,16 +4,14 @@ import { mockInference, parseMockResponse } from '../../../../test-util/mock-http.js'; -import { - AzureOpenAiChatCompletionOutput, - AzureOpenAiChatMessage -} from './azure-openai-types.js'; import { AzureOpenAiChatClient } from './azure-openai-chat-client.js'; +import type { AzureOpenAiCreateChatCompletionResponse } from './client/inference/schema/index.js'; +import { apiVersion } from './model-types.js'; describe('Azure OpenAI chat client', () => { const chatCompletionEndpoint = { url: 'inference/deployments/1234/chat/completions', - apiVersion: '2024-02-01' + apiVersion }; const client = new AzureOpenAiChatClient({ deploymentId: '1234' }); @@ -30,16 +28,17 @@ describe('Azure OpenAI chat client', () => { const prompt = { messages: [ { - role: 'user', + role: 'user' as const, content: 'Where is the deepest place on earth located' } - ] as AzureOpenAiChatMessage[] + ] }; - const mockResponse = parseMockResponse( - 'foundation-models', - 'azure-openai-chat-completion-success-response.json' - ); + const mockResponse = + parseMockResponse( + 'foundation-models', + 'azure-openai-chat-completion-success-response.json' + ); mockInference( { diff --git a/packages/foundation-models/src/azure-openai/azure-openai-chat-client.ts b/packages/foundation-models/src/azure-openai/azure-openai-chat-client.ts index f3b25e853..27e2ef192 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-chat-client.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-chat-client.ts @@ -3,12 +3,10 @@ import { getDeploymentId, type ModelDeployment } from '@sap-ai-sdk/ai-api/internal.js'; -import type { AzureOpenAiChatModel } from './model-types.js'; -import type { AzureOpenAiChatCompletionParameters } from './azure-openai-types.js'; +import type { AzureOpenAiCreateChatCompletionRequest } from './client/inference/schema/index.js'; +import { apiVersion, type AzureOpenAiChatModel } from './model-types.js'; import { AzureOpenAiChatCompletionResponse } from './azure-openai-chat-completion-response.js'; -const apiVersion = '2024-02-01'; - /** * Azure OpenAI client for chat completion. */ @@ -26,7 +24,7 @@ export class AzureOpenAiChatClient { * @returns The completion result. */ async run( - data: AzureOpenAiChatCompletionParameters, + data: AzureOpenAiCreateChatCompletionRequest, requestConfig?: CustomRequestConfig ): Promise { const deploymentId = await getDeploymentId( diff --git a/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.test.ts b/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.test.ts index 13c827f57..ac4e45f8d 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.test.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.test.ts @@ -1,13 +1,13 @@ import { parseMockResponse } from '../../../../test-util/mock-http.js'; import { AzureOpenAiChatCompletionResponse } from './azure-openai-chat-completion-response.js'; -import { AzureOpenAiChatCompletionOutput } from './azure-openai-types.js'; -import { azureOpenAiChatCompletionOutputSchema } from './azure-openai-types-schema.js'; +import { AzureOpenAiCreateChatCompletionResponse } from './client/inference/schema/index.js'; describe('OpenAI chat completion response', () => { - const mockResponse = parseMockResponse( - 'foundation-models', - 'azure-openai-chat-completion-success-response.json' - ); + const mockResponse = + parseMockResponse( + 'foundation-models', + 'azure-openai-chat-completion-success-response.json' + ); const rawResponse = { data: mockResponse, status: 200, @@ -17,7 +17,7 @@ describe('OpenAI chat completion response', () => { const response = new AzureOpenAiChatCompletionResponse(rawResponse); it('should return the completion response', () => { - const data = azureOpenAiChatCompletionOutputSchema.parse(response.data); - expect(data).toStrictEqual(mockResponse); + // TODO: Use zod schema to validate the response + expect(response.data).toStrictEqual(mockResponse); }); }); diff --git a/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.ts b/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.ts index b8974f42c..b93b5a2cb 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-chat-completion-response.ts @@ -1,12 +1,9 @@ import { HttpResponse } from '@sap-cloud-sdk/http-client'; import { createLogger } from '@sap-cloud-sdk/util'; -import { - AzureOpenAiChatCompletionOutput, - AzureOpenAiUsage -} from './azure-openai-types.js'; +import type { AzureOpenAiCreateChatCompletionResponse } from './client/inference/schema/index.js'; const logger = createLogger({ - package: 'gen-ai-hub', + package: 'foundation-models', messageContext: 'azure-openai-chat-completion-response' }); @@ -17,8 +14,7 @@ export class AzureOpenAiChatCompletionResponse { /** * The chat completion response. */ - public readonly data: AzureOpenAiChatCompletionOutput; - + public readonly data: AzureOpenAiCreateChatCompletionResponse; constructor(public readonly rawResponse: HttpResponse) { this.data = rawResponse.data; } @@ -27,7 +23,7 @@ export class AzureOpenAiChatCompletionResponse { * Usage of tokens in the response. * @returns Token usage. */ - getTokenUsage(): AzureOpenAiUsage { + getTokenUsage(): this['data']['usage'] { return this.data.usage; } @@ -36,7 +32,9 @@ export class AzureOpenAiChatCompletionResponse { * @param choiceIndex - The index of the choice to parse. * @returns The finish reason. */ - getFinishReason(choiceIndex = 0): string | undefined { + getFinishReason( + choiceIndex = 0 + ): this['data']['choices'][0]['finish_reason'] { this.logInvalidChoiceIndex(choiceIndex); return this.data.choices[choiceIndex]?.finish_reason; } @@ -46,7 +44,7 @@ export class AzureOpenAiChatCompletionResponse { * @param choiceIndex - The index of the choice to parse. * @returns The message content. */ - getContent(choiceIndex = 0): string | undefined { + getContent(choiceIndex = 0): string | undefined | null { this.logInvalidChoiceIndex(choiceIndex); return this.data.choices[choiceIndex]?.message?.content; } diff --git a/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.test.ts b/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.test.ts index 87f40105a..5a668fc93 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.test.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.test.ts @@ -7,13 +7,14 @@ import { import { AzureOpenAiEmbeddingOutput, AzureOpenAiEmbeddingParameters -} from './azure-openai-types.js'; +} from './azure-openai-embedding-types.js'; import { AzureOpenAiEmbeddingClient } from './azure-openai-embedding-client.js'; +import { apiVersion } from './model-types.js'; describe('Azure OpenAI embedding client', () => { const embeddingsEndpoint = { url: 'inference/deployments/1234/embeddings', - apiVersion: '2024-02-01' + apiVersion }; const client = new AzureOpenAiEmbeddingClient({ deploymentId: '1234' }); diff --git a/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.ts b/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.ts index 8a8b2c75d..5c4b9a89c 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-embedding-client.ts @@ -4,10 +4,8 @@ import { type ModelDeployment } from '@sap-ai-sdk/ai-api/internal.js'; import { AzureOpenAiEmbeddingResponse } from './azure-openai-embedding-response.js'; -import type { AzureOpenAiEmbeddingParameters } from './azure-openai-types.js'; -import type { AzureOpenAiEmbeddingModel } from './model-types.js'; - -const apiVersion = '2024-02-01'; +import type { AzureOpenAiEmbeddingParameters } from './azure-openai-embedding-types.js'; +import { apiVersion, type AzureOpenAiEmbeddingModel } from './model-types.js'; /** * Azure OpenAI client for embeddings. diff --git a/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.test.ts b/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.test.ts index 43beeb20a..c5974fe8e 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.test.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.test.ts @@ -1,6 +1,6 @@ import { parseMockResponse } from '../../../../test-util/mock-http.js'; import { AzureOpenAiEmbeddingResponse } from './azure-openai-embedding-response.js'; -import { azureOpenAiEmbeddingOutputSchema } from './azure-openai-types-schema.js'; +import { azureOpenAiEmbeddingOutputSchema } from './ts-to-zod/azure-openai-embedding-types.zod.js'; describe('Azure OpenAI embedding response', () => { const mockResponse = parseMockResponse( diff --git a/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.ts b/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.ts index 768d49ba6..d4c8cf53a 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-embedding-response.ts @@ -1,9 +1,9 @@ import { HttpResponse } from '@sap-cloud-sdk/http-client'; import { createLogger } from '@sap-cloud-sdk/util'; -import { AzureOpenAiEmbeddingOutput } from './azure-openai-types.js'; +import { AzureOpenAiEmbeddingOutput } from './azure-openai-embedding-types.js'; const logger = createLogger({ - package: 'gen-ai-hub', + package: 'foundation-models', messageContext: 'azure-openai-embedding-response' }); diff --git a/packages/foundation-models/src/azure-openai/azure-openai-embedding-types.ts b/packages/foundation-models/src/azure-openai/azure-openai-embedding-types.ts new file mode 100644 index 000000000..c4030ae61 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/azure-openai-embedding-types.ts @@ -0,0 +1,59 @@ +/** + * Azure OpenAI embedding input parameters. + */ +export interface AzureOpenAiEmbeddingParameters { + /** + * Input text to get embeddings for, encoded as a string. The number of input tokens varies depending on what model you are using. Unless you're embedding code, we suggest replacing newlines (\n) in your input with a single space, as we have observed inferior results when newlines are present. + */ + input: string[] | string; + /** + * A unique identifier representing for your end-user. This will help Azure OpenAI monitor and detect abuse. Do not pass PII identifiers instead use pseudoanonymized values such as GUIDs. + */ + user?: string; +} + +/** + * Azure OpenAI embedding output. + */ +export interface AzureOpenAiEmbeddingOutput { + /** + * List object. + */ + object: 'list'; + /** + * Model used for embedding. + */ + model: string; + /** + * Array of result candidates. + */ + data: [ + { + /** + * Embedding object. + */ + object: 'embedding'; + /** + * Array of size `1536` (Azure OpenAI's embedding size) containing embedding vector. + */ + embedding: number[]; + /** + * Index of choice. + */ + index: number; + } + ]; + /** + * Token Usage. + */ + usage: { + /** + * Tokens consumed for input prompt tokens. + */ + prompt_tokens: number; + /** + * Total tokens consumed. + */ + total_tokens: number; + }; +} diff --git a/packages/foundation-models/src/azure-openai/azure-openai-types-schema.ts b/packages/foundation-models/src/azure-openai/azure-openai-types-schema.ts deleted file mode 100644 index d89627e3f..000000000 --- a/packages/foundation-models/src/azure-openai/azure-openai-types-schema.ts +++ /dev/null @@ -1,300 +0,0 @@ -// Generated by ts-to-zod -import { z } from 'zod'; - -/** - * @internal - */ -export const azureOpenAiChatSystemMessageSchema = z.object({ - role: z.literal('system'), - name: z.string().optional(), - content: z.string() -}); - -/** - * @internal - */ -export const azureOpenAiChatUserMessageSchema = z.object({ - role: z.literal('user'), - name: z.string().optional(), - content: z.union([ - z.string(), - z.array( - z.union([ - z.object({ - type: z.literal('text'), - text: z.string() - }), - z.object({ - type: z.literal('image_url'), - image_url: z.union([ - z.string(), - z.object({ - url: z.string(), - detail: z - .union([z.literal('auto'), z.literal('low'), z.literal('high')]) - .optional() - .default('auto') - }) - ]) - }) - ]) - ) - ]) -}); - -/** - * @internal - */ -export const azureOpenAiChatFunctionCallSchema = z.object({ - name: z.string(), - arguments: z.string() -}); - -/** - * @internal - */ -export const azureOpenAiChatToolCallSchema = z.object({ - id: z.string(), - type: z.literal('function'), - function: azureOpenAiChatFunctionCallSchema -}); - -/** - * @internal - */ -export const azureOpenAiChatToolMessageSchema = z.object({ - role: z.literal('tool'), - content: z.string(), - tool_call_id: z.string() -}); - -/** - * @internal - */ -export const azureOpenAiChatFunctionMessageSchema = z.object({ - role: z.literal('function'), - content: z.string().nullable(), - name: z.string() -}); - -/** - * @internal - */ -export const azureOpenAiChatAssistantMessageSchema = z.object({ - role: z.literal('assistant'), - name: z.string().optional(), - content: z.string().optional(), - function_call: azureOpenAiChatFunctionCallSchema.optional(), - tool_calls: z.array(azureOpenAiChatToolCallSchema).optional() -}); - -/** - * @internal - */ -export const azureOpenAiChatCompletionFunctionSchema = z.object({ - name: z.string(), - description: z.string().optional(), - parameters: z.record(z.unknown()) -}); - -/** - * @internal - */ -export const azureOpenAiChatCompletionToolSchema = z.object({ - type: z.literal('function'), - function: azureOpenAiChatCompletionFunctionSchema -}); - -/** - * @internal - */ -export const azureOpenAiCompletionParametersSchema = z.object({ - max_tokens: z.number().optional(), - temperature: z.number().optional(), - top_p: z.number().optional(), - logit_bias: z.record(z.unknown()).optional(), - user: z.string().optional(), - n: z.number().optional(), - stop: z.union([z.string(), z.array(z.string())]).optional(), - presence_penalty: z.number().optional(), - frequency_penalty: z.number().optional() -}); - -/** - * @internal - */ -export const azureOpenAiChatMessageSchema = z.union([ - azureOpenAiChatSystemMessageSchema, - azureOpenAiChatUserMessageSchema, - azureOpenAiChatAssistantMessageSchema, - azureOpenAiChatToolMessageSchema, - azureOpenAiChatFunctionMessageSchema -]); - -/** - * @internal - */ -export const azureOpenAiEmbeddingParametersSchema = z.object({ - input: z.union([z.array(z.string()), z.string()]), - user: z.string().optional() -}); - -/** - * @internal - */ -export const azureOpenAiUsageSchema = z.object({ - completion_tokens: z.number(), - prompt_tokens: z.number(), - total_tokens: z.number() -}); - -/** - * @internal - */ -export const azureOpenAiErrorBaseSchema = z.object({ - code: z.string().optional(), - message: z.string().optional() -}); - -/** - * @internal - */ -export const azureOpenAiContentFilterResultBaseSchema = z.object({ - filtered: z.boolean() -}); - -/** - * @internal - */ -export const azureOpenAiContentFilterDetectedResultSchema = - azureOpenAiContentFilterResultBaseSchema.extend({ - detected: z.boolean() - }); - -/** - * @internal - */ -export const azureOpenAiContentFilterSeverityResultSchema = - azureOpenAiContentFilterResultBaseSchema.extend({ - severity: z.union([ - z.literal('safe'), - z.literal('low'), - z.literal('medium'), - z.literal('high') - ]) - }); - -/** - * @internal - */ -export const azureOpenAiEmbeddingOutputSchema = z.object({ - object: z.literal('list'), - model: z.string(), - data: z.tuple([ - z.object({ - object: z.literal('embedding'), - embedding: z.array(z.number()), - index: z.number() - }) - ]), - usage: z.object({ - prompt_tokens: z.number(), - total_tokens: z.number() - }) -}); - -/** - * @internal - */ -export const azureOpenAiChatCompletionParametersSchema = - azureOpenAiCompletionParametersSchema.extend({ - messages: z.array(azureOpenAiChatMessageSchema), - response_format: z - .object({ - type: z - .union([z.literal('text'), z.literal('json_object')]) - .default('text') - }) - .optional(), - seed: z.number().optional(), - functions: z.array(azureOpenAiChatCompletionFunctionSchema).optional(), - tools: z.array(azureOpenAiChatCompletionToolSchema).optional(), - tool_choice: z - .union([ - z.literal('none'), - z.literal('auto'), - z.object({ - type: z.literal('function'), - function: z.object({ - name: z.string() - }) - }) - ]) - .optional() - }); - -/** - * @internal - */ -export const azureOpenAiContentFilterResultsBaseSchema = z.object({ - sexual: azureOpenAiContentFilterSeverityResultSchema.optional(), - violence: azureOpenAiContentFilterSeverityResultSchema.optional(), - hate: azureOpenAiContentFilterSeverityResultSchema.optional(), - self_harm: azureOpenAiContentFilterSeverityResultSchema.optional(), - profanity: azureOpenAiContentFilterDetectedResultSchema.optional(), - error: azureOpenAiErrorBaseSchema.optional() -}); - -/** - * @internal - */ -export const azureOpenAiContentFilterPromptResultsSchema = - azureOpenAiContentFilterResultsBaseSchema.extend({ - jailbreak: azureOpenAiContentFilterDetectedResultSchema.optional() - }); - -/** - * @internal - */ -export const azureOpenAiPromptFilterResultSchema = z.object({ - prompt_index: z.number().optional(), - content_filter_results: azureOpenAiContentFilterPromptResultsSchema.optional() -}); - -/** - * @internal - */ -export const azureOpenAiCompletionOutputSchema = z.object({ - created: z.number(), - id: z.string(), - model: z.string(), - object: z.union([z.literal('chat.completion'), z.literal('text_completion')]), - usage: azureOpenAiUsageSchema, - prompt_filter_results: z.array(azureOpenAiPromptFilterResultSchema).optional() -}); - -/** - * @internal - */ -export const azureOpenAiCompletionChoiceSchema = z.object({ - finish_reason: z.string().optional(), - index: z.number(), - content_filter_results: azureOpenAiContentFilterPromptResultsSchema.optional() -}); - -/** - * @internal - */ -export const azureOpenAiChatCompletionChoiceSchema = - azureOpenAiCompletionChoiceSchema.extend({ - message: azureOpenAiChatAssistantMessageSchema - }); - -/** - * @internal - */ -export const azureOpenAiChatCompletionOutputSchema = - azureOpenAiCompletionOutputSchema.extend({ - choices: z.array(azureOpenAiChatCompletionChoiceSchema), - system_fingerprint: z.string().nullable() - }); diff --git a/packages/foundation-models/src/azure-openai/azure-openai-types.ts b/packages/foundation-models/src/azure-openai/azure-openai-types.ts deleted file mode 100644 index b88dc2ede..000000000 --- a/packages/foundation-models/src/azure-openai/azure-openai-types.ts +++ /dev/null @@ -1,570 +0,0 @@ -/** - * Azure OpenAI system message. - */ -export interface AzureOpenAiChatSystemMessage { - /** - * The role of the messages author,. - */ - role: 'system'; - /** - * An optional name for the participant. Provides the model information to differentiate between participants of the same role. - */ - name?: string; - /** - * The contents of the system message. - */ - content: string; -} - -/** - * Azure OpenAI user message. - */ -export interface AzureOpenAiChatUserMessage { - /** - * The role of the messages author,. - */ - role: 'user'; - /** - * An optional name for the participant. Provides the model information to differentiate between participants of the same role. - */ - name?: string; - /** - * The contents of the user message. - */ - content: - | string - | ( - | { - /** - * The type of the content part. - */ - type: 'text'; - /** - * The text content. - */ - text: string; - } - | { - /** - * The type of the content part. - */ - type: 'image_url'; - image_url: - | string - | { - /** - * Either a URL of the image or the base64 encoded image data. - */ - url: string; - /** - * Specifies the detail level of the image. - * @default auto - */ - detail?: 'auto' | 'low' | 'high'; - }; - } - )[]; -} - -/** - * Azure OpenAI assistant message. - */ -export interface AzureOpenAiChatAssistantMessage { - /** - * The role of the messages author,. - */ - role: 'assistant'; - /** - * An optional name for the participant. Provides the model information to differentiate between participants of the same role. - */ - name?: string; - /** - * Message content. - */ - content?: string; - /** - * Function which is called. - * @deprecated In favor of `tool_calls`. - */ - function_call?: AzureOpenAiChatFunctionCall; - /** - * The tool calls generated by the model, such as function calls. - */ - tool_calls?: AzureOpenAiChatToolCall[]; -} - -/** - * Azure OpenAI tool message. - */ -export interface AzureOpenAiChatToolMessage { - /** - * The role of the messages author,. - */ - role: 'tool'; - /** - * The contents of the tool message. - */ - content: string; - /** - * Tool call that this message is responding to. - */ - tool_call_id: string; -} - -/** - * Azure OpenAI function message. - */ -export interface AzureOpenAiChatFunctionMessage { - /** - * The role of the messages author,. - */ - role: 'function'; - /** - * The contents of the function message. - */ - content: string | null; - /** - * The name of the function to call. - */ - name: string; -} - -/** - * Azure OpenAI chat message types. - */ -export type AzureOpenAiChatMessage = - | AzureOpenAiChatSystemMessage - | AzureOpenAiChatUserMessage - | AzureOpenAiChatAssistantMessage - | AzureOpenAiChatToolMessage - | AzureOpenAiChatFunctionMessage; - -/** - * Azure OpenAI function signature. - */ -export interface AzureOpenAiChatCompletionFunction { - /** - * 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; - /** - * Description of the function. - */ - description?: string; - /** - * JSON Schema for the function input parameters. - * - * **Note**: As mentioned in {@link https://community.openai.com/t/whitch-json-schema-version-should-function-calling-use/283535/4}, it follows JSON Schema 7 (2020-12). - * Not all JSON Schema parameters in the specification are supported by Azure OpenAI. - */ - parameters: Record; -} - -/** - * Azure OpenAI tool signature. - */ -export interface AzureOpenAiChatCompletionTool { - /** - * The type of the tool. - */ - type: 'function'; - /** - * Function signature. - */ - function: AzureOpenAiChatCompletionFunction; -} - -/** - * Azure OpenAI function call by AI. - */ -export interface AzureOpenAiChatFunctionCall { - /** - * Name of the function 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; -} - -/** - * Azure OpenAI tool call by AI. - */ -export interface AzureOpenAiChatToolCall { - /** - * The ID of the tool call. - */ - id: string; - /** - * The type of the tool. - */ - type: 'function'; - /** - * The function that the model called. - */ - function: AzureOpenAiChatFunctionCall; -} - -/** - * Azure OpenAI completion input parameters. - */ -export interface AzureOpenAiCompletionParameters { - /** - * The maximum number of [tokens](/tokenizer) that can be generated in the completion. The token count of your prompt plus max_tokens can't exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096). - */ - max_tokens?: number; - /** - * What sampling temperature to use, between 0 and 2. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (`argmax sampling`) for ones with a well-defined answer. We generally recommend altering this or top_p but not both. - */ - temperature?: number; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. - */ - top_p?: number; - /** - * Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this tokenizer tool (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. As an example, you can pass {"50256": -100} to prevent the <|endoftext|> token from being generated. - */ - logit_bias?: Record; - /** - * A unique identifier representing your end-user, which can help monitoring and detecting abuse. - */ - user?: string; - /** - * How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop. - */ - n?: number; - /** - * Up to four sequences where the API will stop generating further tokens. The returned text won't contain the stop sequence. - */ - stop?: string | string[]; - /** - * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - */ - presence_penalty?: number; - /** - * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - */ - frequency_penalty?: number; -} - -/** - * Azure OpenAI chat completion input parameters. - */ -export interface AzureOpenAiChatCompletionParameters - extends AzureOpenAiCompletionParameters { - /** - * An array of system, user & assistant messages for chat completion. - */ - messages: AzureOpenAiChatMessage[]; - /** - * An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON. - * - * **Important**: when using JSON mode, you *must* also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - */ - response_format?: { - /** - * Type of response format. - * @default text - */ - type: 'text' | 'json_object'; - }; - /** - * If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - */ - seed?: number; - /** - * Array of function signatures to be called. - * @deprecated Use `tools` instead. - */ - functions?: AzureOpenAiChatCompletionFunction[]; - /** - * A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. - */ - tools?: AzureOpenAiChatCompletionTool[]; - /** - * Controls which (if any) function is called by the model. - * - * - `none` means the model will not call a function and instead generates a message. - * - `auto` means the model can pick between generating a message or calling a function. - * - Specifying a particular function via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that function. - */ - tool_choice?: - | 'none' - | 'auto' - | { - /** - * The type of the tool. - */ - type: 'function'; - /** - * Use to force the model to call a specific function. - */ - function: { - /** - * The name of the function to call. - */ - name: string; - }; - }; -} - -/** - * Azure OpenAI embedding input parameters. - */ -export interface AzureOpenAiEmbeddingParameters { - /** - * Input text to get embeddings for, encoded as a string. The number of input tokens varies depending on what model you are using. Unless you're embedding code, we suggest replacing newlines (\n) in your input with a single space, as we have observed inferior results when newlines are present. - */ - input: string[] | string; - /** - * A unique identifier representing for your end-user. This will help Azure OpenAI monitor and detect abuse. Do not pass PII identifiers instead use pseudoanonymized values such as GUIDs. - */ - user?: string; -} - -/** - * Usage statistics for the completion request. - */ -export interface AzureOpenAiUsage { - /** - * Tokens consumed for output text completion. - */ - completion_tokens: number; - /** - * Tokens consumed for input prompt tokens. - */ - prompt_tokens: number; - /** - * Total tokens consumed for input + output. - */ - total_tokens: number; -} - -/** - * Azure OpenAI completion output . - */ -export interface AzureOpenAiCompletionOutput { - /** - * - */ - created: number; - /** - * Unique ID for completion. - */ - id: string; - /** - * Name of the model used for completion. - */ - model: string; - /** - * Completion object. - */ - object: 'chat.completion' | 'text_completion'; - /** - * Token usage. - */ - usage: AzureOpenAiUsage; - /** - * Content filtering results for zero or more prompts in the request. - */ - prompt_filter_results?: AzureOpenAiPromptFilterResult[]; -} - -/** - * Azure OpenAI chat completion output. - */ -export interface AzureOpenAiChatCompletionOutput - extends AzureOpenAiCompletionOutput { - /** - * Array of result candidates. - */ - choices: AzureOpenAiChatCompletionChoice[]; - /** - * This fingerprint represents the backend configuration that the model runs with. - * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - */ - system_fingerprint: string | null; -} - -/** - * Content filtering results for a single prompt in the request. - */ -export interface AzureOpenAiPromptFilterResult { - /** - * Index of the prompt in the request. - */ - prompt_index?: number; - /** - * Information about the content filtering category, if it has been detected, as well as the severity level and if it has been filtered or not. - */ - content_filter_results?: AzureOpenAiContentFilterPromptResults; -} - -/** - * Azure OpenAI completion choice. - */ -export interface AzureOpenAiCompletionChoice { - /** - * Reason for finish. - */ - finish_reason?: string; - /** - * Index of choice. - */ - index: number; - /** - * Information about the content filtering category, if it has been detected, as well as the severity level and if it has been filtered or not. - */ - content_filter_results?: AzureOpenAiContentFilterPromptResults; -} - -/** - * Azure OpenAI chat completion choice. - */ -export interface AzureOpenAiChatCompletionChoice - extends AzureOpenAiCompletionChoice { - /** - * Completion chat message. - */ - message: AzureOpenAiChatAssistantMessage; -} - -/** - * Information about the content filtering results. - */ -export interface AzureOpenAiContentFilterResultsBase { - /** - * Sexual content filter result. - */ - sexual?: AzureOpenAiContentFilterSeverityResult; - - /** - * Violent content filter result. - */ - violence?: AzureOpenAiContentFilterSeverityResult; - - /** - * Hate speech content filter result. - */ - hate?: AzureOpenAiContentFilterSeverityResult; - - /** - * Intolerant content filter result. - */ - self_harm?: AzureOpenAiContentFilterSeverityResult; - - /** - * Profanity content filter result. - */ - profanity?: AzureOpenAiContentFilterDetectedResult; - - /** - * Error. - */ - error?: AzureOpenAiErrorBase; -} - -/** - * Content filtering results for a prompt in the request. - */ -export interface AzureOpenAiContentFilterPromptResults - extends AzureOpenAiContentFilterResultsBase { - /** - * - */ - jailbreak?: AzureOpenAiContentFilterDetectedResult; -} - -/** - * Azure OpenAI content filter result. - */ -export interface AzureOpenAiContentFilterResultBase { - /** - * Whether the content was filtered. - */ - filtered: boolean; -} - -/** - * Azure OpenAI content filter detected result. - */ -export interface AzureOpenAiContentFilterDetectedResult - extends AzureOpenAiContentFilterResultBase { - /** - * Whether the content was detected. - */ - detected: boolean; -} - -/** - * Azure OpenAI error. - */ -export interface AzureOpenAiErrorBase { - /** - * Error code. - */ - code?: string; - - /** - * Error message. - */ - message?: string; -} - -/** - * Information about the content filtering results. - */ -export interface AzureOpenAiContentFilterSeverityResult - extends AzureOpenAiContentFilterResultBase { - /** - * Severity of the content. - */ - severity: 'safe' | 'low' | 'medium' | 'high'; -} - -/** - * Azure OpenAI embedding output. - */ -export interface AzureOpenAiEmbeddingOutput { - /** - * List object. - */ - object: 'list'; - /** - * Model used for embedding. - */ - model: string; - /** - * Array of result candidates. - */ - data: [ - { - /** - * Embedding object. - */ - object: 'embedding'; - /** - * Array of size `1536` (Azure OpenAI's embedding size) containing embedding vector. - */ - embedding: number[]; - /** - * Index of choice. - */ - index: number; - } - ]; - /** - * Token Usage. - */ - usage: { - /** - * Tokens consumed for input prompt tokens. - */ - prompt_tokens: number; - /** - * Total tokens consumed. - */ - total_tokens: number; - }; -} diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/audio-response-format.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-response-format.ts new file mode 100644 index 000000000..c01160346 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-response-format.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Defines the format of the output. + */ +export type AzureOpenAiAudioResponseFormat = + | 'json' + | 'text' + | 'srt' + | 'verbose_json' + | 'vtt'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/audio-response.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-response.ts new file mode 100644 index 000000000..d4ea3ed02 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-response.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Translation or transcription response when response_format was json. + */ +export type AzureOpenAiAudioResponse = { + /** + * Translated or transcribed text. + */ + text: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/audio-segment.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-segment.ts new file mode 100644 index 000000000..82ccd75fa --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-segment.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Transcription or translation segment. + */ +export type AzureOpenAiAudioSegment = { + /** + * Segment identifier. + */ + id?: number; + /** + * Offset of the segment. + */ + seek?: number; + /** + * Segment start offset. + */ + start?: number; + /** + * Segment end offset. + */ + end?: number; + /** + * Segment text. + */ + text?: string; + /** + * Tokens of the text. + */ + tokens?: number[]; + /** + * Temperature. + */ + temperature?: number; + /** + * Average log probability. + */ + avg_logprob?: number; + /** + * Compression ratio. + */ + compression_ratio?: number; + /** + * Probability of 'no speech'. + */ + no_speech_prob?: number; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/audio-verbose-response.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-verbose-response.ts new file mode 100644 index 000000000..06b9d2933 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/audio-verbose-response.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiAudioResponse } from './audio-response.js'; +import type { AzureOpenAiAudioSegment } from './audio-segment.js'; +/** + * Translation or transcription response when response_format was verbose_json. + */ +export type AzureOpenAiAudioVerboseResponse = AzureOpenAiAudioResponse & { + /** + * Type of audio task. + */ + task?: 'transcribe' | 'translate'; + /** + * Language. + */ + language?: string; + /** + * Duration. + */ + duration?: number; + segments?: AzureOpenAiAudioSegment[]; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extension-configuration.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extension-configuration.ts new file mode 100644 index 000000000..1c12ef812 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extension-configuration.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiAzureSearchChatExtensionConfiguration } from './azure-search-chat-extension-configuration.js'; +import type { AzureOpenAiAzureCosmosDBChatExtensionConfiguration } from './azure-cosmos-db-chat-extension-configuration.js'; +/** + * A representation of configuration data for a single Azure OpenAI chat extension. This will be used by a chat + * completions request that should use Azure OpenAI chat extensions to augment the response behavior. + * The use of this configuration is compatible only with Azure OpenAI. + */ +export type AzureOpenAiAzureChatExtensionConfiguration = + | ({ + type: 'azure_search'; + } & AzureOpenAiAzureSearchChatExtensionConfiguration) + | ({ + type: 'azure_cosmos_db'; + } & AzureOpenAiAzureCosmosDBChatExtensionConfiguration); diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extension-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extension-type.ts new file mode 100644 index 000000000..296620ecd --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extension-type.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * A representation of configuration data for a single Azure OpenAI chat extension. This will be used by a chat + * completions request that should use Azure OpenAI chat extensions to augment the response behavior. + * The use of this configuration is compatible only with Azure OpenAI. + */ +export type AzureOpenAiAzureChatExtensionType = + | 'azure_search' + | 'azure_cosmos_db'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extensions-message-context.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extensions-message-context.ts new file mode 100644 index 000000000..bffbf6776 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-chat-extensions-message-context.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiCitation } from './citation.js'; +/** + * A representation of the additional context information available when Azure OpenAI chat extensions are involved + * in the generation of a corresponding chat completions response. This context information is only populated when + * using an Azure OpenAI request configured to use a matching extension. + */ +export type AzureOpenAiAzureChatExtensionsMessageContext = { + /** + * The data source retrieval result, used to generate the assistant message in the response. + */ + citations?: AzureOpenAiCitation[]; + /** + * The detected intent from the chat history, used to pass to the next turn to carry over the context. + */ + intent?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-chat-extension-configuration.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-chat-extension-configuration.ts new file mode 100644 index 000000000..26220030d --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-chat-extension-configuration.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiAzureChatExtensionType } from './azure-chat-extension-type.js'; +import type { AzureOpenAiAzureCosmosDBChatExtensionParameters } from './azure-cosmos-db-chat-extension-parameters.js'; +/** + * A specific representation of configurable options for Azure Cosmos DB when using it as an Azure OpenAI chat + * extension. + */ +export type AzureOpenAiAzureCosmosDBChatExtensionConfiguration = { + type: AzureOpenAiAzureChatExtensionType; +} & { + parameters: AzureOpenAiAzureCosmosDBChatExtensionParameters; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-chat-extension-parameters.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-chat-extension-parameters.ts new file mode 100644 index 000000000..8469d5ae2 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-chat-extension-parameters.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataConnectionStringAuthenticationOptions } from './on-your-data-connection-string-authentication-options.js'; +import type { AzureOpenAiAzureCosmosDBFieldMappingOptions } from './azure-cosmos-db-field-mapping-options.js'; +import type { AzureOpenAiOnYourDataEndpointVectorizationSource } from './on-your-data-endpoint-vectorization-source.js'; +import type { AzureOpenAiOnYourDataDeploymentNameVectorizationSource } from './on-your-data-deployment-name-vectorization-source.js'; +/** + * Parameters to use when configuring Azure OpenAI On Your Data chat extensions when using Azure Cosmos DB for + * MongoDB vCore. + */ +export type AzureOpenAiAzureCosmosDBChatExtensionParameters = { + authentication: AzureOpenAiOnYourDataConnectionStringAuthenticationOptions; + /** + * The configured top number of documents to feature for the configured query. + * Format: "int32". + */ + top_n_documents?: number; + /** + * Whether queries should be restricted to use of indexed data. + */ + in_scope?: boolean; + /** + * The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but lower recall of the answer. + * Format: "int32". + * Maximum: 5. + * Minimum: 1. + */ + strictness?: number; + /** + * Give the model instructions about how it should behave and any context it should reference when generating a response. You can describe the assistant's personality and tell it how to format responses. There's a 100 token limit for it, and it counts against the overall token limit. + */ + role_information?: string; + /** + * The MongoDB vCore database name to use with Azure Cosmos DB. + */ + database_name: string; + /** + * The name of the Azure Cosmos DB resource container. + */ + container_name: string; + /** + * The MongoDB vCore index name to use with Azure Cosmos DB. + */ + index_name: string; + fields_mapping: AzureOpenAiAzureCosmosDBFieldMappingOptions; + embedding_dependency: + | AzureOpenAiOnYourDataEndpointVectorizationSource + | AzureOpenAiOnYourDataDeploymentNameVectorizationSource; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-field-mapping-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-field-mapping-options.ts new file mode 100644 index 000000000..6aa2523e2 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-cosmos-db-field-mapping-options.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Optional settings to control how fields are processed when using a configured Azure Cosmos DB resource. + */ +export type AzureOpenAiAzureCosmosDBFieldMappingOptions = { + /** + * The name of the index field to use as a title. + */ + title_field?: string; + /** + * The name of the index field to use as a URL. + */ + url_field?: string; + /** + * The name of the index field to use as a filepath. + */ + filepath_field?: string; + /** + * The names of index fields that should be treated as content. + */ + content_fields: string[]; + /** + * The separator pattern that content fields should use. + */ + content_fields_separator?: string; + /** + * The names of fields that represent vector data. + */ + vector_fields: string[]; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-chat-extension-configuration.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-chat-extension-configuration.ts new file mode 100644 index 000000000..fde681882 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-chat-extension-configuration.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiAzureChatExtensionType } from './azure-chat-extension-type.js'; +import type { AzureOpenAiAzureSearchChatExtensionParameters } from './azure-search-chat-extension-parameters.js'; +/** + * A specific representation of configurable options for Azure Search when using it as an Azure OpenAI chat + * extension. + */ +export type AzureOpenAiAzureSearchChatExtensionConfiguration = { + type: AzureOpenAiAzureChatExtensionType; +} & { + parameters: AzureOpenAiAzureSearchChatExtensionParameters; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-chat-extension-parameters.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-chat-extension-parameters.ts new file mode 100644 index 000000000..c633dbb03 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-chat-extension-parameters.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataApiKeyAuthenticationOptions } from './on-your-data-api-key-authentication-options.js'; +import type { AzureOpenAiOnYourDataSystemAssignedManagedIdentityAuthenticationOptions } from './on-your-data-system-assigned-managed-identity-authentication-options.js'; +import type { AzureOpenAiOnYourDataUserAssignedManagedIdentityAuthenticationOptions } from './on-your-data-user-assigned-managed-identity-authentication-options.js'; +import type { AzureOpenAiAzureSearchIndexFieldMappingOptions } from './azure-search-index-field-mapping-options.js'; +import type { AzureOpenAiAzureSearchQueryType } from './azure-search-query-type.js'; +import type { AzureOpenAiOnYourDataEndpointVectorizationSource } from './on-your-data-endpoint-vectorization-source.js'; +import type { AzureOpenAiOnYourDataDeploymentNameVectorizationSource } from './on-your-data-deployment-name-vectorization-source.js'; +/** + * Parameters for Azure Search when used as an Azure OpenAI chat extension. + */ +export type AzureOpenAiAzureSearchChatExtensionParameters = { + authentication: + | AzureOpenAiOnYourDataApiKeyAuthenticationOptions + | AzureOpenAiOnYourDataSystemAssignedManagedIdentityAuthenticationOptions + | AzureOpenAiOnYourDataUserAssignedManagedIdentityAuthenticationOptions; + /** + * The configured top number of documents to feature for the configured query. + * Format: "int32". + */ + top_n_documents?: number; + /** + * Whether queries should be restricted to use of indexed data. + */ + in_scope?: boolean; + /** + * The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but lower recall of the answer. + * Format: "int32". + * Maximum: 5. + * Minimum: 1. + */ + strictness?: number; + /** + * Give the model instructions about how it should behave and any context it should reference when generating a response. You can describe the assistant's personality and tell it how to format responses. There's a 100 token limit for it, and it counts against the overall token limit. + */ + role_information?: string; + /** + * The absolute endpoint path for the Azure Search resource to use. + * Format: "uri". + */ + endpoint: string; + /** + * The name of the index to use as available in the referenced Azure Search resource. + */ + index_name: string; + fields_mapping?: AzureOpenAiAzureSearchIndexFieldMappingOptions; + query_type?: AzureOpenAiAzureSearchQueryType; + /** + * The additional semantic configuration for the query. + */ + semantic_configuration?: string; + /** + * Search filter. + */ + filter?: string; + embedding_dependency?: + | AzureOpenAiOnYourDataEndpointVectorizationSource + | AzureOpenAiOnYourDataDeploymentNameVectorizationSource; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-index-field-mapping-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-index-field-mapping-options.ts new file mode 100644 index 000000000..a198e4569 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-index-field-mapping-options.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Optional settings to control how fields are processed when using a configured Azure Search resource. + */ +export type AzureOpenAiAzureSearchIndexFieldMappingOptions = { + /** + * The name of the index field to use as a title. + */ + title_field?: string; + /** + * The name of the index field to use as a URL. + */ + url_field?: string; + /** + * The name of the index field to use as a filepath. + */ + filepath_field?: string; + /** + * The names of index fields that should be treated as content. + */ + content_fields?: string[]; + /** + * The separator pattern that content fields should use. + */ + content_fields_separator?: string; + /** + * The names of fields that represent vector data. + */ + vector_fields?: string[]; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-query-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-query-type.ts new file mode 100644 index 000000000..416fc40e8 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/azure-search-query-type.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The type of Azure Search retrieval query that should be executed when using it as an Azure OpenAI chat extension. + */ +export type AzureOpenAiAzureSearchQueryType = + | 'simple' + | 'semantic' + | 'vector' + | 'vector_simple_hybrid' + | 'vector_semantic_hybrid'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-choice-common.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-choice-common.ts new file mode 100644 index 000000000..3919c7014 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-choice-common.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 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 'AzureOpenAiChatCompletionChoiceCommon' schema. + */ +export type AzureOpenAiChatCompletionChoiceCommon = { + index?: number; + finish_reason?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-choice-log-probs.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-choice-log-probs.ts new file mode 100644 index 000000000..602300465 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-choice-log-probs.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionTokenLogprob } from './chat-completion-token-logprob.js'; +/** + * Log probability information for the choice. + */ +export type AzureOpenAiChatCompletionChoiceLogProbs = + | ({ + /** + * A list of message content tokens with log probability information. + */ + content: AzureOpenAiChatCompletionTokenLogprob[] | null; + } & Record) + | null; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function-call.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function-call.ts new file mode 100644 index 000000000..2b15219cc --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function-call.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + */ +export type AzureOpenAiChatCompletionFunctionCall = { + /** + * 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; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function-parameters.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function-parameters.ts new file mode 100644 index 000000000..1dbc1bbb4 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function-parameters.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 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](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + */ +export type AzureOpenAiChatCompletionFunctionParameters = Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function.ts new file mode 100644 index 000000000..1a21eccec --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-function.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionFunctionParameters } from './chat-completion-function-parameters.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionFunction' schema. + */ +export type AzureOpenAiChatCompletionFunction = { + /** + * 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; + /** + * The description of what the function does. + */ + description?: string; + parameters?: AzureOpenAiChatCompletionFunctionParameters; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-message-tool-call.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-message-tool-call.ts new file mode 100644 index 000000000..e4df877df --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-message-tool-call.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiToolCallType } from './tool-call-type.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionMessageToolCall' schema. + */ +export type AzureOpenAiChatCompletionMessageToolCall = { + /** + * The ID of the tool call. + */ + id: string; + type: AzureOpenAiToolCallType; + /** + * 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/foundation-models/src/azure-openai/client/inference/schema/chat-completion-named-tool-choice.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-named-tool-choice.ts new file mode 100644 index 000000000..4693a48d1 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-named-tool-choice.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Specifies a tool the model should use. Use to force the model to call a specific function. + */ +export type AzureOpenAiChatCompletionNamedToolChoice = { + /** + * The type of the tool. Currently, only `function` is supported. + */ + type?: 'function'; + function?: { + /** + * The name of the function to call. + */ + name: string; + } & Record; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-assistant.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-assistant.ts new file mode 100644 index 000000000..f02207d2a --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-assistant.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageRole } from './chat-completion-request-message-role.js'; +import type { AzureOpenAiChatCompletionMessageToolCall } from './chat-completion-message-tool-call.js'; +import type { AzureOpenAiAzureChatExtensionsMessageContext } from './azure-chat-extensions-message-context.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageAssistant' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageAssistant = { + role: AzureOpenAiChatCompletionRequestMessageRole; +} & { + /** + * The contents of the message. + */ + content: string | null; + /** + * The tool calls generated by the model, such as function calls. + */ + tool_calls?: AzureOpenAiChatCompletionMessageToolCall[]; + context?: AzureOpenAiAzureChatExtensionsMessageContext; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-image.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-image.ts new file mode 100644 index 000000000..882f05596 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-image.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageContentPartType } from './chat-completion-request-message-content-part-type.js'; +import type { AzureOpenAiImageDetailLevel } from './image-detail-level.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageContentPartImage' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageContentPartImage = { + type: AzureOpenAiChatCompletionRequestMessageContentPartType; +} & { + /** + * Either a URL of the image or the base64 encoded image data. + * Format: "uri". + */ + url: string; + detail?: AzureOpenAiImageDetailLevel; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-text.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-text.ts new file mode 100644 index 000000000..d1c10ec1a --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-text.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageContentPartType } from './chat-completion-request-message-content-part-type.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageContentPartText' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageContentPartText = { + type: AzureOpenAiChatCompletionRequestMessageContentPartType; +} & { + /** + * The text content. + */ + text: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-type.ts new file mode 100644 index 000000000..9a4a06e50 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part-type.ts @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The type of the content part. + */ +export type AzureOpenAiChatCompletionRequestMessageContentPartType = + | 'text' + | 'image_url'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part.ts new file mode 100644 index 000000000..403d6b55d --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-content-part.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageContentPartText } from './chat-completion-request-message-content-part-text.js'; +import type { AzureOpenAiChatCompletionRequestMessageContentPartImage } from './chat-completion-request-message-content-part-image.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageContentPart' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageContentPart = + | ({ type: 'text' } & AzureOpenAiChatCompletionRequestMessageContentPartText) + | ({ + type: 'image_url'; + } & AzureOpenAiChatCompletionRequestMessageContentPartImage); diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-function.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-function.ts new file mode 100644 index 000000000..e82290e9b --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-function.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageRole } from './chat-completion-request-message-role.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageFunction' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageFunction = { + role: AzureOpenAiChatCompletionRequestMessageRole; +} & { + /** + * The role of the messages author, in this case `function`. + */ + role?: 'function'; + /** + * The contents of the message. + */ + name?: string; + /** + * The contents of the message. + */ + content: string | null; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-role.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-role.ts new file mode 100644 index 000000000..d38f26fff --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-role.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The role of the messages author. + */ +export type AzureOpenAiChatCompletionRequestMessageRole = + | 'system' + | 'user' + | 'assistant' + | 'tool' + | 'function'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-system.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-system.ts new file mode 100644 index 000000000..eb2b2023d --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-system.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageRole } from './chat-completion-request-message-role.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageSystem' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageSystem = { + role: AzureOpenAiChatCompletionRequestMessageRole; +} & { + /** + * The contents of the message. + */ + content: string | null; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-tool.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-tool.ts new file mode 100644 index 000000000..d78e87465 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-tool.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageRole } from './chat-completion-request-message-role.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageTool' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageTool = { + role: AzureOpenAiChatCompletionRequestMessageRole; +} & { + /** + * Tool call that this message is responding to. + */ + tool_call_id: string; + /** + * The contents of the message. + */ + content: string | null; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-user.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-user.ts new file mode 100644 index 000000000..6b7960ff7 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message-user.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageRole } from './chat-completion-request-message-role.js'; +import type { AzureOpenAiChatCompletionRequestMessageContentPart } from './chat-completion-request-message-content-part.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessageUser' schema. + */ +export type AzureOpenAiChatCompletionRequestMessageUser = { + role: AzureOpenAiChatCompletionRequestMessageRole; +} & { + content: string | AzureOpenAiChatCompletionRequestMessageContentPart[] | null; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message.ts new file mode 100644 index 000000000..f87f55da2 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-request-message.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionRequestMessageSystem } from './chat-completion-request-message-system.js'; +import type { AzureOpenAiChatCompletionRequestMessageUser } from './chat-completion-request-message-user.js'; +import type { AzureOpenAiChatCompletionRequestMessageAssistant } from './chat-completion-request-message-assistant.js'; +import type { AzureOpenAiChatCompletionRequestMessageTool } from './chat-completion-request-message-tool.js'; +import type { AzureOpenAiChatCompletionRequestMessageFunction } from './chat-completion-request-message-function.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionRequestMessage' schema. + */ +export type AzureOpenAiChatCompletionRequestMessage = + | ({ role: 'system' } & AzureOpenAiChatCompletionRequestMessageSystem) + | ({ role: 'user' } & AzureOpenAiChatCompletionRequestMessageUser) + | ({ role: 'assistant' } & AzureOpenAiChatCompletionRequestMessageAssistant) + | ({ role: 'tool' } & AzureOpenAiChatCompletionRequestMessageTool) + | ({ role: 'function' } & AzureOpenAiChatCompletionRequestMessageFunction); diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-format.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-format.ts new file mode 100644 index 000000000..688cabc1f --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-format.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Setting to `json_object` enables JSON mode. This guarantees that the message the model generates is valid JSON. + * @example "json_object" + * Default: "text". + */ +export type AzureOpenAiChatCompletionResponseFormat = + | 'text' + | 'json_object' + | null; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-message-role.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-message-role.ts new file mode 100644 index 000000000..e8efe0d6b --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-message-role.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The role of the author of the response message. + */ +export type AzureOpenAiChatCompletionResponseMessageRole = 'assistant'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-message.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-message.ts new file mode 100644 index 000000000..33027ad0c --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-message.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionResponseMessageRole } from './chat-completion-response-message-role.js'; +import type { AzureOpenAiChatCompletionMessageToolCall } from './chat-completion-message-tool-call.js'; +import type { AzureOpenAiChatCompletionFunctionCall } from './chat-completion-function-call.js'; +import type { AzureOpenAiAzureChatExtensionsMessageContext } from './azure-chat-extensions-message-context.js'; +/** + * A chat completion message generated by the model. + */ +export type AzureOpenAiChatCompletionResponseMessage = { + role?: AzureOpenAiChatCompletionResponseMessageRole; + /** + * The contents of the message. + */ + content?: string | null; + /** + * The tool calls generated by the model, such as function calls. + */ + tool_calls?: AzureOpenAiChatCompletionMessageToolCall[]; + function_call?: AzureOpenAiChatCompletionFunctionCall; + context?: AzureOpenAiAzureChatExtensionsMessageContext; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-object.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-object.ts new file mode 100644 index 000000000..2959235f8 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-response-object.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The object type. + */ +export type AzureOpenAiChatCompletionResponseObject = 'chat.completion'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-token-logprob.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-token-logprob.ts new file mode 100644 index 000000000..fb3747f92 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-token-logprob.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 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 'AzureOpenAiChatCompletionTokenLogprob' schema. + */ +export type AzureOpenAiChatCompletionTokenLogprob = { + /** + * The token. + */ + token: string; + /** + * The log probability of this token. + */ + logprob: number; + /** + * A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + */ + bytes: number[] | null; + /** + * List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + */ + top_logprobs: ({ + /** + * The token. + */ + token: string; + /** + * The log probability of this token. + */ + logprob: number; + /** + * A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + */ + bytes: number[] | null; + } & Record)[]; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool-choice-option.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool-choice-option.ts new file mode 100644 index 000000000..a77e81ca4 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool-choice-option.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionNamedToolChoice } from './chat-completion-named-tool-choice.js'; +/** + * Controls which (if any) function is called by the model. `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function. Specifying a particular function via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that function. + */ +export type AzureOpenAiChatCompletionToolChoiceOption = + | 'none' + | 'auto' + | 'required' + | AzureOpenAiChatCompletionNamedToolChoice; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool-type.ts new file mode 100644 index 000000000..a0cafca88 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool-type.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The type of the tool. Currently, only `function` is supported. + */ +export type AzureOpenAiChatCompletionToolType = 'function'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool.ts new file mode 100644 index 000000000..d626ae1fe --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completion-tool.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionToolType } from './chat-completion-tool-type.js'; +import type { AzureOpenAiChatCompletionFunctionParameters } from './chat-completion-function-parameters.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionTool' schema. + */ +export type AzureOpenAiChatCompletionTool = { + type: AzureOpenAiChatCompletionToolType; + function: { + /** + * 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: AzureOpenAiChatCompletionFunctionParameters; + } & Record; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completions-request-common.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completions-request-common.ts new file mode 100644 index 000000000..37fc2e1e1 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completions-request-common.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 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 'AzureOpenAiChatCompletionsRequestCommon' schema. + */ +export type AzureOpenAiChatCompletionsRequestCommon = { + /** + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * We generally recommend altering this or `top_p` but not both. + * @example 1 + * Default: 1. + * Maximum: 2. + */ + temperature?: number | null; + /** + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * We generally recommend altering this or `temperature` but not both. + * @example 1 + * Default: 1. + * Maximum: 1. + */ + top_p?: number | null; + /** + * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message. + */ + stream?: boolean | null; + /** + * Up to 4 sequences where the API will stop generating further tokens. + */ + stop?: string | string[]; + /** + * The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens). + * Default: 4096. + */ + max_tokens?: number; + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + * Maximum: 2. + * Minimum: -2. + */ + presence_penalty?: number; + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + * Maximum: 2. + * Minimum: -2. + */ + frequency_penalty?: number; + /** + * Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + */ + logit_bias?: Record | null; + /** + * A unique identifier representing your end-user, which can help Azure OpenAI to monitor and detect abuse. + * @example "user-1234" + */ + user?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completions-response-common.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completions-response-common.ts new file mode 100644 index 000000000..cb11db44f --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/chat-completions-response-common.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionResponseObject } from './chat-completion-response-object.js'; +import type { AzureOpenAiCompletionUsage } from './completion-usage.js'; +/** + * Representation of the 'AzureOpenAiChatCompletionsResponseCommon' schema. + */ +export type AzureOpenAiChatCompletionsResponseCommon = { + /** + * A unique identifier for the chat completion. + */ + id: string; + object: AzureOpenAiChatCompletionResponseObject; + /** + * The Unix timestamp (in seconds) of when the chat completion was created. + * Format: "unixtime". + */ + created: number; + /** + * The model used for the chat completion. + */ + model: string; + usage?: AzureOpenAiCompletionUsage; + /** + * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + */ + system_fingerprint?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/citation.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/citation.ts new file mode 100644 index 000000000..d0d4a33ad --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/citation.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Citation information for a chat completions response message. + */ +export type AzureOpenAiCitation = { + /** + * The content of the citation. + */ + content: string; + /** + * The title of the citation. + */ + title?: string; + /** + * The URL of the citation. + */ + url?: string; + /** + * The file path of the citation. + */ + filepath?: string; + /** + * The chunk ID of the citation. + */ + chunk_id?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/completion-usage.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/completion-usage.ts new file mode 100644 index 000000000..918521eb0 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/completion-usage.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Usage statistics for the completion request. + */ +export type AzureOpenAiCompletionUsage = { + /** + * Number of tokens in the prompt. + */ + prompt_tokens: number; + /** + * Number of tokens in the generated completion. + */ + completion_tokens: number; + /** + * Total number of tokens used in the request (prompt + completion). + */ + total_tokens: number; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-choice-results.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-choice-results.ts new file mode 100644 index 000000000..f49a6d91a --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-choice-results.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterResultsBase } from './content-filter-results-base.js'; +import type { AzureOpenAiContentFilterDetectedResult } from './content-filter-detected-result.js'; +import type { AzureOpenAiContentFilterDetectedWithCitationResult } from './content-filter-detected-with-citation-result.js'; +/** + * Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about third party text and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id. + */ +export type AzureOpenAiContentFilterChoiceResults = + AzureOpenAiContentFilterResultsBase & { + protected_material_text?: AzureOpenAiContentFilterDetectedResult; + } & Record & { + protected_material_code?: AzureOpenAiContentFilterDetectedWithCitationResult; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-detected-result.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-detected-result.ts new file mode 100644 index 000000000..0457fe4bc --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-detected-result.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterResultBase } from './content-filter-result-base.js'; +/** + * Representation of the 'AzureOpenAiContentFilterDetectedResult' schema. + */ +export type AzureOpenAiContentFilterDetectedResult = + AzureOpenAiContentFilterResultBase & { + detected: boolean; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-detected-with-citation-result.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-detected-with-citation-result.ts new file mode 100644 index 000000000..e7444761b --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-detected-with-citation-result.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterDetectedResult } from './content-filter-detected-result.js'; +/** + * Representation of the 'AzureOpenAiContentFilterDetectedWithCitationResult' schema. + */ +export type AzureOpenAiContentFilterDetectedWithCitationResult = + AzureOpenAiContentFilterDetectedResult & { + citation?: { + URL?: string; + license?: string; + } & Record; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-prompt-results.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-prompt-results.ts new file mode 100644 index 000000000..3fcad31b4 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-prompt-results.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterResultsBase } from './content-filter-results-base.js'; +import type { AzureOpenAiContentFilterDetectedResult } from './content-filter-detected-result.js'; +/** + * Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about jailbreak content and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id. + */ +export type AzureOpenAiContentFilterPromptResults = + AzureOpenAiContentFilterResultsBase & { + jailbreak?: AzureOpenAiContentFilterDetectedResult; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-result-base.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-result-base.ts new file mode 100644 index 000000000..ef468d432 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-result-base.ts @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 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 'AzureOpenAiContentFilterResultBase' schema. + */ +export type AzureOpenAiContentFilterResultBase = { + filtered: boolean; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-results-base.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-results-base.ts new file mode 100644 index 000000000..efe802a8d --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-results-base.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterSeverityResult } from './content-filter-severity-result.js'; +import type { AzureOpenAiContentFilterDetectedResult } from './content-filter-detected-result.js'; +import type { AzureOpenAiErrorBase } from './error-base.js'; +/** + * Information about the content filtering results. + */ +export type AzureOpenAiContentFilterResultsBase = { + sexual?: AzureOpenAiContentFilterSeverityResult; + violence?: AzureOpenAiContentFilterSeverityResult; + hate?: AzureOpenAiContentFilterSeverityResult; + self_harm?: AzureOpenAiContentFilterSeverityResult; + profanity?: AzureOpenAiContentFilterDetectedResult; + error?: AzureOpenAiErrorBase; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-severity-result.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-severity-result.ts new file mode 100644 index 000000000..70a6066cc --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/content-filter-severity-result.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterResultBase } from './content-filter-result-base.js'; +/** + * Representation of the 'AzureOpenAiContentFilterSeverityResult' schema. + */ +export type AzureOpenAiContentFilterSeverityResult = + AzureOpenAiContentFilterResultBase & { + severity: 'safe' | 'low' | 'medium' | 'high'; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/create-chat-completion-request.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/create-chat-completion-request.ts new file mode 100644 index 000000000..ce038b30e --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/create-chat-completion-request.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionsRequestCommon } from './chat-completions-request-common.js'; +import type { AzureOpenAiChatCompletionRequestMessage } from './chat-completion-request-message.js'; +import type { AzureOpenAiAzureChatExtensionConfiguration } from './azure-chat-extension-configuration.js'; +import type { AzureOpenAiChatCompletionResponseFormat } from './chat-completion-response-format.js'; +import type { AzureOpenAiChatCompletionTool } from './chat-completion-tool.js'; +import type { AzureOpenAiChatCompletionToolChoiceOption } from './chat-completion-tool-choice-option.js'; +import type { AzureOpenAiChatCompletionFunction } from './chat-completion-function.js'; +/** + * Representation of the 'AzureOpenAiCreateChatCompletionRequest' schema. + */ +export type AzureOpenAiCreateChatCompletionRequest = + AzureOpenAiChatCompletionsRequestCommon & { + /** + * A list of messages comprising the conversation so far. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb). + * Min Items: 1. + */ + messages: AzureOpenAiChatCompletionRequestMessage[]; + /** + * The configuration entries for Azure OpenAI chat extensions that use them. + * This additional specification is only compatible with Azure OpenAI. + */ + data_sources?: AzureOpenAiAzureChatExtensionConfiguration[]; + /** + * How many chat completion choices to generate for each input message. + * @example 1 + * Default: 1. + * Maximum: 128. + * Minimum: 1. + */ + n?: number | null; + /** + * If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + * @example 1 + * Maximum: 9223372036854776000. + * Minimum: -9223372036854776000. + */ + seed?: number | null; + /** + * Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. This option is currently not available on the `gpt-4-vision-preview` model. + */ + logprobs?: boolean | null; + /** + * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + * Maximum: 5. + */ + top_logprobs?: number | null; + /** + * An object specifying the format that the model must output. Used to enable JSON mode. + */ + response_format?: { + type?: AzureOpenAiChatCompletionResponseFormat; + } & Record; + /** + * A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. + * Min Items: 1. + */ + tools?: AzureOpenAiChatCompletionTool[]; + tool_choice?: AzureOpenAiChatCompletionToolChoiceOption; + /** + * Deprecated in favor of `tools`. A list of functions the model may generate JSON inputs for. + * Min Items: 1. + * Max Items: 128. + */ + functions?: AzureOpenAiChatCompletionFunction[]; + /** + * Deprecated in favor of `tool_choice`. Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. Specifying a particular function via `{"name":\ "my_function"}` forces the model to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present. + */ + function_call?: + | 'none' + | 'auto' + | ({ + /** + * The name of the function to call. + */ + name: string; + } & Record); + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/create-chat-completion-response.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/create-chat-completion-response.ts new file mode 100644 index 000000000..189fbfe03 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/create-chat-completion-response.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiChatCompletionsResponseCommon } from './chat-completions-response-common.js'; +import type { AzureOpenAiPromptFilterResults } from './prompt-filter-results.js'; +import type { AzureOpenAiChatCompletionChoiceCommon } from './chat-completion-choice-common.js'; +import type { AzureOpenAiChatCompletionResponseMessage } from './chat-completion-response-message.js'; +import type { AzureOpenAiContentFilterChoiceResults } from './content-filter-choice-results.js'; +import type { AzureOpenAiChatCompletionChoiceLogProbs } from './chat-completion-choice-log-probs.js'; +/** + * Representation of the 'AzureOpenAiCreateChatCompletionResponse' schema. + */ +export type AzureOpenAiCreateChatCompletionResponse = + AzureOpenAiChatCompletionsResponseCommon & { + prompt_filter_results?: AzureOpenAiPromptFilterResults; + choices: (AzureOpenAiChatCompletionChoiceCommon & { + message?: AzureOpenAiChatCompletionResponseMessage; + content_filter_results?: AzureOpenAiContentFilterChoiceResults; + logprobs?: AzureOpenAiChatCompletionChoiceLogProbs; + } & Record)[]; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/create-transcription-request.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/create-transcription-request.ts new file mode 100644 index 000000000..65de1d32c --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/create-transcription-request.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiAudioResponseFormat } from './audio-response-format.js'; +/** + * Transcription request. + */ +export type AzureOpenAiCreateTranscriptionRequest = { + /** + * The audio file object to transcribe. + * Format: "binary". + */ + file: string; + /** + * An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + */ + prompt?: string; + response_format?: AzureOpenAiAudioResponseFormat; + /** + * The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + */ + temperature?: number; + /** + * The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + */ + language?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/create-translation-request.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/create-translation-request.ts new file mode 100644 index 000000000..5ebe761c2 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/create-translation-request.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiAudioResponseFormat } from './audio-response-format.js'; +/** + * Translation request. + */ +export type AzureOpenAiCreateTranslationRequest = { + /** + * The audio file to translate. + * Format: "binary". + */ + file: string; + /** + * An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English. + */ + prompt?: string; + response_format?: AzureOpenAiAudioResponseFormat; + /** + * The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + */ + temperature?: number; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-content-filter-results.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-content-filter-results.ts new file mode 100644 index 000000000..49f186d59 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-content-filter-results.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterSeverityResult } from './content-filter-severity-result.js'; +/** + * Information about the content filtering results. + */ +export type AzureOpenAiDalleContentFilterResults = { + sexual?: AzureOpenAiContentFilterSeverityResult; + violence?: AzureOpenAiContentFilterSeverityResult; + hate?: AzureOpenAiContentFilterSeverityResult; + self_harm?: AzureOpenAiContentFilterSeverityResult; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-error-response.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-error-response.ts new file mode 100644 index 000000000..3e5336ba4 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-error-response.ts @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiDalleError } from './dalle-error.js'; +/** + * Representation of the 'AzureOpenAiDalleErrorResponse' schema. + */ +export type AzureOpenAiDalleErrorResponse = { + error?: AzureOpenAiDalleError; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-error.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-error.ts new file mode 100644 index 000000000..300307655 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-error.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiErrorBase } from './error-base.js'; +import type { AzureOpenAiDalleInnerError } from './dalle-inner-error.js'; +/** + * Representation of the 'AzureOpenAiDalleError' schema. + */ +export type AzureOpenAiDalleError = AzureOpenAiErrorBase & { + param?: string; + type?: string; + inner_error?: AzureOpenAiDalleInnerError; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-filter-results.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-filter-results.ts new file mode 100644 index 000000000..a139245b5 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-filter-results.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiDalleContentFilterResults } from './dalle-content-filter-results.js'; +import type { AzureOpenAiContentFilterDetectedResult } from './content-filter-detected-result.js'; +/** + * Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about jailbreak content and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id. + */ +export type AzureOpenAiDalleFilterResults = + AzureOpenAiDalleContentFilterResults & { + profanity?: AzureOpenAiContentFilterDetectedResult; + jailbreak?: AzureOpenAiContentFilterDetectedResult; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-inner-error.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-inner-error.ts new file mode 100644 index 000000000..793927a2e --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/dalle-inner-error.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiInnerErrorCode } from './inner-error-code.js'; +import type { AzureOpenAiDalleFilterResults } from './dalle-filter-results.js'; +/** + * Inner error with additional details. + */ +export type AzureOpenAiDalleInnerError = { + code?: AzureOpenAiInnerErrorCode; + content_filter_results?: AzureOpenAiDalleFilterResults; + /** + * The prompt that was used to generate the image, if there was any revision to the prompt. + */ + revised_prompt?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/error-base.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/error-base.ts new file mode 100644 index 000000000..2e974b06a --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/error-base.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 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 'AzureOpenAiErrorBase' schema. + */ +export type AzureOpenAiErrorBase = { + code?: string; + message?: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/error-response.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/error-response.ts new file mode 100644 index 000000000..71cd51eaa --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/error-response.ts @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiError } from './error.js'; +/** + * Representation of the 'AzureOpenAiErrorResponse' schema. + */ +export type AzureOpenAiErrorResponse = { + error?: AzureOpenAiError; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/error.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/error.ts new file mode 100644 index 000000000..87ef88b63 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/error.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiErrorBase } from './error-base.js'; +import type { AzureOpenAiInnerError } from './inner-error.js'; +/** + * Representation of the 'AzureOpenAiError' schema. + */ +export type AzureOpenAiError = AzureOpenAiErrorBase & { + param?: string; + type?: string; + inner_error?: AzureOpenAiInnerError; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/generate-images-response.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/generate-images-response.ts new file mode 100644 index 000000000..83f898b91 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/generate-images-response.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiImageResult } from './image-result.js'; +/** + * Representation of the 'AzureOpenAiGenerateImagesResponse' schema. + */ +export type AzureOpenAiGenerateImagesResponse = { + /** + * The unix timestamp when the operation was created. + * @example "1676540381" + * Format: "unixtime". + */ + created: number; + /** + * The result data of the operation, if successful. + */ + data: AzureOpenAiImageResult[]; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/image-detail-level.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/image-detail-level.ts new file mode 100644 index 000000000..311378ee2 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/image-detail-level.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Specifies the detail level of the image. + * Default: "auto". + */ +export type AzureOpenAiImageDetailLevel = 'auto' | 'low' | 'high'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/image-generations-request.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/image-generations-request.ts new file mode 100644 index 000000000..c23ce95e9 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/image-generations-request.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiImageSize } from './image-size.js'; +import type { AzureOpenAiImagesResponseFormat } from './images-response-format.js'; +import type { AzureOpenAiImageQuality } from './image-quality.js'; +import type { AzureOpenAiImageStyle } from './image-style.js'; +/** + * Representation of the 'AzureOpenAiImageGenerationsRequest' schema. + */ +export type AzureOpenAiImageGenerationsRequest = { + /** + * A text description of the desired image(s). The maximum length is 4000 characters. + * @example "a corgi in a field" + * Format: "string". + * Min Length: 1. + */ + prompt: string; + /** + * The number of images to generate. + * Default: 1. + * Maximum: 1. + * Minimum: 1. + */ + n?: number; + size?: AzureOpenAiImageSize; + response_format?: AzureOpenAiImagesResponseFormat; + /** + * A unique identifier representing your end-user, which can help to monitor and detect abuse. + * @example "user123456" + * Format: "string". + */ + user?: string; + quality?: AzureOpenAiImageQuality; + style?: AzureOpenAiImageStyle; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/image-quality.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/image-quality.ts new file mode 100644 index 000000000..552632e5d --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/image-quality.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The quality of the image that will be generated. + * Default: "standard". + */ +export type AzureOpenAiImageQuality = 'standard' | 'hd'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/image-result.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/image-result.ts new file mode 100644 index 000000000..fca5350eb --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/image-result.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiDalleContentFilterResults } from './dalle-content-filter-results.js'; +import type { AzureOpenAiDalleFilterResults } from './dalle-filter-results.js'; +/** + * The image url or encoded image if successful, and an error otherwise. + */ +export type AzureOpenAiImageResult = { + /** + * The image url. + * @example "https://www.contoso.com" + */ + url?: string; + /** + * The base64 encoded image. + */ + b64_json?: string; + content_filter_results?: AzureOpenAiDalleContentFilterResults; + /** + * The prompt that was used to generate the image, if there was any revision to the prompt. + */ + revised_prompt?: string; + prompt_filter_results?: AzureOpenAiDalleFilterResults; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/image-size.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/image-size.ts new file mode 100644 index 000000000..bc532015b --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/image-size.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The size of the generated images. + * Default: "1024x1024". + */ +export type AzureOpenAiImageSize = '1792x1024' | '1024x1792' | '1024x1024'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/image-style.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/image-style.ts new file mode 100644 index 000000000..745b573aa --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/image-style.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The style of the generated images. + * Default: "vivid". + */ +export type AzureOpenAiImageStyle = 'vivid' | 'natural'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/images-response-format.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/images-response-format.ts new file mode 100644 index 000000000..3e09c6a97 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/images-response-format.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The format in which the generated images are returned. + * Default: "url". + */ +export type AzureOpenAiImagesResponseFormat = 'url' | 'b64_json'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/index.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/index.ts new file mode 100644 index 000000000..778cdfb96 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/index.ts @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ +export * from './error-response.js'; +export * from './error-base.js'; +export * from './error.js'; +export * from './inner-error.js'; +export * from './inner-error-code.js'; +export * from './dalle-error-response.js'; +export * from './dalle-error.js'; +export * from './dalle-inner-error.js'; +export * from './content-filter-result-base.js'; +export * from './content-filter-severity-result.js'; +export * from './content-filter-detected-result.js'; +export * from './content-filter-detected-with-citation-result.js'; +export * from './content-filter-results-base.js'; +export * from './content-filter-prompt-results.js'; +export * from './content-filter-choice-results.js'; +export * from './prompt-filter-result.js'; +export * from './prompt-filter-results.js'; +export * from './dalle-content-filter-results.js'; +export * from './dalle-filter-results.js'; +export * from './chat-completions-request-common.js'; +export * from './create-chat-completion-request.js'; +export * from './chat-completion-response-format.js'; +export * from './chat-completion-function.js'; +export * from './chat-completion-function-parameters.js'; +export * from './chat-completion-request-message.js'; +export * from './chat-completion-request-message-role.js'; +export * from './chat-completion-request-message-system.js'; +export * from './chat-completion-request-message-user.js'; +export * from './chat-completion-request-message-content-part.js'; +export * from './chat-completion-request-message-content-part-type.js'; +export * from './chat-completion-request-message-content-part-text.js'; +export * from './chat-completion-request-message-content-part-image.js'; +export * from './image-detail-level.js'; +export * from './chat-completion-request-message-assistant.js'; +export * from './azure-chat-extension-configuration.js'; +export * from './azure-chat-extension-type.js'; +export * from './azure-search-chat-extension-configuration.js'; +export * from './azure-search-chat-extension-parameters.js'; +export * from './azure-search-index-field-mapping-options.js'; +export * from './azure-search-query-type.js'; +export * from './azure-cosmos-db-chat-extension-configuration.js'; +export * from './azure-cosmos-db-chat-extension-parameters.js'; +export * from './azure-cosmos-db-field-mapping-options.js'; +export * from './on-your-data-authentication-options.js'; +export * from './on-your-data-authentication-type.js'; +export * from './on-your-data-api-key-authentication-options.js'; +export * from './on-your-data-connection-string-authentication-options.js'; +export * from './on-your-data-system-assigned-managed-identity-authentication-options.js'; +export * from './on-your-data-user-assigned-managed-identity-authentication-options.js'; +export * from './on-your-data-vectorization-source.js'; +export * from './on-your-data-vectorization-source-type.js'; +export * from './on-your-data-deployment-name-vectorization-source.js'; +export * from './on-your-data-endpoint-vectorization-source.js'; +export * from './azure-chat-extensions-message-context.js'; +export * from './citation.js'; +export * from './chat-completion-message-tool-call.js'; +export * from './tool-call-type.js'; +export * from './chat-completion-request-message-tool.js'; +export * from './chat-completion-request-message-function.js'; +export * from './create-chat-completion-response.js'; +export * from './chat-completion-choice-log-probs.js'; +export * from './chat-completion-token-logprob.js'; +export * from './chat-completion-response-message.js'; +export * from './chat-completion-response-message-role.js'; +export * from './chat-completion-tool-choice-option.js'; +export * from './chat-completion-named-tool-choice.js'; +export * from './chat-completion-function-call.js'; +export * from './chat-completions-response-common.js'; +export * from './chat-completion-response-object.js'; +export * from './completion-usage.js'; +export * from './chat-completion-tool.js'; +export * from './chat-completion-tool-type.js'; +export * from './chat-completion-choice-common.js'; +export * from './create-translation-request.js'; +export * from './audio-response.js'; +export * from './audio-verbose-response.js'; +export * from './audio-response-format.js'; +export * from './create-transcription-request.js'; +export * from './audio-segment.js'; +export * from './image-quality.js'; +export * from './images-response-format.js'; +export * from './image-size.js'; +export * from './image-style.js'; +export * from './image-generations-request.js'; +export * from './generate-images-response.js'; +export * from './image-result.js'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/inner-error-code.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/inner-error-code.ts new file mode 100644 index 000000000..1cf19a661 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/inner-error-code.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Error codes for the inner error object. + */ +export type AzureOpenAiInnerErrorCode = 'ResponsibleAIPolicyViolation'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/inner-error.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/inner-error.ts new file mode 100644 index 000000000..4ece8de1e --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/inner-error.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiInnerErrorCode } from './inner-error-code.js'; +import type { AzureOpenAiContentFilterPromptResults } from './content-filter-prompt-results.js'; +/** + * Inner error with additional details. + */ +export type AzureOpenAiInnerError = { + code?: AzureOpenAiInnerErrorCode; + content_filter_results?: AzureOpenAiContentFilterPromptResults; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-api-key-authentication-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-api-key-authentication-options.ts new file mode 100644 index 000000000..9f1b70323 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-api-key-authentication-options.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataAuthenticationType } from './on-your-data-authentication-type.js'; +/** + * The authentication options for Azure OpenAI On Your Data when using an API key. + */ +export type AzureOpenAiOnYourDataApiKeyAuthenticationOptions = { + type: AzureOpenAiOnYourDataAuthenticationType; +} & { + /** + * The API key to use for authentication. + */ + key: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-authentication-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-authentication-options.ts new file mode 100644 index 000000000..2a6dcbba6 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-authentication-options.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataApiKeyAuthenticationOptions } from './on-your-data-api-key-authentication-options.js'; +import type { AzureOpenAiOnYourDataConnectionStringAuthenticationOptions } from './on-your-data-connection-string-authentication-options.js'; +import type { AzureOpenAiOnYourDataSystemAssignedManagedIdentityAuthenticationOptions } from './on-your-data-system-assigned-managed-identity-authentication-options.js'; +import type { AzureOpenAiOnYourDataUserAssignedManagedIdentityAuthenticationOptions } from './on-your-data-user-assigned-managed-identity-authentication-options.js'; +/** + * The authentication options for Azure OpenAI On Your Data. + */ +export type AzureOpenAiOnYourDataAuthenticationOptions = + | ({ type: 'api_key' } & AzureOpenAiOnYourDataApiKeyAuthenticationOptions) + | ({ + type: 'connection_string'; + } & AzureOpenAiOnYourDataConnectionStringAuthenticationOptions) + | ({ + type: 'system_assigned_managed_identity'; + } & AzureOpenAiOnYourDataSystemAssignedManagedIdentityAuthenticationOptions) + | ({ + type: 'user_assigned_managed_identity'; + } & AzureOpenAiOnYourDataUserAssignedManagedIdentityAuthenticationOptions); diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-authentication-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-authentication-type.ts new file mode 100644 index 000000000..521091857 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-authentication-type.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The authentication types supported with Azure OpenAI On Your Data. + */ +export type AzureOpenAiOnYourDataAuthenticationType = + | 'api_key' + | 'connection_string' + | 'system_assigned_managed_identity' + | 'user_assigned_managed_identity'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-connection-string-authentication-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-connection-string-authentication-options.ts new file mode 100644 index 000000000..45214ba39 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-connection-string-authentication-options.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataAuthenticationType } from './on-your-data-authentication-type.js'; +/** + * The authentication options for Azure OpenAI On Your Data when using a connection string. + */ +export type AzureOpenAiOnYourDataConnectionStringAuthenticationOptions = { + type: AzureOpenAiOnYourDataAuthenticationType; +} & { + /** + * The connection string to use for authentication. + */ + connection_string: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-deployment-name-vectorization-source.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-deployment-name-vectorization-source.ts new file mode 100644 index 000000000..55bd730bc --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-deployment-name-vectorization-source.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataVectorizationSourceType } from './on-your-data-vectorization-source-type.js'; +/** + * The details of a a vectorization source, used by Azure OpenAI On Your Data when applying vector search, that is based + * on an internal embeddings model deployment name in the same Azure OpenAI resource. + */ +export type AzureOpenAiOnYourDataDeploymentNameVectorizationSource = { + type: AzureOpenAiOnYourDataVectorizationSourceType; +} & { + /** + * Specifies the name of the model deployment to use for vectorization. This model deployment must be in the same Azure OpenAI resource, but On Your Data will use this model deployment via an internal call rather than a public one, which enables vector search even in private networks. + */ + deployment_name: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-endpoint-vectorization-source.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-endpoint-vectorization-source.ts new file mode 100644 index 000000000..f8246dadb --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-endpoint-vectorization-source.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataVectorizationSourceType } from './on-your-data-vectorization-source-type.js'; +import type { AzureOpenAiOnYourDataApiKeyAuthenticationOptions } from './on-your-data-api-key-authentication-options.js'; +/** + * The details of a a vectorization source, used by Azure OpenAI On Your Data when applying vector search, that is based + * on a public Azure OpenAI endpoint call for embeddings. + */ +export type AzureOpenAiOnYourDataEndpointVectorizationSource = { + type: AzureOpenAiOnYourDataVectorizationSourceType; +} & { + authentication: AzureOpenAiOnYourDataApiKeyAuthenticationOptions; + /** + * Specifies the endpoint to use for vectorization. This endpoint must be in the same Azure OpenAI resource, but On Your Data will use this endpoint via an internal call rather than a public one, which enables vector search even in private networks. + * Format: "uri". + */ + endpoint: string; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-system-assigned-managed-identity-authentication-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-system-assigned-managed-identity-authentication-options.ts new file mode 100644 index 000000000..ca802b80f --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-system-assigned-managed-identity-authentication-options.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataAuthenticationType } from './on-your-data-authentication-type.js'; +/** + * The authentication options for Azure OpenAI On Your Data when using a system-assigned managed identity. + */ +export type AzureOpenAiOnYourDataSystemAssignedManagedIdentityAuthenticationOptions = + { + type: AzureOpenAiOnYourDataAuthenticationType; + }; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-user-assigned-managed-identity-authentication-options.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-user-assigned-managed-identity-authentication-options.ts new file mode 100644 index 000000000..d6badf1dc --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-user-assigned-managed-identity-authentication-options.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataAuthenticationType } from './on-your-data-authentication-type.js'; +/** + * The authentication options for Azure OpenAI On Your Data when using a user-assigned managed identity. + */ +export type AzureOpenAiOnYourDataUserAssignedManagedIdentityAuthenticationOptions = + { + type: AzureOpenAiOnYourDataAuthenticationType; + } & { + /** + * The resource ID of the user-assigned managed identity to use for authentication. + */ + managed_identity_resource_id: string; + } & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-vectorization-source-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-vectorization-source-type.ts new file mode 100644 index 000000000..6a6fec986 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-vectorization-source-type.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * Represents the available sources Azure OpenAI On Your Data can use to configure vectorization of data for use with + * vector search. + */ +export type AzureOpenAiOnYourDataVectorizationSourceType = + | 'endpoint' + | 'deployment_name'; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-vectorization-source.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-vectorization-source.ts new file mode 100644 index 000000000..b114c1ddc --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/on-your-data-vectorization-source.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiOnYourDataEndpointVectorizationSource } from './on-your-data-endpoint-vectorization-source.js'; +import type { AzureOpenAiOnYourDataDeploymentNameVectorizationSource } from './on-your-data-deployment-name-vectorization-source.js'; +/** + * An abstract representation of a vectorization source for Azure OpenAI On Your Data with vector search. + */ +export type AzureOpenAiOnYourDataVectorizationSource = + | ({ type: 'endpoint' } & AzureOpenAiOnYourDataEndpointVectorizationSource) + | ({ + type: 'deployment_name'; + } & AzureOpenAiOnYourDataDeploymentNameVectorizationSource); diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/prompt-filter-result.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/prompt-filter-result.ts new file mode 100644 index 000000000..db10f5602 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/prompt-filter-result.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiContentFilterPromptResults } from './content-filter-prompt-results.js'; +/** + * Content filtering results for a single prompt in the request. + */ +export type AzureOpenAiPromptFilterResult = { + prompt_index?: number; + content_filter_results?: AzureOpenAiContentFilterPromptResults; +} & Record; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/prompt-filter-results.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/prompt-filter-results.ts new file mode 100644 index 000000000..2e7b800d6 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/prompt-filter-results.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 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 { AzureOpenAiPromptFilterResult } from './prompt-filter-result.js'; +/** + * Content filtering results for zero or more prompts in the request. In a streaming request, results for different prompts may arrive at different times or in different orders. + */ +export type AzureOpenAiPromptFilterResults = AzureOpenAiPromptFilterResult[]; diff --git a/packages/foundation-models/src/azure-openai/client/inference/schema/tool-call-type.ts b/packages/foundation-models/src/azure-openai/client/inference/schema/tool-call-type.ts new file mode 100644 index 000000000..e8a643d0e --- /dev/null +++ b/packages/foundation-models/src/azure-openai/client/inference/schema/tool-call-type.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + * + * This is a generated file powered by the SAP Cloud SDK for JavaScript. + */ + +/** + * The type of the tool call, in this case `function`. + */ +export type AzureOpenAiToolCallType = 'function'; diff --git a/packages/foundation-models/src/azure-openai/index.ts b/packages/foundation-models/src/azure-openai/index.ts index b98a9e8a5..432cf7a68 100644 --- a/packages/foundation-models/src/azure-openai/index.ts +++ b/packages/foundation-models/src/azure-openai/index.ts @@ -1,4 +1,4 @@ -export * from './azure-openai-types.js'; +export * from './azure-openai-embedding-types.js'; export * from './azure-openai-chat-client.js'; export * from './azure-openai-embedding-client.js'; export * from './azure-openai-chat-completion-response.js'; diff --git a/packages/foundation-models/src/azure-openai/model-types.ts b/packages/foundation-models/src/azure-openai/model-types.ts index defa6e8b7..1e6bcae14 100644 --- a/packages/foundation-models/src/azure-openai/model-types.ts +++ b/packages/foundation-models/src/azure-openai/model-types.ts @@ -3,6 +3,10 @@ import type { AzureOpenAiEmbeddingModel as CoreAzureOpenAiEmbeddingModel } from '@sap-ai-sdk/core'; +/** + * @internal + */ +export const apiVersion = '2024-06-01'; /** * Azure OpenAI models for chat completion. */ diff --git a/packages/foundation-models/src/azure-openai/spec/inference.yaml b/packages/foundation-models/src/azure-openai/spec/inference.yaml new file mode 100644 index 000000000..859388dd6 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/spec/inference.yaml @@ -0,0 +1,2084 @@ +openapi: 3.0.0 +info: + title: Azure OpenAI Service API + description: Azure OpenAI APIs for completions and search + version: '2024-06-01' +servers: + - url: https://{endpoint}/openai + variables: + endpoint: + default: your-resource-name.openai.azure.com +security: + - bearer: + - api.read + - apiKey: [] +paths: + /deployments/{deployment-id}/completions: + post: + summary: Creates a completion for the provided prompt, parameters and chosen model. + operationId: Completions_Create + parameters: + - in: path + name: deployment-id + required: true + schema: + type: string + example: davinci + description: Deployment id of the model which was deployed. + - in: query + name: api-version + required: true + schema: + type: string + example: 2024-06-01 + description: api version + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + prompt: + description: |- + The prompt(s) to generate completions for, encoded as a string or array of strings. + Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. Maximum allowed size of string list is 2048. + oneOf: + - type: string + default: '' + example: This is a test. + nullable: true + - type: array + items: + type: string + default: '' + example: This is a test. + nullable: false + description: Array size minimum of 1 and maximum of 2048 + max_tokens: + description: The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096). Has minimum of 0. + type: integer + default: 16 + example: 16 + nullable: true + temperature: + description: |- + What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. + We generally recommend altering this or top_p but not both. + type: number + default: 1 + example: 1 + nullable: true + top_p: + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + We generally recommend altering this or temperature but not both. + type: number + default: 1 + example: 1 + nullable: true + logit_bias: + description: Defaults to null. Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this tokenizer tool (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. As an example, you can pass {"50256" : -100} to prevent the <|endoftext|> token from being generated. + type: object + nullable: false + user: + description: A unique identifier representing your end-user, which can help monitoring and detecting abuse + type: string + nullable: false + 'n': + description: |- + How many completions to generate for each prompt. Minimum of 1 and maximum of 128 allowed. + Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop. + type: integer + default: 1 + example: 1 + nullable: true + stream: + description: 'Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.' + type: boolean + nullable: true + default: false + logprobs: + description: |- + Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response. + Minimum of 0 and maximum of 5 allowed. + type: integer + default: null + nullable: true + suffix: + type: string + nullable: true + description: The suffix that comes after a completion of inserted text. + echo: + description: Echo back the prompt in addition to the completion + type: boolean + default: false + nullable: true + stop: + description: Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. + oneOf: + - type: string + default: <|endoftext|> + example: |+ + nullable: true + - type: array + items: + type: string + example: |+ + nullable: false + description: Array minimum size of 1 and maximum of 4 + completion_config: + type: string + nullable: true + presence_penalty: + description: Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + type: number + default: 0 + frequency_penalty: + description: Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + type: number + default: 0 + best_of: + description: |- + Generates best_of completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed. + When used with n, best_of controls the number of candidate completions and n specifies how many to return - best_of must be greater than n. + Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop. Has maximum value of 128. + type: integer + example: + prompt: |- + Negate the following sentence.The price for bubblegum increased on thursday. + Negated Sentence: + max_tokens: 50 + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: string + object: + type: string + created: + type: integer + model: + type: string + prompt_filter_results: + $ref: '#/components/schemas/promptFilterResults' + choices: + type: array + items: + type: object + properties: + text: + type: string + index: + type: integer + logprobs: + type: object + properties: + tokens: + type: array + items: + type: string + token_logprobs: + type: array + items: + type: number + top_logprobs: + type: array + items: + type: object + additionalProperties: + type: number + text_offset: + type: array + items: + type: integer + nullable: true + finish_reason: + type: string + content_filter_results: + $ref: '#/components/schemas/contentFilterChoiceResults' + usage: + type: object + properties: + completion_tokens: + type: number + format: int32 + prompt_tokens: + type: number + format: int32 + total_tokens: + type: number + format: int32 + required: + - prompt_tokens + - total_tokens + - completion_tokens + required: + - id + - object + - created + - model + - choices + example: + model: davinci + object: text_completion + id: cmpl-4509KAos68kxOqpE2uYGw81j6m7uo + created: 1637097562 + choices: + - index: 0 + text: The price for bubblegum decreased on thursday. + logprobs: null + finish_reason: stop + headers: + apim-request-id: + description: Request ID for troubleshooting purposes + schema: + type: string + default: + description: Service unavailable + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + headers: + apim-request-id: + description: Request ID for troubleshooting purposes + schema: + type: string + /deployments/{deployment-id}/embeddings: + post: + summary: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. + operationId: embeddings_create + parameters: + - in: path + name: deployment-id + required: true + schema: + type: string + example: ada-search-index-v1 + description: The deployment id of the model which was deployed. + - in: query + name: api-version + required: true + schema: + type: string + example: '2024-06-01' + description: api version + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: true + properties: + input: + description: |- + Input text to get embeddings for, encoded as a string. To get embeddings for multiple inputs in a single request, pass an array of strings. Each input must not exceed 2048 tokens in length. + Unless you are embedding code, we suggest replacing newlines (\n) in your input with a single space, as we have observed inferior results when newlines are present. + oneOf: + - type: string + default: '' + example: This is a test. + nullable: true + - type: array + minItems: 1 + maxItems: 2048 + items: + type: string + minLength: 1 + example: This is a test. + nullable: false + user: + description: A unique identifier representing your end-user, which can help monitoring and detecting abuse. + type: string + nullable: false + input_type: + description: input type of embedding search to use + type: string + example: query + encoding_format: + description: The format to return the embeddings in. Can be either `float` or `base64`. Defaults to `float`. + type: string + example: base64 + nullable: true + dimensions: + description: The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models. + type: integer + example: 1 + nullable: true + required: + - input + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + object: + type: string + model: + type: string + data: + type: array + items: + type: object + properties: + index: + type: integer + object: + type: string + embedding: + type: array + items: + type: number + required: + - index + - object + - embedding + usage: + type: object + properties: + prompt_tokens: + type: integer + total_tokens: + type: integer + required: + - prompt_tokens + - total_tokens + required: + - object + - model + - data + - usage + # x-ms-examples: + # Create a embeddings.: + # $ref: ./examples/embeddings.yaml + /deployments/{deployment-id}/chat/completions: + post: + summary: Creates a completion for the chat message + operationId: ChatCompletions_Create + parameters: + - in: path + name: deployment-id + required: true + schema: + type: string + description: Deployment id of the model which was deployed. + - in: query + name: api-version + required: true + schema: + type: string + example: '2024-06-01' + description: api version + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/createChatCompletionRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/createChatCompletionResponse' + headers: + apim-request-id: + description: Request ID for troubleshooting purposes + schema: + type: string + default: + description: Service unavailable + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + headers: + apim-request-id: + description: Request ID for troubleshooting purposes + schema: + type: string + # x-ms-examples: + # Create a chat completion.: + # $ref: ./examples/chat_completions.yaml + # Creates a completion based on Azure Search data and system-assigned managed identity.: + # $ref: ./examples/chat_completions_azure_search_minimum.yaml + # Creates a completion based on Azure Search vector data, previous assistant message and user-assigned managed identity.: + # $ref: ./examples/chat_completions_azure_search_advanced.yaml + # Creates a completion for the provided Azure Cosmos DB.: + # $ref: ./examples/chat_completions_cosmos_db.yaml + /deployments/{deployment-id}/audio/transcriptions: + post: + summary: Transcribes audio into the input language. + operationId: Transcriptions_Create + parameters: + - in: path + name: deployment-id + required: true + schema: + type: string + example: whisper + description: Deployment id of the whisper model. + - in: query + name: api-version + required: true + schema: + type: string + example: '2024-06-01' + description: api version + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/createTranscriptionRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/audioResponse' + - $ref: '#/components/schemas/audioVerboseResponse' + text/plain: + schema: + type: string + description: Transcribed text in the output format (when response_format was one of text, vtt or srt). + # x-ms-examples: + # Create an audio transcription with json response format.: + # $ref: ./examples/audio_transcription_object.yaml + # Create an audio transcription with text response format.: + # $ref: ./examples/audio_transcription_text.yaml + /deployments/{deployment-id}/audio/translations: + post: + summary: Transcribes and translates input audio into English text. + operationId: Translations_Create + parameters: + - in: path + name: deployment-id + required: true + schema: + type: string + example: whisper + description: Deployment id of the whisper model which was deployed. + - in: query + name: api-version + required: true + schema: + type: string + example: '2024-06-01' + description: api version + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/createTranslationRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/audioResponse' + - $ref: '#/components/schemas/audioVerboseResponse' + text/plain: + schema: + type: string + description: Transcribed text in the output format (when response_format was one of text, vtt or srt). + # x-ms-examples: + # Create an audio translation with json response format.: + # $ref: ./examples/audio_translation_object.yaml + # Create an audio translation with text response format.: + # $ref: ./examples/audio_translation_text.yaml + /deployments/{deployment-id}/images/generations: + post: + summary: Generates a batch of images from a text caption on a given DALLE model deployment + operationId: ImageGenerations_Create + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/imageGenerationsRequest' + parameters: + - in: path + name: deployment-id + required: true + schema: + type: string + example: dalle-deployment + description: Deployment id of the dalle model which was deployed. + - in: query + name: api-version + required: true + schema: + type: string + example: '2024-06-01' + description: api version + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/generateImagesResponse' + default: + description: An error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/dalleErrorResponse' + # x-ms-examples: + # Create an image.: + # $ref: ./examples/image_generation.yaml +components: + schemas: + errorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/error' + errorBase: + type: object + properties: + code: + type: string + message: + type: string + error: + type: object + allOf: + - $ref: '#/components/schemas/errorBase' + properties: + param: + type: string + type: + type: string + inner_error: + $ref: '#/components/schemas/innerError' + innerError: + description: Inner error with additional details. + type: object + properties: + code: + $ref: '#/components/schemas/innerErrorCode' + content_filter_results: + $ref: '#/components/schemas/contentFilterPromptResults' + innerErrorCode: + description: Error codes for the inner error object. + enum: + - ResponsibleAIPolicyViolation + type: string + x-ms-enum: + name: InnerErrorCode + modelAsString: true + values: + - value: ResponsibleAIPolicyViolation + description: The prompt violated one of more content filter rules. + dalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/dalleError' + dalleError: + type: object + allOf: + - $ref: '#/components/schemas/errorBase' + properties: + param: + type: string + type: + type: string + inner_error: + $ref: '#/components/schemas/dalleInnerError' + dalleInnerError: + description: Inner error with additional details. + type: object + properties: + code: + $ref: '#/components/schemas/innerErrorCode' + content_filter_results: + $ref: '#/components/schemas/dalleFilterResults' + revised_prompt: + type: string + description: The prompt that was used to generate the image, if there was any revision to the prompt. + contentFilterResultBase: + type: object + properties: + filtered: + type: boolean + required: + - filtered + contentFilterSeverityResult: + type: object + allOf: + - $ref: '#/components/schemas/contentFilterResultBase' + - properties: + severity: + type: string + enum: + - safe + - low + - medium + - high + x-ms-enum: + name: ContentFilterSeverity + modelAsString: true + values: + - value: safe + description: General content or related content in generic or non-harmful contexts. + - value: low + description: Harmful content at a low intensity and risk level. + - value: medium + description: Harmful content at a medium intensity and risk level. + - value: high + description: Harmful content at a high intensity and risk level. + required: + - severity + - filtered + contentFilterDetectedResult: + type: object + allOf: + - $ref: '#/components/schemas/contentFilterResultBase' + - properties: + detected: + type: boolean + required: + - detected + - filtered + contentFilterDetectedWithCitationResult: + type: object + allOf: + - $ref: '#/components/schemas/contentFilterDetectedResult' + - properties: + citation: + type: object + properties: + URL: + type: string + license: + type: string + required: + - detected + - filtered + contentFilterResultsBase: + type: object + description: Information about the content filtering results. + properties: + sexual: + $ref: '#/components/schemas/contentFilterSeverityResult' + violence: + $ref: '#/components/schemas/contentFilterSeverityResult' + hate: + $ref: '#/components/schemas/contentFilterSeverityResult' + self_harm: + $ref: '#/components/schemas/contentFilterSeverityResult' + profanity: + $ref: '#/components/schemas/contentFilterDetectedResult' + error: + $ref: '#/components/schemas/errorBase' + contentFilterPromptResults: + type: object + description: Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about jailbreak content and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id. + allOf: + - $ref: '#/components/schemas/contentFilterResultsBase' + - properties: + jailbreak: + $ref: '#/components/schemas/contentFilterDetectedResult' + contentFilterChoiceResults: + type: object + description: Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about third party text and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id. + allOf: + - $ref: '#/components/schemas/contentFilterResultsBase' + - properties: + protected_material_text: + $ref: '#/components/schemas/contentFilterDetectedResult' + - properties: + protected_material_code: + $ref: '#/components/schemas/contentFilterDetectedWithCitationResult' + promptFilterResult: + type: object + description: Content filtering results for a single prompt in the request. + properties: + prompt_index: + type: integer + content_filter_results: + $ref: '#/components/schemas/contentFilterPromptResults' + promptFilterResults: + type: array + description: Content filtering results for zero or more prompts in the request. In a streaming request, results for different prompts may arrive at different times or in different orders. + items: + $ref: '#/components/schemas/promptFilterResult' + dalleContentFilterResults: + type: object + description: Information about the content filtering results. + properties: + sexual: + $ref: '#/components/schemas/contentFilterSeverityResult' + violence: + $ref: '#/components/schemas/contentFilterSeverityResult' + hate: + $ref: '#/components/schemas/contentFilterSeverityResult' + self_harm: + $ref: '#/components/schemas/contentFilterSeverityResult' + dalleFilterResults: + type: object + description: Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about jailbreak content and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id. + allOf: + - $ref: '#/components/schemas/dalleContentFilterResults' + - properties: + profanity: + $ref: '#/components/schemas/contentFilterDetectedResult' + jailbreak: + $ref: '#/components/schemas/contentFilterDetectedResult' + chatCompletionsRequestCommon: + type: object + properties: + temperature: + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + We generally recommend altering this or `top_p` but not both. + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + top_p: + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + We generally recommend altering this or `temperature` but not both. + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + stream: + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message.' + type: boolean + nullable: true + default: false + stop: + description: Up to 4 sequences where the API will stop generating further tokens. + oneOf: + - type: string + nullable: true + - type: array + items: + type: string + nullable: false + minItems: 1 + maxItems: 4 + description: Array minimum size of 1 and maximum of 4 + default: null + max_tokens: + description: The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens). + type: integer + default: 4096 + presence_penalty: + description: Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + type: number + default: 0 + minimum: -2 + maximum: 2 + frequency_penalty: + description: Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + type: number + default: 0 + minimum: -2 + maximum: 2 + logit_bias: + description: Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + type: object + nullable: true + user: + description: A unique identifier representing your end-user, which can help Azure OpenAI to monitor and detect abuse. + type: string + example: user-1234 + nullable: false + createChatCompletionRequest: + type: object + allOf: + - $ref: '#/components/schemas/chatCompletionsRequestCommon' + - properties: + messages: + description: A list of messages comprising the conversation so far. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb). + type: array + minItems: 1 + items: + $ref: '#/components/schemas/chatCompletionRequestMessage' + data_sources: + type: array + description: |2- + The configuration entries for Azure OpenAI chat extensions that use them. + This additional specification is only compatible with Azure OpenAI. + items: + $ref: '#/components/schemas/azureChatExtensionConfiguration' + 'n': + type: integer + minimum: 1 + maximum: 128 + default: 1 + example: 1 + nullable: true + description: How many chat completion choices to generate for each input message. + seed: + type: integer + minimum: -9223372036854775808 + maximum: 9223372036854775807 + default: 0 + example: 1 + nullable: true + description: If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + logprobs: + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. This option is currently not available on the `gpt-4-vision-preview` model. + type: boolean + default: false + nullable: true + top_logprobs: + description: An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + type: integer + minimum: 0 + maximum: 5 + nullable: true + response_format: + type: object + description: An object specifying the format that the model must output. Used to enable JSON mode. + properties: + type: + $ref: '#/components/schemas/chatCompletionResponseFormat' + tools: + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. + type: array + minItems: 1 + items: + $ref: '#/components/schemas/chatCompletionTool' + tool_choice: + $ref: '#/components/schemas/chatCompletionToolChoiceOption' + functions: + description: Deprecated in favor of `tools`. A list of functions the model may generate JSON inputs for. + type: array + minItems: 1 + maxItems: 128 + items: + $ref: '#/components/schemas/chatCompletionFunction' + function_call: + description: Deprecated in favor of `tool_choice`. Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. Specifying a particular function via `{"name":\ "my_function"}` forces the model to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present. + oneOf: + - type: string + enum: + - none + - auto + description: '`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.' + - type: object + description: 'Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.' + properties: + name: + type: string + description: The name of the function to call. + required: + - name + required: + - messages + chatCompletionResponseFormat: + type: string + enum: + - text + - json_object + default: text + example: json_object + nullable: true + description: Setting to `json_object` enables JSON mode. This guarantees that the message the model generates is valid JSON. + x-ms-enum: + name: ChatCompletionResponseFormat + modelAsString: true + values: + - value: text + description: Response format is a plain text string. + - value: json_object + description: Response format is a JSON object. + chatCompletionFunction: + type: object + properties: + 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. + description: + type: string + description: The description of what the function does. + parameters: + $ref: '#/components/schemas/chatCompletionFunctionParameters' + required: + - name + chatCompletionFunctionParameters: + type: object + description: The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + additionalProperties: true + chatCompletionRequestMessage: + type: object + properties: + role: + $ref: '#/components/schemas/chatCompletionRequestMessageRole' + discriminator: + propertyName: role + mapping: + system: '#/components/schemas/chatCompletionRequestMessageSystem' + user: '#/components/schemas/chatCompletionRequestMessageUser' + assistant: '#/components/schemas/chatCompletionRequestMessageAssistant' + tool: '#/components/schemas/chatCompletionRequestMessageTool' + function: '#/components/schemas/chatCompletionRequestMessageFunction' + required: + - role + chatCompletionRequestMessageRole: + type: string + enum: + - system + - user + - assistant + - tool + - function + description: The role of the messages author. + x-ms-enum: + name: ChatCompletionRequestMessageRole + modelAsString: true + values: + - value: system + description: The message author role is system. + - value: user + description: The message author role is user. + - value: assistant + description: The message author role is assistant. + - value: tool + description: The message author role is tool. + - value: function + description: Deprecated. The message author role is function. + chatCompletionRequestMessageSystem: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessage' + - type: object + properties: + content: + type: string + description: The contents of the message. + nullable: true + required: + - content + chatCompletionRequestMessageUser: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessage' + - type: object + properties: + content: + oneOf: + - type: string + description: The contents of the message. + - type: array + description: An array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts. Image input is only supported when using the `gpt-4-visual-preview` model. + minimum: 1 + items: + $ref: '#/components/schemas/chatCompletionRequestMessageContentPart' + nullable: true + required: + - content + chatCompletionRequestMessageContentPart: + type: object + properties: + type: + $ref: '#/components/schemas/chatCompletionRequestMessageContentPartType' + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/chatCompletionRequestMessageContentPartText' + image_url: '#/components/schemas/chatCompletionRequestMessageContentPartImage' + required: + - type + chatCompletionRequestMessageContentPartType: + type: string + enum: + - text + - image_url + description: The type of the content part. + x-ms-enum: + name: ChatCompletionRequestMessageContentPartType + modelAsString: true + values: + - value: text + description: The content part type is text. + - value: image_url + description: The content part type is image_url. + chatCompletionRequestMessageContentPartText: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessageContentPart' + - type: object + properties: + text: + type: string + description: The text content. + required: + - text + chatCompletionRequestMessageContentPartImage: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessageContentPart' + - type: object + properties: + url: + type: string + description: Either a URL of the image or the base64 encoded image data. + format: uri + detail: + $ref: '#/components/schemas/imageDetailLevel' + required: + - url + imageDetailLevel: + type: string + description: Specifies the detail level of the image. + enum: + - auto + - low + - high + default: auto + x-ms-enum: + name: ImageDetailLevel + modelAsString: true + values: + - value: auto + description: The image detail level is auto. + - value: low + description: The image detail level is low. + - value: high + description: The image detail level is high. + chatCompletionRequestMessageAssistant: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessage' + - type: object + properties: + content: + type: string + description: The contents of the message. + nullable: true + tool_calls: + type: array + description: The tool calls generated by the model, such as function calls. + items: + $ref: '#/components/schemas/chatCompletionMessageToolCall' + context: + $ref: '#/components/schemas/azureChatExtensionsMessageContext' + required: + - content + azureChatExtensionConfiguration: + required: + - type + type: object + properties: + type: + $ref: '#/components/schemas/azureChatExtensionType' + description: |2- + A representation of configuration data for a single Azure OpenAI chat extension. This will be used by a chat + completions request that should use Azure OpenAI chat extensions to augment the response behavior. + The use of this configuration is compatible only with Azure OpenAI. + discriminator: + propertyName: type + mapping: + azure_search: '#/components/schemas/azureSearchChatExtensionConfiguration' + azure_cosmos_db: '#/components/schemas/azureCosmosDBChatExtensionConfiguration' + azureChatExtensionType: + type: string + description: |2- + A representation of configuration data for a single Azure OpenAI chat extension. This will be used by a chat + completions request that should use Azure OpenAI chat extensions to augment the response behavior. + The use of this configuration is compatible only with Azure OpenAI. + enum: + - azure_search + - azure_cosmos_db + x-ms-enum: + name: AzureChatExtensionType + modelAsString: true + values: + - name: azureSearch + value: azure_search + description: Represents the use of Azure Search as an Azure OpenAI chat extension. + - name: azureCosmosDB + value: azure_cosmos_db + description: Represents the use of Azure Cosmos DB as an Azure OpenAI chat extension. + azureSearchChatExtensionConfiguration: + required: + - parameters + description: |- + A specific representation of configurable options for Azure Search when using it as an Azure OpenAI chat + extension. + allOf: + - $ref: '#/components/schemas/azureChatExtensionConfiguration' + - properties: + parameters: + $ref: '#/components/schemas/azureSearchChatExtensionParameters' + x-ms-discriminator-value: azure_search + azureSearchChatExtensionParameters: + required: + - authentication + - endpoint + - index_name + type: object + properties: + authentication: + oneOf: + - $ref: '#/components/schemas/onYourDataApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/onYourDataSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/onYourDataUserAssignedManagedIdentityAuthenticationOptions' + top_n_documents: + type: integer + description: The configured top number of documents to feature for the configured query. + format: int32 + in_scope: + type: boolean + description: Whether queries should be restricted to use of indexed data. + strictness: + maximum: 5 + minimum: 1 + type: integer + description: The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but lower recall of the answer. + format: int32 + role_information: + type: string + description: Give the model instructions about how it should behave and any context it should reference when generating a response. You can describe the assistant's personality and tell it how to format responses. There's a 100 token limit for it, and it counts against the overall token limit. + endpoint: + type: string + description: The absolute endpoint path for the Azure Search resource to use. + format: uri + index_name: + type: string + description: The name of the index to use as available in the referenced Azure Search resource. + fields_mapping: + $ref: '#/components/schemas/azureSearchIndexFieldMappingOptions' + query_type: + $ref: '#/components/schemas/azureSearchQueryType' + semantic_configuration: + type: string + description: The additional semantic configuration for the query. + filter: + type: string + description: Search filter. + embedding_dependency: + oneOf: + - $ref: '#/components/schemas/onYourDataEndpointVectorizationSource' + - $ref: '#/components/schemas/onYourDataDeploymentNameVectorizationSource' + description: Parameters for Azure Search when used as an Azure OpenAI chat extension. + azureSearchIndexFieldMappingOptions: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + description: The names of index fields that should be treated as content. + items: + type: string + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + description: The names of fields that represent vector data. + items: + type: string + description: Optional settings to control how fields are processed when using a configured Azure Search resource. + azureSearchQueryType: + type: string + description: The type of Azure Search retrieval query that should be executed when using it as an Azure OpenAI chat extension. + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + x-ms-enum: + name: azureSearchQueryType + modelAsString: true + values: + - name: simple + value: simple + description: Represents the default, simple query parser. + - name: semantic + value: semantic + description: Represents the semantic query parser for advanced semantic modeling. + - name: vector + value: vector + description: Represents vector search over computed data. + - name: vectorSimpleHybrid + value: vector_simple_hybrid + description: Represents a combination of the simple query strategy with vector data. + - name: vectorSemanticHybrid + value: vector_semantic_hybrid + description: Represents a combination of semantic search and vector data querying. + azureCosmosDBChatExtensionConfiguration: + required: + - parameters + description: |- + A specific representation of configurable options for Azure Cosmos DB when using it as an Azure OpenAI chat + extension. + allOf: + - $ref: '#/components/schemas/azureChatExtensionConfiguration' + - properties: + parameters: + $ref: '#/components/schemas/azureCosmosDBChatExtensionParameters' + x-ms-discriminator-value: azure_cosmos_db + azureCosmosDBChatExtensionParameters: + required: + - authentication + - container_name + - database_name + - embedding_dependency + - fields_mapping + - index_name + type: object + properties: + authentication: + $ref: '#/components/schemas/onYourDataConnectionStringAuthenticationOptions' + top_n_documents: + type: integer + description: The configured top number of documents to feature for the configured query. + format: int32 + in_scope: + type: boolean + description: Whether queries should be restricted to use of indexed data. + strictness: + maximum: 5 + minimum: 1 + type: integer + description: The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but lower recall of the answer. + format: int32 + role_information: + type: string + description: Give the model instructions about how it should behave and any context it should reference when generating a response. You can describe the assistant's personality and tell it how to format responses. There's a 100 token limit for it, and it counts against the overall token limit. + database_name: + type: string + description: The MongoDB vCore database name to use with Azure Cosmos DB. + container_name: + type: string + description: The name of the Azure Cosmos DB resource container. + index_name: + type: string + description: The MongoDB vCore index name to use with Azure Cosmos DB. + fields_mapping: + $ref: '#/components/schemas/azureCosmosDBFieldMappingOptions' + embedding_dependency: + oneOf: + - $ref: '#/components/schemas/onYourDataEndpointVectorizationSource' + - $ref: '#/components/schemas/onYourDataDeploymentNameVectorizationSource' + description: |- + Parameters to use when configuring Azure OpenAI On Your Data chat extensions when using Azure Cosmos DB for + MongoDB vCore. + azureCosmosDBFieldMappingOptions: + required: + - content_fields + - vector_fields + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + description: The names of index fields that should be treated as content. + items: + type: string + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + description: The names of fields that represent vector data. + items: + type: string + description: Optional settings to control how fields are processed when using a configured Azure Cosmos DB resource. + onYourDataAuthenticationOptions: + required: + - type + type: object + properties: + type: + $ref: '#/components/schemas/onYourDataAuthenticationType' + description: The authentication options for Azure OpenAI On Your Data. + discriminator: + propertyName: type + mapping: + api_key: '#/components/schemas/onYourDataApiKeyAuthenticationOptions' + connection_string: '#/components/schemas/onYourDataConnectionStringAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/onYourDataSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/onYourDataUserAssignedManagedIdentityAuthenticationOptions' + onYourDataAuthenticationType: + type: string + description: The authentication types supported with Azure OpenAI On Your Data. + enum: + - api_key + - connection_string + - system_assigned_managed_identity + - user_assigned_managed_identity + x-ms-enum: + name: OnYourDataAuthenticationType + modelAsString: true + values: + - name: apiKey + value: api_key + description: Authentication via API key. + - name: connectionString + value: connection_string + description: Authentication via connection string. + - name: systemAssignedManagedIdentity + value: system_assigned_managed_identity + description: Authentication via system-assigned managed identity. + - name: userAssignedManagedIdentity + value: user_assigned_managed_identity + description: Authentication via user-assigned managed identity. + onYourDataApiKeyAuthenticationOptions: + required: + - key + description: The authentication options for Azure OpenAI On Your Data when using an API key. + allOf: + - $ref: '#/components/schemas/onYourDataAuthenticationOptions' + - properties: + key: + type: string + description: The API key to use for authentication. + x-ms-discriminator-value: api_key + onYourDataConnectionStringAuthenticationOptions: + required: + - connection_string + description: The authentication options for Azure OpenAI On Your Data when using a connection string. + allOf: + - $ref: '#/components/schemas/onYourDataAuthenticationOptions' + - properties: + connection_string: + type: string + description: The connection string to use for authentication. + x-ms-discriminator-value: connection_string + onYourDataSystemAssignedManagedIdentityAuthenticationOptions: + description: The authentication options for Azure OpenAI On Your Data when using a system-assigned managed identity. + allOf: + - $ref: '#/components/schemas/onYourDataAuthenticationOptions' + x-ms-discriminator-value: system_assigned_managed_identity + onYourDataUserAssignedManagedIdentityAuthenticationOptions: + required: + - managed_identity_resource_id + description: The authentication options for Azure OpenAI On Your Data when using a user-assigned managed identity. + allOf: + - $ref: '#/components/schemas/onYourDataAuthenticationOptions' + - properties: + managed_identity_resource_id: + type: string + description: The resource ID of the user-assigned managed identity to use for authentication. + x-ms-discriminator-value: user_assigned_managed_identity + onYourDataVectorizationSource: + required: + - type + type: object + properties: + type: + $ref: '#/components/schemas/onYourDataVectorizationSourceType' + description: An abstract representation of a vectorization source for Azure OpenAI On Your Data with vector search. + discriminator: + propertyName: type + mapping: + endpoint: '#/components/schemas/onYourDataEndpointVectorizationSource' + deployment_name: '#/components/schemas/onYourDataDeploymentNameVectorizationSource' + onYourDataVectorizationSourceType: + type: string + description: |- + Represents the available sources Azure OpenAI On Your Data can use to configure vectorization of data for use with + vector search. + enum: + - endpoint + - deployment_name + x-ms-enum: + name: OnYourDataVectorizationSourceType + modelAsString: true + values: + - name: endpoint + value: endpoint + description: Represents vectorization performed by public service calls to an Azure OpenAI embedding model. + - name: deploymentName + value: deployment_name + description: |- + Represents an Ada model deployment name to use. This model deployment must be in the same Azure OpenAI resource, but + On Your Data will use this model deployment via an internal call rather than a public one, which enables vector + search even in private networks. + onYourDataDeploymentNameVectorizationSource: + required: + - deployment_name + description: |- + The details of a a vectorization source, used by Azure OpenAI On Your Data when applying vector search, that is based + on an internal embeddings model deployment name in the same Azure OpenAI resource. + allOf: + - $ref: '#/components/schemas/onYourDataVectorizationSource' + - properties: + deployment_name: + type: string + description: Specifies the name of the model deployment to use for vectorization. This model deployment must be in the same Azure OpenAI resource, but On Your Data will use this model deployment via an internal call rather than a public one, which enables vector search even in private networks. + x-ms-discriminator-value: deployment_name + onYourDataEndpointVectorizationSource: + required: + - authentication + - endpoint + description: |- + The details of a a vectorization source, used by Azure OpenAI On Your Data when applying vector search, that is based + on a public Azure OpenAI endpoint call for embeddings. + allOf: + - $ref: '#/components/schemas/onYourDataVectorizationSource' + - properties: + authentication: + $ref: '#/components/schemas/onYourDataApiKeyAuthenticationOptions' + endpoint: + type: string + description: Specifies the endpoint to use for vectorization. This endpoint must be in the same Azure OpenAI resource, but On Your Data will use this endpoint via an internal call rather than a public one, which enables vector search even in private networks. + format: uri + x-ms-discriminator-value: endpoint + azureChatExtensionsMessageContext: + type: object + properties: + citations: + type: array + description: The data source retrieval result, used to generate the assistant message in the response. + items: + $ref: '#/components/schemas/citation' + x-ms-identifiers: [] + intent: + type: string + description: The detected intent from the chat history, used to pass to the next turn to carry over the context. + description: |2- + A representation of the additional context information available when Azure OpenAI chat extensions are involved + in the generation of a corresponding chat completions response. This context information is only populated when + using an Azure OpenAI request configured to use a matching extension. + citation: + required: + - content + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title of the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path of the citation. + chunk_id: + type: string + description: The chunk ID of the citation. + description: citation information for a chat completions response message. + chatCompletionMessageToolCall: + type: object + properties: + id: + type: string + description: The ID of the tool call. + type: + $ref: '#/components/schemas/toolCallType' + 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 + toolCallType: + type: string + enum: + - function + description: The type of the tool call, in this case `function`. + x-ms-enum: + name: ToolCallType + modelAsString: true + values: + - value: function + description: The tool call type is function. + chatCompletionRequestMessageTool: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessage' + - type: object + nullable: true + properties: + tool_call_id: + type: string + description: Tool call that this message is responding to. + content: + type: string + description: The contents of the message. + nullable: true + required: + - tool_call_id + - content + chatCompletionRequestMessageFunction: + allOf: + - $ref: '#/components/schemas/chatCompletionRequestMessage' + - type: object + description: Deprecated. Message that represents a function. + nullable: true + properties: + role: + type: string + enum: + - function + description: The role of the messages author, in this case `function`. + name: + type: string + description: The contents of the message. + content: + type: string + description: The contents of the message. + nullable: true + required: + - function_call_id + - content + createChatCompletionResponse: + type: object + allOf: + - $ref: '#/components/schemas/chatCompletionsResponseCommon' + - properties: + prompt_filter_results: + $ref: '#/components/schemas/promptFilterResults' + choices: + type: array + items: + type: object + allOf: + - $ref: '#/components/schemas/chatCompletionChoiceCommon' + - properties: + message: + $ref: '#/components/schemas/chatCompletionResponseMessage' + content_filter_results: + $ref: '#/components/schemas/contentFilterChoiceResults' + logprobs: + $ref: '#/components/schemas/chatCompletionChoiceLogProbs' + required: + - id + - object + - created + - model + - choices + chatCompletionChoiceLogProbs: + description: Log probability information for the choice. + type: object + nullable: true + properties: + content: + description: A list of message content tokens with log probability information. + type: array + items: + $ref: '#/components/schemas/chatCompletionTokenLogprob' + nullable: true + required: + - content + chatCompletionTokenLogprob: + type: object + properties: + token: + description: The token. + type: string + logprob: + description: The log probability of this token. + type: number + bytes: + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + type: array + items: + type: integer + nullable: true + top_logprobs: + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + type: array + items: + type: object + properties: + token: + description: The token. + type: string + logprob: + description: The log probability of this token. + type: number + bytes: + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + type: array + items: + type: integer + nullable: true + required: + - token + - logprob + - bytes + required: + - token + - logprob + - bytes + - top_logprobs + + chatCompletionResponseMessage: + type: object + description: A chat completion message generated by the model. + properties: + role: + $ref: '#/components/schemas/chatCompletionResponseMessageRole' + content: + type: string + description: The contents of the message. + nullable: true + tool_calls: + type: array + description: The tool calls generated by the model, such as function calls. + items: + $ref: '#/components/schemas/chatCompletionMessageToolCall' + function_call: + $ref: '#/components/schemas/chatCompletionFunctionCall' + context: + $ref: '#/components/schemas/azureChatExtensionsMessageContext' + chatCompletionResponseMessageRole: + type: string + enum: + - assistant + description: The role of the author of the response message. + chatCompletionToolChoiceOption: + description: 'Controls which (if any) function is called by the model. `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function. Specifying a particular function via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that function.' + oneOf: + - type: string + description: '`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.' + enum: + - none + - auto + - required + - $ref: '#/components/schemas/chatCompletionNamedToolChoice' + chatCompletionNamedToolChoice: + type: object + description: Specifies a tool the model should use. Use to force the model to call a specific function. + properties: + 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. + required: + - name + chatCompletionFunctionCall: + type: object + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + 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 + chatCompletionsResponseCommon: + type: object + properties: + id: + type: string + description: A unique identifier for the chat completion. + object: + $ref: '#/components/schemas/chatCompletionResponseObject' + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + usage: + $ref: '#/components/schemas/completionUsage' + system_fingerprint: + type: string + description: Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + required: + - id + - object + - created + - model + chatCompletionResponseObject: + type: string + description: The object type. + enum: + - chat.completion + x-ms-enum: + name: ChatCompletionResponseObject + modelAsString: true + values: + - value: chat.completion + description: The object type is chat completion. + completionUsage: + type: object + description: Usage statistics for the completion request. + properties: + prompt_tokens: + type: integer + description: Number of tokens in the prompt. + completion_tokens: + type: integer + description: Number of tokens in the generated completion. + total_tokens: + type: integer + description: Total number of tokens used in the request (prompt + completion). + required: + - prompt_tokens + - completion_tokens + - total_tokens + chatCompletionTool: + type: object + properties: + type: + $ref: '#/components/schemas/chatCompletionToolType' + function: + type: object + 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/chatCompletionFunctionParameters' + required: + - name + - parameters + required: + - type + - function + chatCompletionToolType: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + x-ms-enum: + name: ChatCompletionToolType + modelAsString: true + values: + - value: function + description: The tool type is function. + chatCompletionChoiceCommon: + type: object + properties: + index: + type: integer + finish_reason: + type: string + createTranslationRequest: + type: object + description: Translation request. + properties: + file: + type: string + description: The audio file to translate. + format: binary + prompt: + type: string + description: An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English. + response_format: + $ref: '#/components/schemas/audioResponseFormat' + temperature: + type: number + default: 0 + description: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + required: + - file + audioResponse: + description: Translation or transcription response when response_format was json + type: object + properties: + text: + type: string + description: Translated or transcribed text. + required: + - text + audioVerboseResponse: + description: Translation or transcription response when response_format was verbose_json + type: object + allOf: + - $ref: '#/components/schemas/audioResponse' + - properties: + task: + type: string + description: Type of audio task. + enum: + - transcribe + - translate + x-ms-enum: + modelAsString: true + language: + type: string + description: Language. + duration: + type: number + description: Duration. + segments: + type: array + items: + $ref: '#/components/schemas/audioSegment' + required: + - text + audioResponseFormat: + title: AudioResponseFormat + description: Defines the format of the output. + enum: + - json + - text + - srt + - verbose_json + - vtt + type: string + x-ms-enum: + modelAsString: true + createTranscriptionRequest: + type: object + description: Transcription request. + properties: + file: + type: string + description: The audio file object to transcribe. + format: binary + prompt: + type: string + description: An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + response_format: + $ref: '#/components/schemas/audioResponseFormat' + temperature: + type: number + default: 0 + description: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + language: + type: string + description: The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + required: + - file + audioSegment: + type: object + description: Transcription or translation segment. + properties: + id: + type: integer + description: Segment identifier. + seek: + type: number + description: Offset of the segment. + start: + type: number + description: Segment start offset. + end: + type: number + description: Segment end offset. + text: + type: string + description: Segment text. + tokens: + type: array + items: + type: number + nullable: false + description: Tokens of the text. + temperature: + type: number + description: Temperature. + avg_logprob: + type: number + description: Average log probability. + compression_ratio: + type: number + description: Compression ratio. + no_speech_prob: + type: number + description: Probability of 'no speech'. + imageQuality: + description: The quality of the image that will be generated. + type: string + enum: + - standard + - hd + default: standard + x-ms-enum: + name: Quality + modelAsString: true + values: + - value: standard + description: Standard quality creates images with standard quality. + name: Standard + - value: hd + description: HD quality creates images with finer details and greater consistency across the image. + name: HD + imagesResponseFormat: + description: The format in which the generated images are returned. + type: string + enum: + - url + - b64_json + default: url + x-ms-enum: + name: ImagesResponseFormat + modelAsString: true + values: + - value: url + description: The URL that provides temporary access to download the generated images. + name: Url + - value: b64_json + description: The generated images are returned as base64 encoded string. + name: Base64Json + imageSize: + description: The size of the generated images. + type: string + enum: + - 1792x1024 + - 1024x1792 + - 1024x1024 + default: 1024x1024 + x-ms-enum: + name: Size + modelAsString: true + values: + - value: 1792x1024 + description: The desired size of the generated image is 1792x1024 pixels. + name: Size1792x1024 + - value: 1024x1792 + description: The desired size of the generated image is 1024x1792 pixels. + name: Size1024x1792 + - value: 1024x1024 + description: The desired size of the generated image is 1024x1024 pixels. + name: Size1024x1024 + imageStyle: + description: The style of the generated images. + type: string + enum: + - vivid + - natural + default: vivid + x-ms-enum: + name: Style + modelAsString: true + values: + - value: vivid + description: Vivid creates images that are hyper-realistic and dramatic. + name: Vivid + - value: natural + description: Natural creates images that are more natural and less hyper-realistic. + name: Natural + imageGenerationsRequest: + type: object + properties: + prompt: + description: A text description of the desired image(s). The maximum length is 4000 characters. + type: string + format: string + example: a corgi in a field + minLength: 1 + 'n': + description: The number of images to generate. + type: integer + minimum: 1 + maximum: 1 + default: 1 + size: + $ref: '#/components/schemas/imageSize' + response_format: + $ref: '#/components/schemas/imagesResponseFormat' + user: + description: A unique identifier representing your end-user, which can help to monitor and detect abuse. + type: string + format: string + example: user123456 + quality: + $ref: '#/components/schemas/imageQuality' + style: + $ref: '#/components/schemas/imageStyle' + required: + - prompt + generateImagesResponse: + type: object + properties: + created: + type: integer + format: unixtime + description: The unix timestamp when the operation was created. + example: '1676540381' + data: + type: array + description: The result data of the operation, if successful + items: + $ref: '#/components/schemas/imageResult' + required: + - created + - data + imageResult: + type: object + description: The image url or encoded image if successful, and an error otherwise. + properties: + url: + type: string + description: The image url. + example: https://www.contoso.com + b64_json: + type: string + description: The base64 encoded image + content_filter_results: + $ref: '#/components/schemas/dalleContentFilterResults' + revised_prompt: + type: string + description: The prompt that was used to generate the image, if there was any revision to the prompt. + prompt_filter_results: + $ref: '#/components/schemas/dalleFilterResults' + securitySchemes: + bearer: + type: oauth2 + flows: + implicit: + authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize + scopes: {} + x-tokenInfoFunc: api.middleware.auth.bearer_auth + x-scopeValidateFunc: api.middleware.auth.validate_scopes + apiKey: + type: apiKey + name: api-key + in: header diff --git a/packages/foundation-models/src/azure-openai/ts-to-zod/azure-openai-embedding-types.zod.ts b/packages/foundation-models/src/azure-openai/ts-to-zod/azure-openai-embedding-types.zod.ts new file mode 100644 index 000000000..f37b451b7 --- /dev/null +++ b/packages/foundation-models/src/azure-openai/ts-to-zod/azure-openai-embedding-types.zod.ts @@ -0,0 +1,29 @@ +// Generated by ts-to-zod +import { z } from 'zod'; + +/** + * @internal + */ +export const azureOpenAiEmbeddingParametersSchema = z.object({ + input: z.union([z.array(z.string()), z.string()]), + user: z.string().optional() +}); + +/** + * @internal + */ +export const azureOpenAiEmbeddingOutputSchema = z.object({ + object: z.literal('list'), + model: z.string(), + data: z.tuple([ + z.object({ + object: z.literal('embedding'), + embedding: z.array(z.number()), + index: z.number() + }) + ]), + usage: z.object({ + prompt_tokens: z.number(), + total_tokens: z.number() + }) +}); diff --git a/packages/foundation-models/src/index.ts b/packages/foundation-models/src/index.ts index 365473465..5f0a191fe 100644 --- a/packages/foundation-models/src/index.ts +++ b/packages/foundation-models/src/index.ts @@ -1,32 +1,8 @@ export type { - AzureOpenAiChatMessage, - AzureOpenAiChatSystemMessage, - AzureOpenAiChatUserMessage, - AzureOpenAiChatAssistantMessage, - AzureOpenAiChatToolMessage, - AzureOpenAiChatFunctionMessage, - AzureOpenAiCompletionChoice, - AzureOpenAiErrorBase, - AzureOpenAiChatCompletionChoice, - AzureOpenAiCompletionOutput, - AzureOpenAiUsage, - AzureOpenAiChatCompletionFunction, - AzureOpenAiChatCompletionTool, - AzureOpenAiChatFunctionCall, - AzureOpenAiChatToolCall, - AzureOpenAiCompletionParameters, - AzureOpenAiChatCompletionParameters, - AzureOpenAiEmbeddingParameters, - AzureOpenAiChatCompletionOutput, - AzureOpenAiPromptFilterResult, - AzureOpenAiContentFilterResultsBase, - AzureOpenAiContentFilterPromptResults, - AzureOpenAiContentFilterResultBase, - AzureOpenAiContentFilterDetectedResult, - AzureOpenAiContentFilterSeverityResult, - AzureOpenAiEmbeddingOutput, AzureOpenAiChatModel, - AzureOpenAiEmbeddingModel + AzureOpenAiEmbeddingModel, + AzureOpenAiEmbeddingParameters, + AzureOpenAiEmbeddingOutput } from './azure-openai/index.js'; export { @@ -35,3 +11,52 @@ export { AzureOpenAiChatCompletionResponse, AzureOpenAiEmbeddingResponse } from './azure-openai/index.js'; + +export type { + AzureOpenAiCreateChatCompletionRequest, + AzureOpenAiChatCompletionsRequestCommon, + AzureOpenAiChatCompletionRequestMessage, + AzureOpenAiChatCompletionRequestMessageRole, + AzureOpenAiAzureChatExtensionConfiguration, + AzureOpenAiAzureChatExtensionType, + AzureOpenAiChatCompletionResponseFormat, + AzureOpenAiChatCompletionTool, + AzureOpenAiChatCompletionToolType, + AzureOpenAiChatCompletionFunctionParameters, + AzureOpenAiChatCompletionToolChoiceOption, + AzureOpenAiChatCompletionNamedToolChoice, + AzureOpenAiChatCompletionFunction, + AzureOpenAiChatCompletionRequestMessageSystem, + AzureOpenAiChatCompletionRequestMessageUser, + AzureOpenAiChatCompletionRequestMessageAssistant, + AzureOpenAiChatCompletionRequestMessageTool, + AzureOpenAiChatCompletionMessageToolCall, + AzureOpenAiAzureChatExtensionsMessageContext, + AzureOpenAiToolCallType, + AzureOpenAiCitation, + AzureOpenAiChatCompletionRequestMessageFunction, + AzureOpenAiChatCompletionRequestMessageContentPart, + AzureOpenAiChatCompletionRequestMessageContentPartType, + AzureOpenAiCreateChatCompletionResponse, + AzureOpenAiChatCompletionsResponseCommon, + AzureOpenAiPromptFilterResults, + AzureOpenAiPromptFilterResult, + AzureOpenAiContentFilterPromptResults, + AzureOpenAiContentFilterResultsBase, + AzureOpenAiContentFilterSeverityResult, + AzureOpenAiContentFilterDetectedResult, + AzureOpenAiError, + AzureOpenAiErrorBase, + AzureOpenAiInnerError, + AzureOpenAiInnerErrorCode, + AzureOpenAiChatCompletionChoiceCommon, + AzureOpenAiChatCompletionResponseMessage, + AzureOpenAiContentFilterChoiceResults, + AzureOpenAiChatCompletionChoiceLogProbs, + AzureOpenAiChatCompletionResponseMessageRole, + AzureOpenAiChatCompletionFunctionCall, + AzureOpenAiContentFilterDetectedWithCitationResult, + AzureOpenAiChatCompletionTokenLogprob, + AzureOpenAiCompletionUsage, + AzureOpenAiChatCompletionResponseObject +} from './azure-openai/client/inference/schema/index.js'; diff --git a/packages/foundation-models/tsconfig.json b/packages/foundation-models/tsconfig.json index 5c6b23abc..18caaf176 100644 --- a/packages/foundation-models/tsconfig.json +++ b/packages/foundation-models/tsconfig.json @@ -7,6 +7,12 @@ "composite": true }, "include": ["src/**/*.ts"], - "exclude": ["dist/**/*", "test/**/*", "**/*.test.ts", "node_modules/**/*"], + "exclude": [ + "dist/**/*", + "test/**/*", + "**/*.test.ts", + "node_modules/**/*", + "src/**/ts-to-zod/*.zod.ts" + ], "references": [{ "path": "../core" }] } diff --git a/packages/orchestration/package.json b/packages/orchestration/package.json index 4fec15c8f..3ad9240cb 100644 --- a/packages/orchestration/package.json +++ b/packages/orchestration/package.json @@ -39,7 +39,6 @@ "@sap-cloud-sdk/openapi": "^3.21.0" }, "devDependencies": { - "@sap-cloud-sdk/openapi-generator": "^3.21.0", "typescript": "^5.6.2", "nock": "^13.5.5" } diff --git a/packages/orchestration/src/orchestration-response.ts b/packages/orchestration/src/orchestration-response.ts index cbdd1e793..7e380ad8c 100644 --- a/packages/orchestration/src/orchestration-response.ts +++ b/packages/orchestration/src/orchestration-response.ts @@ -6,7 +6,7 @@ import { } from './client/api/schema/index.js'; const logger = createLogger({ - package: 'gen-ai-hub', + package: 'orchestration', messageContext: 'orchestration-response' }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 751892ecf..07d61e880 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,6 +40,9 @@ importers: '@sap-cloud-sdk/http-client': specifier: ^3.21.0 version: 3.21.0 + '@sap-cloud-sdk/openapi-generator': + specifier: ^3.21.0 + version: 3.21.0 '@sap-cloud-sdk/util': specifier: ^3.21.0 version: 3.21.0 @@ -92,9 +95,6 @@ importers: specifier: workspace:^ version: link:../core devDependencies: - '@sap-cloud-sdk/openapi-generator': - specifier: ^3.21.0 - version: 3.21.0 typescript: specifier: ^5.6.2 version: 5.6.2 @@ -139,9 +139,6 @@ importers: specifier: ^3.21.0 version: 3.21.0 devDependencies: - '@sap-cloud-sdk/openapi-generator': - specifier: ^3.21.0 - version: 3.21.0 nock: specifier: ^13.5.5 version: 13.5.5 @@ -176,9 +173,6 @@ importers: specifier: ^3.21.0 version: 3.21.0 devDependencies: - '@sap-cloud-sdk/openapi-generator': - specifier: ^3.21.0 - version: 3.21.0 nock: specifier: ^13.5.5 version: 13.5.5 @@ -230,13 +224,13 @@ importers: dependencies: '@sap-ai-sdk/ai-api': specifier: canary - version: 0.1.1-20240918013048.0 + version: 0.1.1-20240916013108.0 '@sap-ai-sdk/foundation-models': specifier: canary - version: 0.1.1-20240918013048.0 + version: 0.1.1-20240916013108.0 '@sap-ai-sdk/orchestration': specifier: canary - version: 0.1.1-20240918013048.0 + version: 0.1.1-20240916013108.0 express: specifier: ^4.21.0 version: 4.21.0 @@ -551,10 +545,6 @@ packages: resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint-community/regexpp@4.11.1': - resolution: {integrity: sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q==} - engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint/config-array@0.18.0': resolution: {integrity: sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -761,17 +751,17 @@ packages: '@rtsao/scc@1.1.0': resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==} - '@sap-ai-sdk/ai-api@0.1.1-20240918013048.0': - resolution: {integrity: sha512-fWYbjaLlNbjlCQJcjqTgv/akSsmRCpGbTevBSCkyapCSzQGrsxBGtvapVnWxI5d41MTUwwZhnHkjpIILANyyhw==} + '@sap-ai-sdk/ai-api@0.1.1-20240916013108.0': + resolution: {integrity: sha512-626CFUnb7reUDFf8Joyj+7PFNTek7loEczDw6HfjQwDnajDa944v08DPgFfCyrQ/nLl94omKcz7yP7GV9PMNTg==} - '@sap-ai-sdk/core@0.1.1-20240918013048.0': - resolution: {integrity: sha512-EXCIJTekGVX01VxoZAGwvHVkfYVpUQacOmPEeDIIKcAy0hl3z07mO9zwzLPafNV5/t7mgZQ8TnHnpb4WAZUcfg==} + '@sap-ai-sdk/core@0.1.1-20240916013108.0': + resolution: {integrity: sha512-9nj0JhiMvnqEJ5m/534p3Bx/k6PCMxQoAOPSiPrZbUMrRKNlYDUjlH+L2wF9Y9PLjaJdFXIt2BXn5Ci4qURy9A==} - '@sap-ai-sdk/foundation-models@0.1.1-20240918013048.0': - resolution: {integrity: sha512-mrfU+JxCcagLSVbqyENEqxHG6zXXZl/ypeJpX3Xg+WIKw0BZ3rky/1NNbPrDc1AZZbs95WhfhXMv4rC5ojxo1Q==} + '@sap-ai-sdk/foundation-models@0.1.1-20240916013108.0': + resolution: {integrity: sha512-Pg39SMXbu+uCvObdrfTph78e9iJLeQLOEiAURe+mAXBGChDUhAR1tNmXq3KUQwFnAo+L+N3waUl/vdQneh1pbQ==} - '@sap-ai-sdk/orchestration@0.1.1-20240918013048.0': - resolution: {integrity: sha512-e4PJkWMFIQ2UFarYubkZtQbOUe+WvbzhwfSzsgHUirKKzvMaMiTSzLwRMY4s1Z5AOV94HY4en7xdGvn04VJnZA==} + '@sap-ai-sdk/orchestration@0.1.1-20240916013108.0': + resolution: {integrity: sha512-nWY/tDXMbrSvuouQKQnWBkHHF9Hzx9RyZbnBP1ZotP0s5dPglvMEvVKXTy5KNMbdq5qOd1PA3keyB6s7zJSQig==} '@sap-cloud-sdk/connectivity@3.21.0': resolution: {integrity: sha512-E3WdZ13r+va/DYaj/vLLUEmtj9bKtkxcUiqMWG560X7vFzcUDN0jKtSE8L+RkWs7k3bqsIr01EV+TuGku9mggQ==} @@ -866,9 +856,6 @@ packages: '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} - '@types/estree@1.0.6': - resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} - '@types/express-serve-static-core@4.19.5': resolution: {integrity: sha512-y6W03tvrACO72aijJ5uF02FRq5cgDR9lUxddQ8vyF+GvmjJQqbzDcJngEjURc+ZsG31VI3hODNZJ2URj86pzmg==} @@ -1140,8 +1127,8 @@ packages: async-retry@1.3.3: resolution: {integrity: sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw==} - async@3.2.6: - resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} + async@3.2.5: + resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} @@ -1616,8 +1603,8 @@ packages: es6-promise@3.3.1: resolution: {integrity: sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==} - escalade@3.2.0: - resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + escalade@3.1.2: + resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} escape-html@1.0.3: @@ -1875,8 +1862,8 @@ packages: fn.name@1.1.0: resolution: {integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==} - follow-redirects@1.15.9: - resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==} + follow-redirects@1.15.6: + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} engines: {node: '>=4.0'} peerDependencies: debug: '*' @@ -1891,10 +1878,6 @@ packages: resolution: {integrity: sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==} engines: {node: '>=14'} - foreground-child@3.3.0: - resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==} - engines: {node: '>=14'} - form-data@4.0.0: resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} engines: {node: '>= 6'} @@ -2275,8 +2258,9 @@ packages: resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} engines: {node: '>=8'} - jackspeak@3.4.3: - resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + jackspeak@3.4.0: + resolution: {integrity: sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==} + engines: {node: '>=14'} jackspeak@4.0.1: resolution: {integrity: sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==} @@ -2600,8 +2584,9 @@ packages: resolution: {integrity: sha512-CdaO738xRapbKIMVn2m4F6KTj4j7ooJ8POVnebSgKo3KBz5axNXRAL7ZdRjIV6NOr2Uf4vjtRkxrFETOioCqSA==} engines: {node: '>= 12.0.0'} - lru-cache@10.4.3: - resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@10.3.0: + resolution: {integrity: sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==} + engines: {node: 14 || >=16.14} lru-cache@11.0.0: resolution: {integrity: sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==} @@ -3139,8 +3124,8 @@ packages: resolution: {integrity: sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==} engines: {node: '>= 0.4'} - safe-stable-stringify@2.5.0: - resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} + safe-stable-stringify@2.4.3: + resolution: {integrity: sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==} engines: {node: '>=10'} safer-buffer@2.1.2: @@ -4119,8 +4104,6 @@ snapshots: '@eslint-community/regexpp@4.11.0': {} - '@eslint-community/regexpp@4.11.1': {} - '@eslint/config-array@0.18.0': dependencies: '@eslint/object-schema': 2.1.4 @@ -4501,14 +4484,14 @@ snapshots: '@rtsao/scc@1.1.0': {} - '@sap-ai-sdk/ai-api@0.1.1-20240918013048.0': + '@sap-ai-sdk/ai-api@0.1.1-20240916013108.0': dependencies: - '@sap-ai-sdk/core': 0.1.1-20240918013048.0 + '@sap-ai-sdk/core': 0.1.1-20240916013108.0 transitivePeerDependencies: - debug - supports-color - '@sap-ai-sdk/core@0.1.1-20240918013048.0': + '@sap-ai-sdk/core@0.1.1-20240916013108.0': dependencies: '@sap-cloud-sdk/connectivity': 3.21.0 '@sap-cloud-sdk/http-client': 3.21.0 @@ -4518,10 +4501,10 @@ snapshots: - debug - supports-color - '@sap-ai-sdk/foundation-models@0.1.1-20240918013048.0': + '@sap-ai-sdk/foundation-models@0.1.1-20240916013108.0': dependencies: - '@sap-ai-sdk/ai-api': 0.1.1-20240918013048.0 - '@sap-ai-sdk/core': 0.1.1-20240918013048.0 + '@sap-ai-sdk/ai-api': 0.1.1-20240916013108.0 + '@sap-ai-sdk/core': 0.1.1-20240916013108.0 '@sap-cloud-sdk/connectivity': 3.21.0 '@sap-cloud-sdk/http-client': 3.21.0 '@sap-cloud-sdk/openapi': 3.21.0 @@ -4530,10 +4513,10 @@ snapshots: - debug - supports-color - '@sap-ai-sdk/orchestration@0.1.1-20240918013048.0': + '@sap-ai-sdk/orchestration@0.1.1-20240916013108.0': dependencies: - '@sap-ai-sdk/ai-api': 0.1.1-20240918013048.0 - '@sap-ai-sdk/core': 0.1.1-20240918013048.0 + '@sap-ai-sdk/ai-api': 0.1.1-20240916013108.0 + '@sap-ai-sdk/core': 0.1.1-20240916013108.0 '@sap-cloud-sdk/connectivity': 3.21.0 '@sap-cloud-sdk/http-client': 3.21.0 '@sap-cloud-sdk/openapi': 3.21.0 @@ -4722,15 +4705,12 @@ snapshots: '@types/eslint@8.56.10': dependencies: - '@types/estree': 1.0.6 + '@types/estree': 1.0.5 '@types/json-schema': 7.0.15 optional: true '@types/estree@1.0.5': {} - '@types/estree@1.0.6': - optional: true - '@types/express-serve-static-core@4.19.5': dependencies: '@types/node': 20.16.5 @@ -4819,7 +4799,7 @@ snapshots: '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@9.10.0)(typescript@5.6.2))(eslint@9.10.0)(typescript@5.6.2)': dependencies: - '@eslint-community/regexpp': 4.11.1 + '@eslint-community/regexpp': 4.11.0 '@typescript-eslint/parser': 7.18.0(eslint@9.10.0)(typescript@5.6.2) '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/type-utils': 7.18.0(eslint@9.10.0)(typescript@5.6.2) @@ -5039,7 +5019,7 @@ snapshots: dependencies: retry: 0.13.1 - async@3.2.6: {} + async@3.2.5: {} asynckit@0.4.0: {} @@ -5049,7 +5029,7 @@ snapshots: axios@1.7.7: dependencies: - follow-redirects: 1.15.9 + follow-redirects: 1.15.6 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -5554,7 +5534,7 @@ snapshots: es6-promise@3.3.1: {} - escalade@3.2.0: {} + escalade@3.1.2: {} escape-html@1.0.3: {} @@ -5895,7 +5875,7 @@ snapshots: fn.name@1.1.0: {} - follow-redirects@1.15.9: {} + follow-redirects@1.15.6: {} for-each@0.3.3: dependencies: @@ -5906,11 +5886,6 @@ snapshots: cross-spawn: 7.0.3 signal-exit: 4.1.0 - foreground-child@3.3.0: - dependencies: - cross-spawn: 7.0.3 - signal-exit: 4.1.0 - form-data@4.0.0: dependencies: asynckit: 0.4.0 @@ -5987,8 +5962,8 @@ snapshots: glob@10.4.5: dependencies: - foreground-child: 3.3.0 - jackspeak: 3.4.3 + foreground-child: 3.2.1 + jackspeak: 3.4.0 minimatch: 9.0.5 minipass: 7.1.2 package-json-from-dist: 1.0.0 @@ -6289,7 +6264,7 @@ snapshots: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 - jackspeak@3.4.3: + jackspeak@3.4.0: dependencies: '@isaacs/cliui': 8.0.2 optionalDependencies: @@ -6303,7 +6278,7 @@ snapshots: jake@10.9.2: dependencies: - async: 3.2.6 + async: 3.2.5 chalk: 4.1.2 filelist: 1.0.4 minimatch: 3.1.2 @@ -6843,10 +6818,10 @@ snapshots: '@types/triple-beam': 1.3.5 fecha: 4.2.3 ms: 2.1.3 - safe-stable-stringify: 2.5.0 + safe-stable-stringify: 2.4.3 triple-beam: 1.4.1 - lru-cache@10.4.3: {} + lru-cache@10.3.0: {} lru-cache@11.0.0: {} @@ -7173,7 +7148,7 @@ snapshots: path-scurry@1.11.1: dependencies: - lru-cache: 10.4.3 + lru-cache: 10.3.0 minipass: 7.1.2 path-scurry@2.0.0: @@ -7363,7 +7338,7 @@ snapshots: es-errors: 1.3.0 is-regex: 1.1.4 - safe-stable-stringify@2.5.0: {} + safe-stable-stringify@2.4.3: {} safer-buffer@2.1.2: {} @@ -7631,7 +7606,7 @@ snapshots: threads@1.7.0: dependencies: callsites: 3.1.0 - debug: 4.3.6 + debug: 4.3.7(supports-color@8.1.1) is-observable: 2.1.0 observable-fns: 0.6.1 optionalDependencies: @@ -7835,7 +7810,7 @@ snapshots: update-browserslist-db@1.1.0(browserslist@4.23.1): dependencies: browserslist: 4.23.1 - escalade: 3.2.0 + escalade: 3.1.2 picocolors: 1.1.0 uri-js@4.4.1: @@ -7922,12 +7897,12 @@ snapshots: dependencies: '@colors/colors': 1.6.0 '@dabh/diagnostics': 2.0.3 - async: 3.2.6 + async: 3.2.5 is-stream: 2.0.1 logform: 2.6.1 one-time: 1.0.0 readable-stream: 3.6.2 - safe-stable-stringify: 2.5.0 + safe-stable-stringify: 2.4.3 stack-trace: 0.0.10 triple-beam: 1.4.1 winston-transport: 4.7.1 @@ -7983,7 +7958,7 @@ snapshots: yargs@17.7.2: dependencies: cliui: 8.0.1 - escalade: 3.2.0 + escalade: 3.1.2 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 diff --git a/scripts/check-public-api.ts b/scripts/check-public-api.ts index 7f3191eb5..7f14eb16f 100644 --- a/scripts/check-public-api.ts +++ b/scripts/check-public-api.ts @@ -1,6 +1,6 @@ /* eslint-disable jsdoc/require-jsdoc */ -import path, { join, resolve, parse, basename, dirname } from 'path'; +import path, { join, resolve, parse, basename, dirname, posix, sep } from 'path'; import { fileURLToPath } from 'url'; import { promises, existsSync } from 'fs'; import { glob } from 'glob'; @@ -85,11 +85,18 @@ function compareApisAndLog( verbose: boolean ): boolean { let setsAreEqual = true; + const schemaPathRegex = /.*\/client\/[^/]+\/schema\/[^/]+\.ts$/; allExportedTypes.forEach(exportedType => { if ( !allExportedIndex.find(nameInIndex => exportedType.name === nameInIndex) ) { + if (exportedType.path.split(sep).join(posix.sep).match(schemaPathRegex)) { + logger.warn( + `The ${exportedType.type} "${exportedType.name}" in file: ${exportedType.path} is not exported in the index.ts.` + ); + return; + } logger.error( `The ${exportedType.type} "${exportedType.name}" in file: ${exportedType.path} is neither listed in the index.ts nor marked as internal.` ); diff --git a/tests/type-tests/test/azure-openai.test-d.ts b/tests/type-tests/test/azure-openai.test-d.ts index a53fb5550..1dfbe4b78 100644 --- a/tests/type-tests/test/azure-openai.test-d.ts +++ b/tests/type-tests/test/azure-openai.test-d.ts @@ -1,12 +1,12 @@ import { expectType } from 'tsd'; import { type AzureOpenAiChatModel, - AzureOpenAiChatCompletionOutput, + AzureOpenAiEmbeddingResponse, AzureOpenAiChatClient, AzureOpenAiEmbeddingClient, AzureOpenAiChatCompletionResponse, - AzureOpenAiEmbeddingResponse, - AzureOpenAiUsage + AzureOpenAiCreateChatCompletionResponse, + AzureOpenAiCompletionUsage } from '@sap-ai-sdk/foundation-models'; /** @@ -27,7 +27,7 @@ expectType( }) ); -expectType( +expectType( ( await new AzureOpenAiChatClient('gpt-4').run({ messages: [{ role: 'user', content: 'test prompt' }] @@ -35,7 +35,7 @@ expectType( ).data ); -expectType( +expectType( ( await new AzureOpenAiChatClient('gpt-4').run({ messages: [{ role: 'user', content: 'test prompt' }] @@ -51,7 +51,7 @@ expectType( ).getFinishReason() ); -expectType( +expectType( ( await new AzureOpenAiChatClient('gpt-4').run({ messages: [{ role: 'user', content: 'test prompt' }]