-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98ef0e4
commit 0404961
Showing
11 changed files
with
4,409 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
example/openai/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,99 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// CLASS: ChatCompletionMessageToolCall | ||
// ========================================== | ||
|
||
/// No Description | ||
@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 function that the model called. | ||
required ChatCompletionMessageToolCallFunction 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, | ||
} | ||
|
||
// ========================================== | ||
// CLASS: ChatCompletionMessageToolCallFunction | ||
// ========================================== | ||
|
||
/// The function that the model called. | ||
@freezed | ||
class ChatCompletionMessageToolCallFunction | ||
with _$ChatCompletionMessageToolCallFunction { | ||
const ChatCompletionMessageToolCallFunction._(); | ||
|
||
/// Factory constructor for ChatCompletionMessageToolCallFunction | ||
const factory ChatCompletionMessageToolCallFunction({ | ||
/// The name of the function to call. | ||
required String name, | ||
|
||
/// The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. | ||
required String arguments, | ||
}) = _ChatCompletionMessageToolCallFunction; | ||
|
||
/// Object construction from a JSON representation | ||
factory ChatCompletionMessageToolCallFunction.fromJson( | ||
Map<String, dynamic> json) => | ||
_$ChatCompletionMessageToolCallFunctionFromJson(json); | ||
|
||
/// List of all property names of schema | ||
static const List<String> propertyNames = ['name', 'arguments']; | ||
|
||
/// Perform validations on the schema property values | ||
String? validateSchema() { | ||
return null; | ||
} | ||
|
||
/// Map representation of object (not serialized) | ||
Map<String, dynamic> toMap() { | ||
return { | ||
'name': name, | ||
'arguments': arguments, | ||
}; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
example/openai/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 | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// TYPE: ChatCompletionMessageToolCalls | ||
// ========================================== | ||
|
||
/// The tool calls generated by the model, such as function calls. | ||
typedef ChatCompletionMessageToolCalls = List<ChatCompletionMessageToolCall>; |
243 changes: 243 additions & 0 deletions
243
example/openai/generated/schema/chat_completion_request_message.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,243 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: invalid_annotation_target | ||
part of open_a_i_schema; | ||
|
||
// ========================================== | ||
// CLASS: ChatCompletionRequestMessage | ||
// ========================================== | ||
|
||
/// A message in a chat conversation. | ||
@Freezed(unionKey: 'role') | ||
sealed class ChatCompletionRequestMessage with _$ChatCompletionRequestMessage { | ||
const ChatCompletionRequestMessage._(); | ||
|
||
// ------------------------------------------ | ||
// UNION: ChatCompletionRequestSystemMessage | ||
// ------------------------------------------ | ||
|
||
/// A system message in a chat conversation. | ||
const factory ChatCompletionRequestMessage.system({ | ||
/// The contents of the system message. | ||
required String? content, | ||
|
||
/// The role of the messages author, in this case `system`. | ||
required SystemMessageRole role, | ||
}) = ChatCompletionRequestSystemMessage; | ||
|
||
// ------------------------------------------ | ||
// UNION: ChatCompletionRequestUserMessage | ||
// ------------------------------------------ | ||
|
||
/// A user message in a chat conversation. | ||
const factory ChatCompletionRequestMessage.user({ | ||
/// The contents of the user message. | ||
@_UserMessageContentConverter() required UserMessageContent? content, | ||
|
||
/// The role of the messages author, in this case `user`. | ||
required UserMessageRole role, | ||
}) = ChatCompletionRequestUserMessage; | ||
|
||
// ------------------------------------------ | ||
// UNION: ChatCompletionRequestAssistantMessage | ||
// ------------------------------------------ | ||
|
||
/// An assistant message in a chat conversation. | ||
const factory ChatCompletionRequestMessage.assistant({ | ||
/// The contents of the assistant message. | ||
required String? content, | ||
|
||
/// The role of the messages author, in this case `assistant`. | ||
required AssistantMessageRole role, | ||
|
||
/// No Description | ||
@JsonKey(name: 'tool_calls', includeIfNull: false) | ||
ChatCompletionMessageToolCalls? toolCalls, | ||
|
||
/// Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. | ||
@JsonKey(name: 'function_call', includeIfNull: false) | ||
AssistantMessageFunctionCall? functionCall, | ||
}) = ChatCompletionRequestAssistantMessage; | ||
|
||
// ------------------------------------------ | ||
// UNION: ChatCompletionRequestToolMessage | ||
// ------------------------------------------ | ||
|
||
/// A tool message in a chat conversation. | ||
const factory ChatCompletionRequestMessage.tool({ | ||
/// The role of the messages author, in this case `tool`. | ||
required ToolMessageRole role, | ||
|
||
/// The contents of the tool message. | ||
required String? content, | ||
|
||
/// Tool call that this message is responding to. | ||
@JsonKey(name: 'tool_call_id') required String toolCallId, | ||
}) = ChatCompletionRequestToolMessage; | ||
|
||
// ------------------------------------------ | ||
// UNION: ChatCompletionRequestFunctionMessage | ||
// ------------------------------------------ | ||
|
||
/// A function message in a chat conversation. | ||
const factory ChatCompletionRequestMessage.function({ | ||
/// The role of the messages author, in this case `function`. | ||
required FunctionMessageRole role, | ||
|
||
/// The return value from the function call, to return to the model. | ||
required String? content, | ||
|
||
/// The name of the function to call. | ||
required String name, | ||
}) = ChatCompletionRequestFunctionMessage; | ||
|
||
/// Object construction from a JSON representation | ||
factory ChatCompletionRequestMessage.fromJson(Map<String, dynamic> json) => | ||
_$ChatCompletionRequestMessageFromJson(json); | ||
} | ||
|
||
// ========================================== | ||
// ENUM: SystemMessageRole | ||
// ========================================== | ||
|
||
/// The role of the messages author, in this case `system`. | ||
enum SystemMessageRole { | ||
@JsonValue('system') | ||
system, | ||
} | ||
|
||
// ========================================== | ||
// CLASS: UserMessageContent | ||
// ========================================== | ||
|
||
/// The contents of the user message. | ||
@freezed | ||
sealed class UserMessageContent with _$UserMessageContent { | ||
const UserMessageContent._(); | ||
|
||
/// An array of content parts with a defined type. | ||
const factory UserMessageContent.parts( | ||
List<ChatCompletionRequestMessageContentPart> value, | ||
) = UserMessageContentListChatCompletionRequestMessageContentPart; | ||
|
||
/// The text contents of the message. | ||
const factory UserMessageContent.string( | ||
String value, | ||
) = UserMessageContentString; | ||
|
||
/// Object construction from a JSON representation | ||
factory UserMessageContent.fromJson(Map<String, dynamic> json) => | ||
_$UserMessageContentFromJson(json); | ||
} | ||
|
||
/// Custom JSON converter for [UserMessageContent] | ||
class _UserMessageContentConverter | ||
implements JsonConverter<UserMessageContent, Object?> { | ||
const _UserMessageContentConverter(); | ||
|
||
@override | ||
UserMessageContent fromJson(Object? data) { | ||
if (data is List && | ||
data.every((item) => item is ChatCompletionRequestMessageContentPart)) { | ||
return UserMessageContentListChatCompletionRequestMessageContentPart( | ||
data.cast()); | ||
} | ||
if (data is String) { | ||
return UserMessageContentString(data); | ||
} | ||
throw Exception( | ||
'Unexpected value for UserMessageContent: $data', | ||
); | ||
} | ||
|
||
@override | ||
Object? toJson(UserMessageContent data) { | ||
return switch (data) { | ||
UserMessageContentListChatCompletionRequestMessageContentPart( | ||
value: final v | ||
) => | ||
v, | ||
UserMessageContentString(value: final v) => v, | ||
}; | ||
} | ||
} | ||
|
||
// ========================================== | ||
// ENUM: UserMessageRole | ||
// ========================================== | ||
|
||
/// The role of the messages author, in this case `user`. | ||
enum UserMessageRole { | ||
@JsonValue('user') | ||
user, | ||
} | ||
|
||
// ========================================== | ||
// ENUM: AssistantMessageRole | ||
// ========================================== | ||
|
||
/// The role of the messages author, in this case `assistant`. | ||
enum AssistantMessageRole { | ||
@JsonValue('assistant') | ||
assistant, | ||
} | ||
|
||
// ========================================== | ||
// CLASS: AssistantMessageFunctionCall | ||
// ========================================== | ||
|
||
/// Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. | ||
@freezed | ||
class AssistantMessageFunctionCall with _$AssistantMessageFunctionCall { | ||
const AssistantMessageFunctionCall._(); | ||
|
||
/// Factory constructor for AssistantMessageFunctionCall | ||
const factory AssistantMessageFunctionCall({ | ||
/// The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. | ||
required String arguments, | ||
|
||
/// The name of the function to call. | ||
required String name, | ||
}) = _AssistantMessageFunctionCall; | ||
|
||
/// Object construction from a JSON representation | ||
factory AssistantMessageFunctionCall.fromJson(Map<String, dynamic> json) => | ||
_$AssistantMessageFunctionCallFromJson(json); | ||
|
||
/// List of all property names of schema | ||
static const List<String> propertyNames = ['arguments', 'name']; | ||
|
||
/// Perform validations on the schema property values | ||
String? validateSchema() { | ||
return null; | ||
} | ||
|
||
/// Map representation of object (not serialized) | ||
Map<String, dynamic> toMap() { | ||
return { | ||
'arguments': arguments, | ||
'name': name, | ||
}; | ||
} | ||
} | ||
|
||
// ========================================== | ||
// ENUM: ToolMessageRole | ||
// ========================================== | ||
|
||
/// The role of the messages author, in this case `tool`. | ||
enum ToolMessageRole { | ||
@JsonValue('tool') | ||
tool, | ||
} | ||
|
||
// ========================================== | ||
// ENUM: FunctionMessageRole | ||
// ========================================== | ||
|
||
/// The role of the messages author, in this case `function`. | ||
enum FunctionMessageRole { | ||
@JsonValue('function') | ||
function, | ||
} |
Oops, something went wrong.