Skip to content

Commit

Permalink
Fix Thread Messages containing no content. #97
Browse files Browse the repository at this point in the history
  • Loading branch information
redevrx committed Mar 4, 2024
1 parent 95fab7b commit 8dcfe87
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_android-2.2.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-02-28 08:03:33.229291","version":"3.19.1"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_android-2.2.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/redev.rx/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-03-04 12:19:00.387805","version":"3.19.2"}
2 changes: 1 addition & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v1
with:
flutter-version: '3.16.9'
flutter-version: '3.19.2'

# - name: run analyze
# run: flutter analyze
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.2"
version: "3.0.3"
clock:
dependency: transitive
description:
Expand Down
10 changes: 2 additions & 8 deletions lib/src/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Messages {
);
}

Future<List<CreateMessageResponse>> listMessage({
Future<CreateMessageResponse> listMessage({
required String threadId,
int limit = 20,
String order = 'desc',
Expand All @@ -48,13 +48,7 @@ class Messages {
return _client.get(
url,
headers: _headers,
onSuccess: (it) => it['data'] == null
? []
: List<CreateMessageResponse>.from(
it['data'].map(
(x) => CreateMessageResponse.fromJson(x),
),
),
onSuccess: CreateMessageResponse.fromJson,
onCancel: (cancelData) => null,
);
}
Expand Down
15 changes: 11 additions & 4 deletions lib/src/model/chat_complete/response/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ class Message {
final Map<String, dynamic>? functionCall;
final List<Map<String, dynamic>>? toolCalls;

Message({required this.role, required this.content, this.functionCall, this.toolCalls});
Message({
required this.role,
required this.content,
this.functionCall,
this.toolCalls,
});

factory Message.fromJson(Map<String, dynamic> json) => Message(
role: json["role"] ?? "",
content: json["content"] ?? "",
functionCall: json["function_call"],
toolCalls: json['tool_calls'] == null ? null : List<Map<String, dynamic>>.from(
json["tool_calls"].map((x) => Map<String, dynamic>.from(x)),
),
toolCalls: json['tool_calls'] == null
? null
: List<Map<String, dynamic>>.from(
json["tool_calls"].map((x) => Map<String, dynamic>.from(x)),
),
);

Map<String, dynamic> toJson() => {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://www.facebook.com/REDEVRX
repository: https://github.com/redevRx/Flutter-ChatGPT

environment:
sdk: '>=3.2.6 <4.0.0'
sdk: '>=3.3.0 <4.0.0'

dependencies:
dio: ^5.4.0
Expand Down
1 change: 1 addition & 0 deletions test/model/chat_complete/response/message_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ void main() {
'role': 'sender',
'content': 'Hello, world!',
'function_call': null,
'tool_calls': null,
});
});

Expand Down

0 comments on commit 8dcfe87

Please sign in to comment.