AgentsClient.CreateThreadAndRunAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateThreadAndRunAsync(RequestContent, RequestContext)
- Source:
- AgentsClient.cs
[Protocol Method] Creates a new agent thread and immediately starts a run using that new thread.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreateThreadAndRunAsync(String, AgentThreadCreationOptions, String, String, IEnumerable<ToolDefinition>, UpdateToolResourcesOptions, Nullable<Boolean>, Nullable<Single>, Nullable<Single>, Nullable<Int32>, Nullable<Int32>, TruncationObject, BinaryData, BinaryData, IReadOnlyDictionary<String, String>, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> CreateThreadAndRunAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateThreadAndRunAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateThreadAndRunAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateThreadAndRunAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content
is null.
Service returned a non-success status code.
Applies to
CreateThreadAndRunAsync(String, AgentThreadCreationOptions, String, String, IEnumerable<ToolDefinition>, UpdateToolResourcesOptions, Nullable<Boolean>, Nullable<Single>, Nullable<Single>, Nullable<Int32>, Nullable<Int32>, TruncationObject, BinaryData, BinaryData, IReadOnlyDictionary<String, String>, CancellationToken)
- Source:
- AgentsClient.cs
Creates a new agent thread and immediately starts a run using that new thread.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Projects.ThreadRun>> CreateThreadAndRunAsync (string assistantId, Azure.AI.Projects.AgentThreadCreationOptions thread = default, string overrideModelName = default, string overrideInstructions = default, System.Collections.Generic.IEnumerable<Azure.AI.Projects.ToolDefinition> overrideTools = default, Azure.AI.Projects.UpdateToolResourcesOptions toolResources = default, bool? stream = default, float? temperature = default, float? topP = default, int? maxPromptTokens = default, int? maxCompletionTokens = default, Azure.AI.Projects.TruncationObject truncationStrategy = default, BinaryData toolChoice = default, BinaryData responseFormat = default, System.Collections.Generic.IReadOnlyDictionary<string,string> metadata = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateThreadAndRunAsync : string * Azure.AI.Projects.AgentThreadCreationOptions * string * string * seq<Azure.AI.Projects.ToolDefinition> * Azure.AI.Projects.UpdateToolResourcesOptions * Nullable<bool> * Nullable<single> * Nullable<single> * Nullable<int> * Nullable<int> * Azure.AI.Projects.TruncationObject * BinaryData * BinaryData * System.Collections.Generic.IReadOnlyDictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Projects.ThreadRun>>
override this.CreateThreadAndRunAsync : string * Azure.AI.Projects.AgentThreadCreationOptions * string * string * seq<Azure.AI.Projects.ToolDefinition> * Azure.AI.Projects.UpdateToolResourcesOptions * Nullable<bool> * Nullable<single> * Nullable<single> * Nullable<int> * Nullable<int> * Azure.AI.Projects.TruncationObject * BinaryData * BinaryData * System.Collections.Generic.IReadOnlyDictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Projects.ThreadRun>>
Public Overridable Function CreateThreadAndRunAsync (assistantId As String, Optional thread As AgentThreadCreationOptions = Nothing, Optional overrideModelName As String = Nothing, Optional overrideInstructions As String = Nothing, Optional overrideTools As IEnumerable(Of ToolDefinition) = Nothing, Optional toolResources As UpdateToolResourcesOptions = Nothing, Optional stream As Nullable(Of Boolean) = Nothing, Optional temperature As Nullable(Of Single) = Nothing, Optional topP As Nullable(Of Single) = Nothing, Optional maxPromptTokens As Nullable(Of Integer) = Nothing, Optional maxCompletionTokens As Nullable(Of Integer) = Nothing, Optional truncationStrategy As TruncationObject = Nothing, Optional toolChoice As BinaryData = Nothing, Optional responseFormat As BinaryData = Nothing, Optional metadata As IReadOnlyDictionary(Of String, String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of ThreadRun))
Parameters
- assistantId
- String
The ID of the agent for which the thread should be created.
- thread
- AgentThreadCreationOptions
The details used to create the new thread. If no thread is provided, an empty one will be created.
- overrideModelName
- String
The overridden model that the agent should use to run the thread.
- overrideInstructions
- String
The overridden system instructions the agent should use to run the thread.
- overrideTools
- IEnumerable<ToolDefinition>
The overridden list of enabled tools the agent should use to run the thread.
- toolResources
- UpdateToolResourcesOptions
Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis.
If true
, returns a stream of events that happen during the Run as server-sent events,
terminating when the Run enters a terminal state with a data: [DONE]
message.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
the run will end with status incomplete
. See incomplete_details
for more info.
The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only
the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens
specified, the run will end with status incomplete
. See incomplete_details
for more info.
- truncationStrategy
- TruncationObject
The strategy to use for dropping messages as the context windows moves forward.
- toolChoice
- BinaryData
Controls whether or not and which tool is called by the model.
- responseFormat
- BinaryData
Specifies the format that the model must output.
- metadata
- IReadOnlyDictionary<String,String>
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.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
assistantId
is null.
Applies to
Azure SDK for .NET