Skip to content

Commit

Permalink
[OpenAI-Assistant] Added support for 2024-07-01 (#41464)
Browse files Browse the repository at this point in the history
* Added support 2024-07-01 service API version (#41473)
  • Loading branch information
mssfang authored and glharper committed Aug 28, 2024
1 parent 9eb9291 commit 0879248
Show file tree
Hide file tree
Showing 40 changed files with 2,114 additions and 243 deletions.
16 changes: 16 additions & 0 deletions sdk/openai/azure-ai-openai-assistants/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

### Features Added

- `file_search` tool definitions now have the ability to configure `max_num_results` via the matching, named inner options object
Previously, only a stubbed `{ "type": "file_search" }` was valid. Now, e.g.: `{ "type": "file_search", "file_search": { "max_num_results": 20 } }`
- Added a new property `FileSearchToolDefinitionDetails fileSearch` to `FileSearchToolDefinition` model.
- Added new class `FileSearchToolDefinitionDetails` to represent the details of a file search tool.

- `chunking_strategy` is added as a new optional property when creating a vector store (either via the vector store creation operation
or the helper when creating an assistant) -- this allows customization of the chunk size and overlap used when ingesting data.
See the OpenAI reference for full details.
- Added a new property `VectorStoreChunkingStrategyRequest chunkingStrategy` to `VectorStoreOptions` model.
- Added a new property `VectorStoreChunkingStrategyResponse chunkingStrategy` to `VectorStoreFile` model.
- Added new enum `VectorStoreChunkingStrategyRequestType` and `VectorStoreChunkingStrategyResponseType` to represent the chunking strategy `type` for vector stores.
- Added new class `VectorStoreChunkingStrategyRequest` and `VectorStoreChunkingStrategyResponse` to represent the chunking strategy for vector stores.
- Added new class `VectorStoreAutoChunkingStrategyRequest` and `VectorStoreAutoChunkingStrategyResponse` to represent the `auto` chunking strategy for vector stores.
- Added new class `VectorStoreStaticChunkingStrategyOptions`, `VectorStoreStaticChunkingStrategyRequest` and `VectorStoreStaticChunkingStrategyResponse`
to represent the `static` chunking strategy for vector stores.

### Breaking Changes

### Bugs Fixed
Expand Down
3 changes: 2 additions & 1 deletion sdk/openai/azure-ai-openai-assistants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ CreateToolResourcesOptions createToolResourcesOptions = new CreateToolResourcesO
createToolResourcesOptions.setFileSearch(
new CreateFileSearchToolResourceOptions(
new CreateFileSearchToolResourceVectorStoreOptionsList(
Arrays.asList(new CreateFileSearchToolResourceVectorStoreOptions(Arrays.asList(openAIFile.getId()))))));
Arrays.asList(new CreateFileSearchToolResourceVectorStoreOptions(
Arrays.asList(openAIFile.getId()))))));

Assistant assistant = client.createAssistant(
new AssistantCreationOptions(deploymentOrModelId)
Expand Down
4 changes: 2 additions & 2 deletions sdk/openai/azure-ai-openai-assistants/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo" : "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath" : "java",
"TagPrefix" : "java/assistants/azure-ai-openai-assistants",
"Tag" : "java/assistants/azure-ai-openai-assistants_868e5c86d0"
}
"Tag" : "java/assistants/azure-ai-openai-assistants_19cb2164a3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.azure.ai.openai.assistants.models.UpdateAssistantOptions;
import com.azure.ai.openai.assistants.models.UpdateAssistantThreadOptions;
import com.azure.ai.openai.assistants.models.VectorStore;
import com.azure.ai.openai.assistants.models.VectorStoreChunkingStrategyRequest;
import com.azure.ai.openai.assistants.models.VectorStoreDeletionStatus;
import com.azure.ai.openai.assistants.models.VectorStoreFile;
import com.azure.ai.openai.assistants.models.VectorStoreFileBatch;
Expand Down Expand Up @@ -3751,4 +3752,62 @@ public Mono<PageableList<VectorStoreFile>> listVectorStoreFileBatchFiles(String
.map(vectorStoreFileList -> PageableListAccessHelper.create(vectorStoreFileList.getData(),
vectorStoreFileList.getFirstId(), vectorStoreFileList.getLastId(), vectorStoreFileList.isHasMore()));
}

/**
* Create a vector store file by attaching a file to a vector store.
*
* @param vectorStoreId The ID of the vector store for which to create a File.
* @param fileId A File ID that the vector store should use. Useful for tools like `file_search` that can access
* files.
* @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return description of a file attached to a vector store on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<VectorStoreFile> createVectorStoreFile(String vectorStoreId, String fileId,
VectorStoreChunkingStrategyRequest chunkingStrategy) {
// Generated convenience method for createVectorStoreFileWithResponse
RequestOptions requestOptions = new RequestOptions();
CreateVectorStoreFileRequest createVectorStoreFileRequestObj
= new CreateVectorStoreFileRequest(fileId).setChunkingStrategy(chunkingStrategy);
BinaryData createVectorStoreFileRequest = BinaryData.fromObject(createVectorStoreFileRequestObj);
return createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class));
}

/**
* Create a vector store file batch.
*
* @param vectorStoreId The ID of the vector store for which to create a File Batch.
* @param fileIds A list of File IDs that the vector store should use. Useful for tools like `file_search` that can
* access files.
* @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a batch of files attached to a vector store on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<VectorStoreFileBatch> createVectorStoreFileBatch(String vectorStoreId, List<String> fileIds,
VectorStoreChunkingStrategyRequest chunkingStrategy) {
// Generated convenience method for createVectorStoreFileBatchWithResponse
RequestOptions requestOptions = new RequestOptions();
CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequestObj
= new CreateVectorStoreFileBatchRequest(fileIds).setChunkingStrategy(chunkingStrategy);
BinaryData createVectorStoreFileBatchRequest = BinaryData.fromObject(createVectorStoreFileBatchRequestObj);
return createVectorStoreFileBatchWithResponse(vectorStoreId, createVectorStoreFileBatchRequest, requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFileBatch.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.azure.ai.openai.assistants.models.UpdateAssistantOptions;
import com.azure.ai.openai.assistants.models.UpdateAssistantThreadOptions;
import com.azure.ai.openai.assistants.models.VectorStore;
import com.azure.ai.openai.assistants.models.VectorStoreChunkingStrategyRequest;
import com.azure.ai.openai.assistants.models.VectorStoreDeletionStatus;
import com.azure.ai.openai.assistants.models.VectorStoreFile;
import com.azure.ai.openai.assistants.models.VectorStoreFileBatch;
Expand Down Expand Up @@ -3765,4 +3766,61 @@ public PageableList<VectorStoreFile> listVectorStoreFileBatchFiles(String vector
return PageableListAccessHelper.create(vectorStoreFileList.getData(), vectorStoreFileList.getFirstId(),
vectorStoreFileList.getLastId(), vectorStoreFileList.isHasMore());
}

/**
* Create a vector store file by attaching a file to a vector store.
*
* @param vectorStoreId The ID of the vector store for which to create a File.
* @param fileId A File ID that the vector store should use. Useful for tools like `file_search` that can access
* files.
* @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return description of a file attached to a vector store.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public VectorStoreFile createVectorStoreFile(String vectorStoreId, String fileId,
VectorStoreChunkingStrategyRequest chunkingStrategy) {
// Generated convenience method for createVectorStoreFileWithResponse
RequestOptions requestOptions = new RequestOptions();
CreateVectorStoreFileRequest createVectorStoreFileRequestObj
= new CreateVectorStoreFileRequest(fileId).setChunkingStrategy(chunkingStrategy);
BinaryData createVectorStoreFileRequest = BinaryData.fromObject(createVectorStoreFileRequestObj);
return createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, requestOptions).getValue()
.toObject(VectorStoreFile.class);
}

/**
* Create a vector store file batch.
*
* @param vectorStoreId The ID of the vector store for which to create a File Batch.
* @param fileIds A list of File IDs that the vector store should use. Useful for tools like `file_search` that can
* access files.
* @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a batch of files attached to a vector store.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public VectorStoreFileBatch createVectorStoreFileBatch(String vectorStoreId, List<String> fileIds,
VectorStoreChunkingStrategyRequest chunkingStrategy) {
// Generated convenience method for createVectorStoreFileBatchWithResponse
RequestOptions requestOptions = new RequestOptions();
CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequestObj
= new CreateVectorStoreFileBatchRequest(fileIds).setChunkingStrategy(chunkingStrategy);
BinaryData createVectorStoreFileBatchRequest = BinaryData.fromObject(createVectorStoreFileBatchRequestObj);
return createVectorStoreFileBatchWithResponse(vectorStoreId, createVectorStoreFileBatchRequest, requestOptions)
.getValue()
.toObject(VectorStoreFileBatch.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ public enum AssistantsServiceVersion implements ServiceVersion {
/**
* Enum value 2024-05-01-preview.
*/
V2024_05_01_PREVIEW("2024-05-01-preview");
V2024_05_01_PREVIEW("2024-05-01-preview"),

/**
* Enum value 2024-07-01-preview.
*/
V2024_07_01_PREVIEW("2024-07-01-preview");

private final String version;

Expand All @@ -40,6 +45,6 @@ public String getVersion() {
* @return The latest {@link AssistantsServiceVersion}.
*/
public static AssistantsServiceVersion getLatest() {
return V2024_05_01_PREVIEW;
return V2024_07_01_PREVIEW;
}
}
Loading

0 comments on commit 0879248

Please sign in to comment.