Skip to content

Commit

Permalink
update authentication and role information property
Browse files Browse the repository at this point in the history
  • Loading branch information
minhanh-phan committed Nov 21, 2024
1 parent 9df2c07 commit c058547
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 28 deletions.
29 changes: 19 additions & 10 deletions sdk/openai/openai/review/openai-types.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -199,6 +210,7 @@ export interface ContentFilterResultsForChoiceOutput {
protected_material_text?: ContentFilterDetectionResultOutput;
self_harm?: ContentFilterResultOutput;
sexual?: ContentFilterResultOutput;
ungrounded_material?: ContentFilterCompletionTextSpanResultOutput;
violence?: ContentFilterResultOutput;
}

Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -339,7 +349,7 @@ export interface OnYourDataEncodedApiKeyAuthenticationOptions extends OnYourData

// @public
export interface OnYourDataEndpointVectorizationSource extends OnYourDataVectorizationSourceParent {
authentication: OnYourDataVectorSearchAuthenticationOptions;
authentication: OnYourDataVectorSearchApiKeyAuthenticationOptions | OnYourDataVectorSearchAccessTokenAuthenticationOptions;
endpoint: string;
type: "endpoint";
}
Expand Down Expand Up @@ -414,15 +424,14 @@ 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;
in_scope?: boolean;
include_contexts?: OnYourDataContextProperty[];
index_name: string;
max_search_queries?: number;
role_information?: string;
strictness?: number;
top_n_documents?: number;
}
Expand Down
31 changes: 13 additions & 18 deletions sdk/openai/openai/src/types/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand Down
24 changes: 24 additions & 0 deletions sdk/openai/openai/src/types/outputModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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
Expand Down
18 changes: 18 additions & 0 deletions sdk/openai/openai/test/public/utils/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c058547

Please sign in to comment.