-
Notifications
You must be signed in to change notification settings - Fork 163
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
Showing
15 changed files
with
566 additions
and
1 deletion.
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
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
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,61 @@ | ||
class CreateRun { | ||
///The ID of the | ||
///<a href='https://platform.openai.com/docs/api-reference/assistants'>assistant</a> | ||
/// to use to execute this run. | ||
///[assistantId] | ||
final String assistantId; | ||
|
||
///The ID of the | ||
///<a href='https://platform.openai.com/docs/api-reference/models'>Model</a> | ||
/// to be used to execute this run. | ||
/// If a value is provided here, | ||
/// it will override the model associated with the assistant. | ||
/// If not, the model associated with the assistant will be used. | ||
/// [model] | ||
final String? model; | ||
|
||
///Overrides the | ||
///<a href='https://platform.openai.com/docs/api-reference/assistants/createAssistant'>instructions</a> | ||
/// of the assistant. | ||
/// This is useful for modifying the behavior on a per-run basis. | ||
/// [instructions] | ||
final String? instructions; | ||
|
||
///Appends additional instructions at the end of the instructions | ||
/// for the run. This is useful for modifying the behavior | ||
/// on a per-run basis without overriding other instructions. | ||
/// [additionalInstructions] | ||
final String? additionalInstructions; | ||
|
||
///Override the tools the assistant can use for this run. | ||
/// This is useful for modifying the behavior on a per-run basis. | ||
/// [tools] | ||
final List<Map<String, dynamic>>? tools; | ||
|
||
///Set of 16 key-value pairs that can be attached to an object. | ||
/// This can be useful for storing additional information | ||
/// about the object in a structured format. Keys can be a | ||
/// maximum of 64 characters long and values can be a | ||
/// maxium of 512 characters long. | ||
/// [metadata] | ||
final Map<String, dynamic>? metadata; | ||
|
||
CreateRun({ | ||
required this.assistantId, | ||
this.model, | ||
this.instructions, | ||
this.additionalInstructions, | ||
this.tools, | ||
this.metadata, | ||
}); | ||
|
||
Map<String, dynamic> toJson() => Map.of({ | ||
'assistant_id': assistantId, | ||
'model': model, | ||
'instructions': instructions, | ||
'additional_instructions': additionalInstructions, | ||
'tools': tools, | ||
'metadata': metadata, | ||
}) | ||
..removeWhere((_, value) => value == null); | ||
} |
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,64 @@ | ||
class CreateThreadAndRun { | ||
///The ID of the | ||
///<a href='https://platform.openai.com/docs/api-reference/assistants'>assistant</a> | ||
/// to use to execute this run. | ||
/// [assistantId] | ||
final String assistantId; | ||
|
||
/// | ||
/// [thread] | ||
/// ## Example | ||
/// ```dart | ||
/// { | ||
/// "messages": [ | ||
/// {"role": "user", "content": "Explain deep learning to a 5 year old."} | ||
/// ] | ||
/// } | ||
/// ``` | ||
final Map<String, dynamic>? thread; | ||
|
||
///The ID of the | ||
///<a href='https://platform.openai.com/docs/api-reference/models'>Model</a> | ||
/// to be used to execute this run. | ||
/// If a value is provided here, it will override the | ||
/// model associated with the assistant. | ||
/// If not, the model associated with the assistant will be used. | ||
/// [model] | ||
final String? model; | ||
|
||
///Override the default system message of the assistant. | ||
/// This is useful for modifying the behavior on a per-run basis. | ||
/// [instructions] | ||
final String? instructions; | ||
|
||
///Override the tools the assistant can use for this run. | ||
/// This is useful for modifying the behavior on a per-run basis. | ||
/// [tools] | ||
final List<Map<String, dynamic>>? tools; | ||
|
||
///Set of 16 key-value pairs that can be attached to an object. | ||
/// This can be useful for storing additional information about | ||
/// the object in a structured format. Keys can be a maximum of 64 | ||
/// characters long and values can be a maxium of 512 characters long. | ||
/// [metadata] | ||
final Map<String, dynamic>? metadata; | ||
|
||
CreateThreadAndRun({ | ||
required this.assistantId, | ||
this.thread, | ||
this.model, | ||
this.instructions, | ||
this.tools, | ||
this.metadata, | ||
}); | ||
|
||
Map<String, dynamic> toJson() => Map.of({ | ||
'assistant_id': assistantId, | ||
'thread': thread, | ||
'model': model, | ||
'instructions': instructions, | ||
'tools': tools, | ||
'metadata': metadata, | ||
}) | ||
..removeWhere((_, value) => value == null); | ||
} |
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,102 @@ | ||
import 'package:chat_gpt_sdk/src/model/assistant/response/tool.dart'; | ||
import 'package:chat_gpt_sdk/src/model/run/response/step_detail.dart'; | ||
import 'package:chat_gpt_sdk/src/model/run/response/usage.dart'; | ||
|
||
class CreateRunResponse { | ||
CreateRunResponse({ | ||
required this.metadata, | ||
required this.assistantId, | ||
required this.createdAt, | ||
required this.tools, | ||
required this.completedAt, | ||
required this.threadId, | ||
required this.fileIds, | ||
required this.startedAt, | ||
required this.model, | ||
required this.id, | ||
required this.object, | ||
required this.status, | ||
required this.usage, | ||
required this.instructions, | ||
required this.lastError, | ||
required this.failedAt, | ||
required this.cancelledAt, | ||
required this.expiresAt, | ||
required this.type, | ||
required this.stepDetails, | ||
}); | ||
|
||
Map<String, dynamic> metadata; | ||
String assistantId; | ||
int createdAt; | ||
List<Tool> tools; | ||
int completedAt; | ||
String threadId; | ||
List<String> fileIds; | ||
int startedAt; | ||
String model; | ||
String id; | ||
String object; | ||
String status; | ||
Usage? usage; | ||
String instructions; | ||
Map<String, dynamic> lastError; | ||
int failedAt; | ||
int cancelledAt; | ||
int expiresAt; | ||
String type; | ||
StepDetail? stepDetails; | ||
|
||
factory CreateRunResponse.fromJson(Map<String, dynamic> json) => | ||
CreateRunResponse( | ||
metadata: json["metadata"] ?? {}, | ||
assistantId: json["assistant_id"] ?? '', | ||
createdAt: json["created_at"] ?? 0, | ||
tools: json["tools"] == null | ||
? [] | ||
: List<Tool>.from(json["tools"].map((x) => Tool.fromJson(x))), | ||
completedAt: json["completed_at"] ?? '', | ||
threadId: json["thread_id"] ?? '', | ||
fileIds: json["file_ids"] == null | ||
? [] | ||
: List<String>.from(json["file_ids"].map((x) => x)), | ||
startedAt: json["started_at"] ?? 0, | ||
model: json["model"] ?? '', | ||
id: json["id"] ?? '', | ||
object: json["object"] ?? '', | ||
status: json["status"] ?? '', | ||
usage: json["usage"] == null ? null : Usage.fromJson(json["usage"]), | ||
instructions: json['instructions'] ?? '', | ||
lastError: json['last_error'] ?? {}, | ||
failedAt: json['failed_at'] ?? 0, | ||
cancelledAt: json['cancelled_at'] ?? 0, | ||
expiresAt: json['expires_at'] ?? 0, | ||
type: json['type'] ?? '', | ||
stepDetails: json['step_details'] == null | ||
? null | ||
: StepDetail.fromJson(json['step_details']), | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"metadata": metadata, | ||
"assistant_id": assistantId, | ||
"created_at": createdAt, | ||
"usage": usage?.toJson(), | ||
"tools": tools.map((x) => x.toJson()), | ||
"completed_at": completedAt, | ||
"thread_id": threadId, | ||
"file_ids": fileIds, | ||
"started_at": startedAt, | ||
"model": model, | ||
"id": id, | ||
"object": object, | ||
"status": status, | ||
'instructions': instructions, | ||
'last_error': lastError, | ||
'failed_at': failedAt, | ||
'cancelled_at': cancelledAt, | ||
'expires_at': expiresAt, | ||
'type': type, | ||
'step_details': stepDetails?.toJson(), | ||
}; | ||
} |
64 changes: 64 additions & 0 deletions
64
lib/src/model/run/response/create_thread_and_run_data.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,64 @@ | ||
class CreateThreadAndRunData { | ||
CreateThreadAndRunData({ | ||
required this.instructions, | ||
required this.metadata, | ||
required this.assistantId, | ||
required this.createdAt, | ||
required this.tools, | ||
required this.threadId, | ||
required this.expiresAt, | ||
required this.fileIds, | ||
required this.model, | ||
required this.id, | ||
required this.object, | ||
required this.status, | ||
}); | ||
|
||
String instructions; | ||
Map<String, dynamic> metadata; | ||
String assistantId; | ||
int createdAt; | ||
List<Map<String, dynamic>> tools; | ||
String threadId; | ||
int expiresAt; | ||
List<Map<String, dynamic>> fileIds; | ||
String model; | ||
String id; | ||
String object; | ||
String status; | ||
|
||
factory CreateThreadAndRunData.fromJson(Map<String, dynamic> json) => | ||
CreateThreadAndRunData( | ||
instructions: json["instructions"] ?? '', | ||
metadata: json["metadata"] ?? {}, | ||
assistantId: json["assistant_id"] ?? '', | ||
createdAt: json["created_at"] ?? '', | ||
tools: json["tools"] == null | ||
? [] | ||
: List<Map<String, dynamic>>.from(json["tools"].map((x) => x)), | ||
threadId: json["thread_id"] ?? '', | ||
expiresAt: json["expires_at"] ?? '', | ||
fileIds: json["file_ids"] == null | ||
? [] | ||
: List<Map<String, dynamic>>.from(json["file_ids"].map((x) => x)), | ||
model: json["model"] ?? '', | ||
id: json["id"] ?? '', | ||
object: json["object"] ?? '', | ||
status: json["status"] ?? '', | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"instructions": instructions, | ||
"metadata": metadata, | ||
"assistant_id": assistantId, | ||
"created_at": createdAt, | ||
"tools": tools, | ||
"thread_id": threadId, | ||
"expires_at": expiresAt, | ||
"file_ids": fileIds, | ||
"model": model, | ||
"id": id, | ||
"object": object, | ||
"status": status, | ||
}; | ||
} |
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,37 @@ | ||
import 'package:chat_gpt_sdk/src/model/run/response/create_run_response.dart'; | ||
|
||
class ListRun { | ||
ListRun({ | ||
required this.firstId, | ||
required this.data, | ||
required this.lastId, | ||
required this.hasMore, | ||
required this.object, | ||
}); | ||
|
||
String firstId; | ||
List<CreateRunResponse> data; | ||
String lastId; | ||
bool hasMore; | ||
String object; | ||
|
||
factory ListRun.fromJson(Map<String, dynamic> json) => ListRun( | ||
firstId: json["first_id"], | ||
data: json["data"] == null | ||
? [] | ||
: List<CreateRunResponse>.from( | ||
json["data"].map((x) => CreateRunResponse.fromJson(x)), | ||
), | ||
lastId: json["last_id"], | ||
hasMore: json["has_more"], | ||
object: json["object"], | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"first_id": firstId, | ||
"data": data.map((x) => x.toJson()).toList(), | ||
"last_id": lastId, | ||
"has_more": hasMore, | ||
"object": object, | ||
}; | ||
} |
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,16 @@ | ||
class MessageCreation { | ||
MessageCreation({ | ||
required this.messageId, | ||
}); | ||
|
||
String messageId; | ||
|
||
factory MessageCreation.fromJson(Map<String, dynamic> json) => | ||
MessageCreation( | ||
messageId: json["message_id"] ?? '', | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"message_id": messageId, | ||
}; | ||
} |
Oops, something went wrong.