次の方法で共有


ThreadsClient Class

  • java.lang.Object
    • com.azure.ai.agents.persistent.ThreadsClient

public final class ThreadsClient

Initializes a new instance of the synchronous Threads type.

Method Summary

Modifier and Type Method and Description
PersistentAgentThread createThread()

Creates a new thread.

PersistentAgentThread createThread(List<ThreadMessageOptions> messages, ToolResources toolResources, Map<String,String> metadata)

Creates a new thread.

Response<BinaryData> createThreadWithResponse(BinaryData createThreadRequest, RequestOptions requestOptions)

Creates a new thread.

void deleteThread(String threadId)

Deletes an existing thread.

PersistentAgentThread getThread(String threadId)

Gets information about an existing thread.

Response<BinaryData> getThreadWithResponse(String threadId, RequestOptions requestOptions)

Gets information about an existing thread.

PagedIterable<PersistentAgentThread> listThreads()

Gets a list of threads that were previously created.

PagedIterable<PersistentAgentThread> listThreads(Integer limit, ListSortOrder order, String after, String before)

Gets a list of threads that were previously created.

PagedIterable<BinaryData> listThreads(RequestOptions requestOptions)

Gets a list of threads that were previously created.

PersistentAgentThread updateThread(String threadId)

Modifies an existing thread.

PersistentAgentThread updateThread(String threadId, ToolResources toolResources, Map<String,String> metadata)

Modifies an existing thread.

Response<BinaryData> updateThreadWithResponse(String threadId, BinaryData updateThreadRequest, RequestOptions requestOptions)

Modifies an existing thread.

Methods inherited from java.lang.Object

Method Details

createThread

public PersistentAgentThread createThread()

Creates a new thread. Threads contain messages and can be run by agents.

Returns:

information about a single thread associated with an agent.

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.

createThreadWithResponse

public Response<BinaryData> createThreadWithResponse(BinaryData createThreadRequest, 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<T>.

deleteThread

public void deleteThread(String threadId)

Deletes an existing thread.

Parameters:

threadId - Identifier of the thread.

getThread

public PersistentAgentThread getThread(String threadId)

Gets information about an existing thread.

Parameters:

threadId - Identifier of the thread.

Returns:

information about an existing thread.

getThreadWithResponse

public Response<BinaryData> getThreadWithResponse(String threadId, 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<T>.

listThreads

public PagedIterable<PersistentAgentThread> listThreads()

Gets a list of threads that were previously created.

Returns:

a list of threads that were previously created as paginated response with PagedIterable<T>.

listThreads

public 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<T>.

listThreads

public PagedIterable<BinaryData> listThreads(RequestOptions requestOptions)

Gets a list of threads that were previously created.

Query 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. |

You can add these to a request with RequestOptions#addQueryParam

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<T>.

updateThread

public PersistentAgentThread updateThread(String threadId)

Modifies an existing thread.

Parameters:

threadId - The ID of the thread to modify.

Returns:

information about a single thread associated with an agent.

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.

updateThreadWithResponse

public Response<BinaryData> updateThreadWithResponse(String threadId, BinaryData updateThreadRequest, 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<T>.

Applies to