ChatCompletionRequest class
ChatCompletionRequest is the request body for the chat completion endpoint.
- Annotations
-
- @freezed
Constructors
-
ChatCompletionRequest({required String model, required List messages, @Deprecated("Use tools instead") List<
ChatFunction> ? functions, @Deprecated("use toolChoice instead") dynamic functionCall, double? temperature, double? topP, int? n, bool? stream, List<String> ? stop, int? maxTokens, double? presencePenalty, double? frequencyPenalty, ResponseFormat? responseFormat, Map<String, dynamic> ? logitBias, List<ChatTool> ? tools, dynamic toolChoice, String? user}) -
constfactory
-
ChatCompletionRequest.fromJson(Map<
String, Object?> json) -
factory
Properties
-
copyWith
→ $ChatCompletionRequestCopyWith<
ChatCompletionRequest> -
no setterinherited
- frequencyPenalty → double?
-
Number between -2.0 and 2.0. Positive values penalize new tokens
based on whether they appear in the text so far, increasing the
model's likelihood to talk about new topics.
no setterinherited
- functionCall → dynamic
-
Controls how the model responds to function calls. "none" means the model
does not call a function, and responds to the end-user. "auto" means
the model can pick between an end-user or calling a function.
Specifying a particular function via {"name":\ "my_function"} forces
the model to call that function. "none" is the default when no functions
are present. "auto" is the default if functions are present.
no setterinherited
-
functions
→ List<
ChatFunction> ? -
A list of functions the model may generate JSON inputs for.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
logitBias
→ Map<
String, dynamic> ? -
Modify the likelihood of specified tokens appearing in the completion.
Defaults to null.
Accepts a json object that maps tokens (specified by their token ID in
the tokenizer) to an associated bias value from -100 to 100.
Mathematically, the bias is added to the logits generated by the model
prior to sampling. The exact effect will vary per model, but values
between -1 and 1 should decrease or increase likelihood of selection;
values like -100 or 100 should result in a ban or exclusive selection
of the relevant token.
no setterinherited
- maxTokens → int?
-
The maximum number of tokens to generate in the chat completion.
defaults to inf.
The total length of input tokens and generated tokens is limited by the
model's context length.
no setterinherited
- messages → List
-
The messages to generate chat completions for, in the chat format.
no setterinherited
- model → String
-
ID of the model to use. See the
model endpoint compatibility table
for details on which models work with the Chat API.
no setterinherited
- n → int?
-
How many chat completion choices to generate for each input message.
Defaults to 1.
no setterinherited
- presencePenalty → double?
-
Number between -2.0 and 2.0. Positive values penalize new tokens
based on whether they appear in the text so far, increasing the model's
likelihood to talk about new topics.
no setterinherited
- responseFormat → ResponseFormat?
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stop
→ List<
String> ? -
Up to 4 sequences where the API will stop generating further tokens.
Defaults to null
no setterinherited
- stream → bool?
-
If set, partial message deltas will be sent, like in ChatGPT.
Tokens will be sent as data-only server-sent events as they
become available, with the stream terminated by a data:
DONE
message. See the OpenAI Cookbook for example code. Defaults to false.no setterinherited - temperature → double?
-
The sampling temperature. Defaults to 1.
What sampling temperature to use, between 0 and 2. Higher values l
ike 0.8 will make the output more random, while lower values like 0.2
will make it more focused and deterministic.
no setterinherited
- toolChoice → dynamic
-
Controls which (if any) function is called by the model.
none
means the model will not call a function and instead generates a message.auto
means the model can pick between generating a message or calling a function. Specifying a particular function via{"type: "function", "function": {"name": "my_function"}}
forces the model to call that function.none
is the default when no functions are present.auto
is the default if functions are present.no setterinherited -
tools
→ List<
ChatTool> ? -
A list of tools the model may call. Currently,
only functions are supported as a tool. Use this to provide a list of
functions the model may generate JSON inputs for.
no setterinherited
- topP → double?
-
The top-p sampling parameter. Defaults to 1.
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.
no setterinherited
- user → String?
-
A unique identifier representing your end-user, which can help OpenAI to
monitor and detect abuse. Learn more.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited