Package com.azure.ai.agents.persistent
Class ThreadsClient
java.lang.Object
com.azure.ai.agents.persistent.ThreadsClient
Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new thread.createThread(List<ThreadMessageOptions> messages, ToolResources toolResources, Map<String, String> metadata) Creates a new thread.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> createThreadWithResponse(com.azure.core.util.BinaryData createThreadRequest, com.azure.core.http.rest.RequestOptions requestOptions) Creates a new thread.deleteThread(String threadId) Deletes an existing thread.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> deleteThreadWithResponse(String threadId, com.azure.core.http.rest.RequestOptions requestOptions) Deletes an existing thread.Gets information about an existing thread.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getThreadWithResponse(String threadId, com.azure.core.http.rest.RequestOptions requestOptions) Gets information about an existing thread.com.azure.core.http.rest.PagedIterable<PersistentAgentThread> Gets a list of threads that were previously created.com.azure.core.http.rest.PagedIterable<com.azure.core.util.BinaryData> listThreads(com.azure.core.http.rest.RequestOptions requestOptions) Gets a list of threads that were previously created.com.azure.core.http.rest.PagedIterable<PersistentAgentThread> listThreads(Integer limit, ListSortOrder order, String after, String before) Gets a list of threads that were previously created.updateThread(String threadId) Modifies an existing thread.updateThread(String threadId, ToolResources toolResources, Map<String, String> metadata) Modifies an existing thread.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> updateThreadWithResponse(String threadId, com.azure.core.util.BinaryData updateThreadRequest, com.azure.core.http.rest.RequestOptions requestOptions) Modifies an existing thread.
-
Method Details
-
createThreadWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> createThreadWithResponse(com.azure.core.util.BinaryData createThreadRequest, com.azure.core.http.rest.RequestOptions requestOptions) Creates a new thread. Threads contain messages and can be run by agents.Request Body Schema
{ messages (Optional): [ (Optional){ role: String(user/assistant) (Required) content: BinaryData (Required) attachments (Optional): [ (Optional){ file_id: String (Optional) data_source (Optional): { uri: String (Required) type: String(uri_asset/id_asset) (Required) } tools (Required): [ BinaryData (Required) ] } ] metadata (Optional): { String: String (Required) } } ] tool_resources (Optional): { code_interpreter (Optional): { file_ids (Optional): [ String (Optional) ] data_sources (Optional): [ (recursive schema, see above) ] } file_search (Optional): { vector_store_ids (Optional): [ String (Optional) ] vector_stores (Optional): [ (Optional){ name: String (Required) configuration (Required): { data_sources (Required): [ (recursive schema, see above) ] } } ] } azure_ai_search (Optional): { indexes (Optional): [ (Optional){ index_connection_id: String (Optional) index_name: String (Optional) query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional) top_k: Integer (Optional) filter: String (Optional) index_asset_id: String (Optional) } ] } } metadata (Optional): { String: String (Required) } }Response Body Schema
{ id: String (Required) object: String (Required) created_at: long (Required) tool_resources (Required): { code_interpreter (Optional): { file_ids (Optional): [ String (Optional) ] data_sources (Optional): [ (Optional){ uri: String (Required) type: String(uri_asset/id_asset) (Required) } ] } file_search (Optional): { vector_store_ids (Optional): [ String (Optional) ] vector_stores (Optional): [ (Optional){ name: String (Required) configuration (Required): { data_sources (Required): [ (recursive schema, see above) ] } } ] } azure_ai_search (Optional): { indexes (Optional): [ (Optional){ index_connection_id: String (Optional) index_name: String (Optional) query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional) top_k: Integer (Optional) filter: String (Optional) index_asset_id: String (Optional) } ] } } metadata (Required): { String: String (Required) } }- Parameters:
createThreadRequest- The createThreadRequest parameter.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- information about a single thread associated with an agent along with
Response. - Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.
-
getThreadWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getThreadWithResponse(String threadId, com.azure.core.http.rest.RequestOptions requestOptions) Gets information about an existing thread.Response Body Schema
{ id: String (Required) object: String (Required) created_at: long (Required) tool_resources (Required): { code_interpreter (Optional): { file_ids (Optional): [ String (Optional) ] data_sources (Optional): [ (Optional){ uri: String (Required) type: String(uri_asset/id_asset) (Required) } ] } file_search (Optional): { vector_store_ids (Optional): [ String (Optional) ] vector_stores (Optional): [ (Optional){ name: String (Required) configuration (Required): { data_sources (Required): [ (recursive schema, see above) ] } } ] } azure_ai_search (Optional): { indexes (Optional): [ (Optional){ index_connection_id: String (Optional) index_name: String (Optional) query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional) top_k: Integer (Optional) filter: String (Optional) index_asset_id: String (Optional) } ] } } metadata (Required): { String: String (Required) } }- Parameters:
threadId- Identifier of the thread.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- information about an existing thread along with
Response. - Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.
-
updateThreadWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> updateThreadWithResponse(String threadId, com.azure.core.util.BinaryData updateThreadRequest, com.azure.core.http.rest.RequestOptions requestOptions) Modifies an existing thread.Request Body Schema
{ tool_resources (Optional): { code_interpreter (Optional): { file_ids (Optional): [ String (Optional) ] data_sources (Optional): [ (Optional){ uri: String (Required) type: String(uri_asset/id_asset) (Required) } ] } file_search (Optional): { vector_store_ids (Optional): [ String (Optional) ] vector_stores (Optional): [ (Optional){ name: String (Required) configuration (Required): { data_sources (Required): [ (recursive schema, see above) ] } } ] } azure_ai_search (Optional): { indexes (Optional): [ (Optional){ index_connection_id: String (Optional) index_name: String (Optional) query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional) top_k: Integer (Optional) filter: String (Optional) index_asset_id: String (Optional) } ] } } metadata (Optional): { String: String (Required) } }Response Body Schema
{ id: String (Required) object: String (Required) created_at: long (Required) tool_resources (Required): { code_interpreter (Optional): { file_ids (Optional): [ String (Optional) ] data_sources (Optional): [ (Optional){ uri: String (Required) type: String(uri_asset/id_asset) (Required) } ] } file_search (Optional): { vector_store_ids (Optional): [ String (Optional) ] vector_stores (Optional): [ (Optional){ name: String (Required) configuration (Required): { data_sources (Required): [ (recursive schema, see above) ] } } ] } azure_ai_search (Optional): { indexes (Optional): [ (Optional){ index_connection_id: String (Optional) index_name: String (Optional) query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional) top_k: Integer (Optional) filter: String (Optional) index_asset_id: String (Optional) } ] } } metadata (Required): { String: String (Required) } }- Parameters:
threadId- The ID of the thread to modify.updateThreadRequest- The updateThreadRequest parameter.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- information about a single thread associated with an agent along with
Response. - Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.
-
deleteThreadWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> deleteThreadWithResponse(String threadId, com.azure.core.http.rest.RequestOptions requestOptions) Deletes an existing thread.Response Body Schema
{ id: String (Required) deleted: boolean (Required) object: String (Required) }- Parameters:
threadId- Identifier of the thread.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- the status of a thread deletion operation along with
Response. - Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.
-
createThread
public PersistentAgentThread createThread(List<ThreadMessageOptions> messages, ToolResources toolResources, Map<String, String> metadata) Creates a new thread. Threads contain messages and can be run by agents.- Parameters:
messages- The initial messages to associate with the new thread.toolResources- A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.metadata- A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.- Returns:
- information about a single thread associated with an agent.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
createThread
Creates a new thread. Threads contain messages and can be run by agents.- Returns:
- information about a single thread associated with an agent.
- Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
listThreads
public com.azure.core.http.rest.PagedIterable<PersistentAgentThread> listThreads(Integer limit, ListSortOrder order, String after, String before) Gets a list of threads that were previously created.- Parameters:
limit- A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.order- Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.after- A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.before- A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.- Returns:
- a list of threads that were previously created as paginated response with
PagedIterable. - Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
listThreads
Gets a list of threads that were previously created.- Returns:
- a list of threads that were previously created as paginated response with
PagedIterable. - Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
getThread
Gets information about an existing thread.- Parameters:
threadId- Identifier of the thread.- Returns:
- information about an existing thread.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
updateThread
public PersistentAgentThread updateThread(String threadId, ToolResources toolResources, Map<String, String> metadata) Modifies an existing thread.- Parameters:
threadId- The ID of the thread to modify.toolResources- A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.metadata- A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.- Returns:
- information about a single thread associated with an agent.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
updateThread
Modifies an existing thread.- Parameters:
threadId- The ID of the thread to modify.- Returns:
- information about a single thread associated with an agent.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
deleteThread
Deletes an existing thread.- Parameters:
threadId- Identifier of the thread.- Returns:
- the status of a thread deletion operation.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
listThreads
public com.azure.core.http.rest.PagedIterable<com.azure.core.util.BinaryData> listThreads(com.azure.core.http.rest.RequestOptions requestOptions) Gets a list of threads that were previously created.Query Parameters
You can add these to a request withQuery Parameters Name Type Required Description limit Integer No A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. order String No Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc", "desc". after String No A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. before String No A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. RequestOptions.addQueryParam(java.lang.String, java.lang.String)Response Body Schema
{ id: String (Required) object: String (Required) created_at: long (Required) tool_resources (Required): { code_interpreter (Optional): { file_ids (Optional): [ String (Optional) ] data_sources (Optional): [ (Optional){ uri: String (Required) type: String(uri_asset/id_asset) (Required) } ] } file_search (Optional): { vector_store_ids (Optional): [ String (Optional) ] vector_stores (Optional): [ (Optional){ name: String (Required) configuration (Required): { data_sources (Required): [ (recursive schema, see above) ] } } ] } azure_ai_search (Optional): { indexes (Optional): [ (Optional){ index_connection_id: String (Optional) index_name: String (Optional) query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional) top_k: Integer (Optional) filter: String (Optional) index_asset_id: String (Optional) } ] } } metadata (Required): { String: String (Required) } }- Parameters:
requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- a list of threads that were previously created as paginated response with
PagedIterable. - Throws:
com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.
-