From c058547a49a15c7c244fb9775235499758ddc10c Mon Sep 17 00:00:00 2001 From: Minh-Anh Phan Date: Thu, 21 Nov 2024 21:44:04 +0000 Subject: [PATCH] update authentication and role information property --- sdk/openai/openai/review/openai-types.api.md | 29 +++++++++++------ sdk/openai/openai/src/types/models.ts | 31 ++++++++----------- sdk/openai/openai/src/types/outputModels.ts | 24 ++++++++++++++ .../openai/test/public/utils/asserts.ts | 18 +++++++++++ 4 files changed, 74 insertions(+), 28 deletions(-) diff --git a/sdk/openai/openai/review/openai-types.api.md b/sdk/openai/openai/review/openai-types.api.md index 1e9b61370238..075f74a286c7 100644 --- a/sdk/openai/openai/review/openai-types.api.md +++ b/sdk/openai/openai/review/openai-types.api.md @@ -68,7 +68,7 @@ export interface AzureCosmosDBChatExtensionConfiguration extends AzureChatExtens // @public export interface AzureCosmosDBChatExtensionParameters { allow_partial_result?: boolean; - authentication: OnYourDataAuthenticationOptions; + authentication: OnYourDataConnectionStringAuthenticationOptions; container_name: string; database_name: string; embedding_dependency: OnYourDataVectorizationSource; @@ -77,7 +77,6 @@ export interface AzureCosmosDBChatExtensionParameters { include_contexts?: OnYourDataContextProperty[]; index_name: string; max_search_queries?: number; - role_information?: string; strictness?: number; top_n_documents?: number; } @@ -101,7 +100,7 @@ export interface AzureSearchChatExtensionConfiguration extends AzureChatExtensio // @public export interface AzureSearchChatExtensionParameters { allow_partial_result?: boolean; - authentication: OnYourDataAuthenticationOptions; + authentication: OnYourDataApiKeyAuthenticationOptions | OnYourDataSystemAssignedManagedIdentityAuthenticationOptions | OnYourDataUserAssignedManagedIdentityAuthenticationOptions | OnYourDataAccessTokenAuthenticationOptions; embedding_dependency?: OnYourDataVectorizationSource; endpoint: string; fields_mapping?: AzureSearchIndexFieldMappingOptions; @@ -111,7 +110,6 @@ export interface AzureSearchChatExtensionParameters { index_name: string; max_search_queries?: number; query_type?: string; - role_information?: string; semantic_configuration?: string; strictness?: number; top_n_documents?: number; @@ -158,6 +156,19 @@ export interface ContentFilterCitedDetectionResultOutput { URL?: string; } +// @public +export interface ContentFilterCompletionTextSpan { + completion_end_offset: number; + completion_start_offset: number; +} + +// @public +export interface ContentFilterCompletionTextSpanResultOutput { + details: ContentFilterCompletionTextSpan[]; + detected: boolean; + filtered: boolean; +} + // @public export interface ContentFilterDetailedResults { details: ContentFilterBlocklistIdResultOutput[]; @@ -199,6 +210,7 @@ export interface ContentFilterResultsForChoiceOutput { protected_material_text?: ContentFilterDetectionResultOutput; self_harm?: ContentFilterResultOutput; sexual?: ContentFilterResultOutput; + ungrounded_material?: ContentFilterCompletionTextSpanResultOutput; violence?: ContentFilterResultOutput; } @@ -217,7 +229,7 @@ export interface ElasticsearchChatExtensionConfiguration extends AzureChatExtens // @public export interface ElasticsearchChatExtensionParameters { allow_partial_result?: boolean; - authentication: OnYourDataAuthenticationOptions; + authentication: OnYourDataKeyAndKeyIdAuthenticationOptions | OnYourDataEncodedApiKeyAuthenticationOptions; embedding_dependency?: OnYourDataVectorizationSource; endpoint: string; fields_mapping?: ElasticsearchIndexFieldMappingOptions; @@ -226,7 +238,6 @@ export interface ElasticsearchChatExtensionParameters { index_name: string; max_search_queries?: number; query_type?: string; - role_information?: string; strictness?: number; top_n_documents?: number; } @@ -280,7 +291,6 @@ export interface MongoDBChatExtensionParameters { include_contexts?: OnYourDataContextProperty[]; index_name: string; max_search_queries?: number; - role_information?: string; strictness?: number; top_n_documents?: number; } @@ -339,7 +349,7 @@ export interface OnYourDataEncodedApiKeyAuthenticationOptions extends OnYourData // @public export interface OnYourDataEndpointVectorizationSource extends OnYourDataVectorizationSourceParent { - authentication: OnYourDataVectorSearchAuthenticationOptions; + authentication: OnYourDataVectorSearchApiKeyAuthenticationOptions | OnYourDataVectorSearchAccessTokenAuthenticationOptions; endpoint: string; type: "endpoint"; } @@ -414,7 +424,7 @@ export interface PineconeChatExtensionConfiguration extends AzureChatExtensionCo // @public export interface PineconeChatExtensionParameters { allow_partial_result?: boolean; - authentication: OnYourDataAuthenticationOptions; + authentication: OnYourDataApiKeyAuthenticationOptions; embedding_dependency: OnYourDataVectorizationSource; environment: string; fields_mapping: PineconeFieldMappingOptions; @@ -422,7 +432,6 @@ export interface PineconeChatExtensionParameters { include_contexts?: OnYourDataContextProperty[]; index_name: string; max_search_queries?: number; - role_information?: string; strictness?: number; top_n_documents?: number; } diff --git a/sdk/openai/openai/src/types/models.ts b/sdk/openai/openai/src/types/models.ts index a0d278b4866a..77dac50444c9 100644 --- a/sdk/openai/openai/src/types/models.ts +++ b/sdk/openai/openai/src/types/models.ts @@ -28,15 +28,17 @@ export interface AzureSearchChatExtensionParameters { * If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) * authentication. */ - authentication: OnYourDataAuthenticationOptions; + authentication: + | OnYourDataApiKeyAuthenticationOptions + | OnYourDataSystemAssignedManagedIdentityAuthenticationOptions + | OnYourDataUserAssignedManagedIdentityAuthenticationOptions + | OnYourDataAccessTokenAuthenticationOptions; /** The configured top number of documents to feature for the configured query. */ 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. */ 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 max number of rewritten queries should be send to search provider for one user message. If not specified, * the system will decide the number of queries to send. @@ -111,15 +113,15 @@ export interface ElasticsearchChatExtensionParameters { * If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) * authentication. */ - authentication: OnYourDataAuthenticationOptions; + authentication: + | OnYourDataKeyAndKeyIdAuthenticationOptions + | OnYourDataEncodedApiKeyAuthenticationOptions; /** The configured top number of documents to feature for the configured query. */ 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. */ 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 max number of rewritten queries should be send to search provider for one user message. If not specified, * the system will decide the number of queries to send. @@ -200,15 +202,13 @@ export interface AzureCosmosDBChatExtensionParameters { * If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) * authentication. */ - authentication: OnYourDataAuthenticationOptions; + authentication: OnYourDataConnectionStringAuthenticationOptions; /** The configured top number of documents to feature for the configured query. */ 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. */ 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 max number of rewritten queries should be send to search provider for one user message. If not specified, * the system will decide the number of queries to send. @@ -319,7 +319,9 @@ export interface OnYourDataEndpointVectorizationSource extends OnYourDataVectori /** Specifies the resource endpoint URL from which embeddings should be retrieved. It should be in the format of https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. The api-version query parameter is not allowed. */ endpoint: string; /** Specifies the authentication options to use when retrieving embeddings from the specified endpoint. */ - authentication: OnYourDataVectorSearchAuthenticationOptions; + authentication: + | OnYourDataVectorSearchApiKeyAuthenticationOptions + | OnYourDataVectorSearchAccessTokenAuthenticationOptions; } /** The authentication options for Azure OpenAI On Your Data when using an Elasticsearch key and key ID pair. */ @@ -399,15 +401,13 @@ export interface PineconeChatExtensionParameters { * If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) * authentication. */ - authentication: OnYourDataAuthenticationOptions; + authentication: OnYourDataApiKeyAuthenticationOptions; /** The configured top number of documents to feature for the configured query. */ 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. */ 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 max number of rewritten queries should be send to search provider for one user message. If not specified, * the system will decide the number of queries to send. @@ -477,8 +477,6 @@ export interface MongoDBChatExtensionParameters { 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. */ 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 max number of rewritten queries should be send to search provider for one user message. If not specified, * the system will decide the number of queries to send. @@ -533,9 +531,6 @@ export interface OnYourDataVectorSearchAuthenticationOptions { type: string; } -/** - * The authentication options for Azure OpenAI On Your Data when using an API key. - */ /** * The authentication options for Azure OpenAI On Your Data vector search when using an API key. */ diff --git a/sdk/openai/openai/src/types/outputModels.ts b/sdk/openai/openai/src/types/outputModels.ts index ce84bc9c5866..a952ad795ec3 100644 --- a/sdk/openai/openai/src/types/outputModels.ts +++ b/sdk/openai/openai/src/types/outputModels.ts @@ -43,6 +43,8 @@ export interface ContentFilterResultsForChoiceOutput { protected_material_text?: ContentFilterDetectionResultOutput; /** Information about detection of protected code material. */ protected_material_code?: ContentFilterCitedDetectionResultOutput; + /** Information about detection of ungrounded material. */ + ungrounded_material?: ContentFilterCompletionTextSpanResultOutput; } /** Represents a structured collection of result details for content filtering. */ @@ -66,6 +68,28 @@ export interface ContentFilterCitedDetectionResultOutput { license?: string; } +/** Describes a span within generated completion text. */ +export interface ContentFilterCompletionTextSpanResultOutput { + /** A value indicating whether or not the content has been filtered. */ + filtered: boolean; + /** A value indicating whether detection occurred, irrespective of severity or whether the content was filtered. */ + detected: boolean; + /** The collection of completion text spans. */ + details: ContentFilterCompletionTextSpan[]; +} + +/** Describes a span within generated completion text. Offset 0 is the first UTF32 code point of the completion text. */ +export interface ContentFilterCompletionTextSpan { + /** Offset of the UTF32 code point which begins the span. */ + completion_start_offset: number; + /** + * Offset of the first UTF32 code point which is excluded from the span. + * This field is always equal to completion_start_offset for empty spans. + * This field is always larger than completion_start_offset for non-empty spans. + */ + completion_end_offset: number; +} + /** * 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 diff --git a/sdk/openai/openai/test/public/utils/asserts.ts b/sdk/openai/openai/test/public/utils/asserts.ts index 24fd0dc177ea..e14814dd20fc 100644 --- a/sdk/openai/openai/test/public/utils/asserts.ts +++ b/sdk/openai/openai/test/public/utils/asserts.ts @@ -12,6 +12,8 @@ import { ContentFilterResultsForChoiceOutput, ContentFilterResultsForPromptOutput, ContentFilterDetailedResults, + ContentFilterCompletionTextSpanResultOutput, + ContentFilterCompletionTextSpan, } from "../../../src/types/index.js"; import { Assistant, AssistantCreateParams } from "openai/resources/beta/assistants.mjs"; import { @@ -160,9 +162,25 @@ function assertContentFilterResultsForChoice(cfr: ContentFilterResultsForChoiceO ifDefined(cfr.custom_blocklists, assertContentFilterDetailedResult); ifDefined(cfr.protected_material_code, assertContentFilterCitedDetectionResult); ifDefined(cfr.protected_material_text, assertContentFilterDetectionResult); + ifDefined(cfr.ungrounded_material, assertContentFilterCompletionTextSpanResult); } } +function assertContentFilterCompletionTextSpanResult( + cfr: ContentFilterCompletionTextSpanResultOutput, +): void { + assertContentFilterDetectionResult(cfr); + assert.isBoolean(cfr.filtered); + for (const detail of cfr.details) { + assertContentFilterCompletionTextSpan(detail); + } +} + +function assertContentFilterCompletionTextSpan(cfr: ContentFilterCompletionTextSpan): void { + assert.isNumber(cfr.completion_end_offset); + assert.isNumber(cfr.completion_start_offset); +} + function assertContentFilterResultsForPrompt(cfr: ContentFilterResultsForPromptOutput[]): void { assert.isArray(cfr); for (const item of cfr) {