-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openai_dart): Support new chat completion API functionality (#198)
- Added `gpt-4-1106-preview` > GPT-4 Turbo is more capable and has knowledge of world events up to April 2023. It has a 128k context window so it can fit the equivalent of more than 300 pages of text in a single prompt. We also optimized its performance so we are able to offer GPT-4 Turbo at a 3x cheaper price for input tokens and a 2x cheaper price for output tokens compared to GPT-4. - Support new function calling structure > We’re releasing several improvements today, including the ability to call multiple functions in a single message: users can send one message requesting multiple actions, such as “open the car window and turn off the A/C”, which would previously require multiple roundtrips with the model (learn more). We are also improving function calling accuracy: GPT-4 Turbo is more likely to return the right function parameters. - Support `response_format` > GPT-4 Turbo performs better than our previous models on tasks that require the careful following of instructions, such as generating specific formats (e.g., “always respond in XML”). It also supports our new JSON mode, which ensures the model will respond with valid JSON. The new API parameter response_format enables the model to constrain its output to generate a syntactically correct JSON object. JSON mode is useful for developers generating JSON in the Chat Completions API outside of function calling. - Support `seed` > The new seed parameter enables reproducible outputs by making the model return consistent completions most of the time. This beta feature is useful for use cases such as replaying requests for debugging, writing more comprehensive unit tests, and generally having a higher degree of control over the model behavior. We at OpenAI have been using this feature internally for our own unit tests and have found it invaluable. We’re excited to see how developers will use it.
- Loading branch information
1 parent
bb87c19
commit 01820d6
Showing
58 changed files
with
11,576 additions
and
4,258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ targets: | |
json_serializable: | ||
options: | ||
explicit_to_json: true | ||
include_if_null: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/openai_dart/lib/src/generated/schema/chat_completion_function.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/openai_dart/lib/src/generated/schema/chat_completion_function_call_option.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/openai_dart/lib/src/generated/schema/chat_completion_function_parameters.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/openai_dart/lib/src/generated/schema/chat_completion_message_function_call.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
packages/openai_dart/lib/src/generated/schema/chat_completion_message_role.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target | ||
// ignore_for_file: invalid_annotation_target, unused_import | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// ENUM: ChatCompletionMessageRole | ||
// ========================================== | ||
|
||
/// The role of the messages author. One of `system`, `user`, `assistant`, or `function`. | ||
/// The role of the messages author. One of `system`, `user`, `assistant`, or `tool` (`function` is deprecated). | ||
enum ChatCompletionMessageRole { | ||
@JsonValue('system') | ||
system, | ||
@JsonValue('user') | ||
user, | ||
@JsonValue('assistant') | ||
assistant, | ||
@JsonValue('tool') | ||
tool, | ||
@JsonValue('function') | ||
function, | ||
} |
58 changes: 58 additions & 0 deletions
58
packages/openai_dart/lib/src/generated/schema/chat_completion_message_tool_call.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target, unused_import | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// CLASS: ChatCompletionMessageToolCall | ||
// ========================================== | ||
|
||
/// A tool call generated by the model, such as a function call. | ||
@freezed | ||
class ChatCompletionMessageToolCall with _$ChatCompletionMessageToolCall { | ||
const ChatCompletionMessageToolCall._(); | ||
|
||
/// Factory constructor for ChatCompletionMessageToolCall | ||
const factory ChatCompletionMessageToolCall({ | ||
/// The ID of the tool call. | ||
required String id, | ||
|
||
/// The type of the tool. Currently, only `function` is supported. | ||
required ChatCompletionMessageToolCallType type, | ||
|
||
/// The name and arguments of a function that should be called, as generated by the model. | ||
required ChatCompletionMessageFunctionCall function, | ||
}) = _ChatCompletionMessageToolCall; | ||
|
||
/// Object construction from a JSON representation | ||
factory ChatCompletionMessageToolCall.fromJson(Map<String, dynamic> json) => | ||
_$ChatCompletionMessageToolCallFromJson(json); | ||
|
||
/// List of all property names of schema | ||
static const List<String> propertyNames = ['id', 'type', 'function']; | ||
|
||
/// Perform validations on the schema property values | ||
String? validateSchema() { | ||
return null; | ||
} | ||
|
||
/// Map representation of object (not serialized) | ||
Map<String, dynamic> toMap() { | ||
return { | ||
'id': id, | ||
'type': type, | ||
'function': function, | ||
}; | ||
} | ||
} | ||
|
||
// ========================================== | ||
// ENUM: ChatCompletionMessageToolCallType | ||
// ========================================== | ||
|
||
/// The type of the tool. Currently, only `function` is supported. | ||
enum ChatCompletionMessageToolCallType { | ||
@JsonValue('function') | ||
function, | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/openai_dart/lib/src/generated/schema/chat_completion_message_tool_calls.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target, unused_import | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// TYPE: ChatCompletionMessageToolCalls | ||
// ========================================== | ||
|
||
/// The tool calls generated by the model, such as function calls. | ||
typedef ChatCompletionMessageToolCalls = List<ChatCompletionMessageToolCall>; |
58 changes: 58 additions & 0 deletions
58
packages/openai_dart/lib/src/generated/schema/chat_completion_named_tool_choice.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target, unused_import | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// CLASS: ChatCompletionNamedToolChoice | ||
// ========================================== | ||
|
||
/// Specifies a tool the model should use. Use to force the model to call a specific function. | ||
@freezed | ||
class ChatCompletionNamedToolChoice with _$ChatCompletionNamedToolChoice { | ||
const ChatCompletionNamedToolChoice._(); | ||
|
||
/// Factory constructor for ChatCompletionNamedToolChoice | ||
const factory ChatCompletionNamedToolChoice({ | ||
/// The type of the tool. Currently, only `function` is supported. | ||
@JsonKey( | ||
includeIfNull: false, | ||
unknownEnumValue: JsonKey.nullForUndefinedEnumValue, | ||
) | ||
ChatCompletionNamedToolChoiceType? type, | ||
|
||
/// Forces the model to call the specified function. | ||
@JsonKey(includeIfNull: false) ChatCompletionFunctionCallOption? function, | ||
}) = _ChatCompletionNamedToolChoice; | ||
|
||
/// Object construction from a JSON representation | ||
factory ChatCompletionNamedToolChoice.fromJson(Map<String, dynamic> json) => | ||
_$ChatCompletionNamedToolChoiceFromJson(json); | ||
|
||
/// List of all property names of schema | ||
static const List<String> propertyNames = ['type', 'function']; | ||
|
||
/// Perform validations on the schema property values | ||
String? validateSchema() { | ||
return null; | ||
} | ||
|
||
/// Map representation of object (not serialized) | ||
Map<String, dynamic> toMap() { | ||
return { | ||
'type': type, | ||
'function': function, | ||
}; | ||
} | ||
} | ||
|
||
// ========================================== | ||
// ENUM: ChatCompletionNamedToolChoiceType | ||
// ========================================== | ||
|
||
/// The type of the tool. Currently, only `function` is supported. | ||
enum ChatCompletionNamedToolChoiceType { | ||
@JsonValue('function') | ||
function, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/openai_dart/lib/src/generated/schema/chat_completion_stream_message_function_call.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../openai_dart/lib/src/generated/schema/chat_completion_stream_message_tool_call_chunk.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target, unused_import | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// CLASS: ChatCompletionStreamMessageToolCallChunk | ||
// ========================================== | ||
|
||
/// The tool that should be called, as generated by the model. | ||
@freezed | ||
class ChatCompletionStreamMessageToolCallChunk | ||
with _$ChatCompletionStreamMessageToolCallChunk { | ||
const ChatCompletionStreamMessageToolCallChunk._(); | ||
|
||
/// Factory constructor for ChatCompletionStreamMessageToolCallChunk | ||
const factory ChatCompletionStreamMessageToolCallChunk({ | ||
/// No Description | ||
required int index, | ||
|
||
/// The ID of the tool call. | ||
@JsonKey(includeIfNull: false) String? id, | ||
|
||
/// The type of the tool. Currently, only `function` is supported. | ||
@JsonKey( | ||
includeIfNull: false, | ||
unknownEnumValue: JsonKey.nullForUndefinedEnumValue, | ||
) | ||
ChatCompletionStreamMessageToolCallChunkType? type, | ||
|
||
/// The name and arguments of a function that should be called, as generated by the model. | ||
@JsonKey(includeIfNull: false) | ||
ChatCompletionStreamMessageFunctionCall? function, | ||
}) = _ChatCompletionStreamMessageToolCallChunk; | ||
|
||
/// Object construction from a JSON representation | ||
factory ChatCompletionStreamMessageToolCallChunk.fromJson( | ||
Map<String, dynamic> json) => | ||
_$ChatCompletionStreamMessageToolCallChunkFromJson(json); | ||
|
||
/// List of all property names of schema | ||
static const List<String> propertyNames = ['index', 'id', 'type', 'function']; | ||
|
||
/// Perform validations on the schema property values | ||
String? validateSchema() { | ||
return null; | ||
} | ||
|
||
/// Map representation of object (not serialized) | ||
Map<String, dynamic> toMap() { | ||
return { | ||
'index': index, | ||
'id': id, | ||
'type': type, | ||
'function': function, | ||
}; | ||
} | ||
} | ||
|
||
// ========================================== | ||
// ENUM: ChatCompletionStreamMessageToolCallChunkType | ||
// ========================================== | ||
|
||
/// The type of the tool. Currently, only `function` is supported. | ||
enum ChatCompletionStreamMessageToolCallChunkType { | ||
@JsonValue('function') | ||
function, | ||
} |
Oops, something went wrong.