Skip to content

Commit

Permalink
release 3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
redevrx committed Dec 21, 2024
1 parent 4a85ada commit bae4917
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 28 deletions.
1 change: 0 additions & 1 deletion .flutter-plugins-dependencies

This file was deleted.

5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,7 @@
## 3.1.3
- Implement support for streaming responses from OpenAI on web platform
- Merge Code from contributors
- Added json_schema support to ResponseFormat
- Added json_schema support to ResponseFormat

# 3.1.4
- Added support for image data i.e, type (image_file, image_url) in content v2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ supervised and reinforcement learning techniques.

## Install Package
```dart
chat_gpt_sdk: 3.1.3
chat_gpt_sdk: 3.1.4
```

## Create OpenAI Instance
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.1.3"
version: "3.1.4"
clock:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example_app/openai_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ packages:
path: "../.."
relative: true
source: path
version: "3.1.3"
version: "3.1.4"
clock:
dependency: transitive
description:
Expand Down
10 changes: 5 additions & 5 deletions lib/src/model/chat_complete/request/response_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import 'package:chat_gpt_sdk/src/model/chat_complete/request/json_schema.dart';

class ResponseFormat {
final String type;
final JsonSchema? json_schema;
final JsonSchema? jsonSchema;

ResponseFormat({required this.type, this.json_schema});
ResponseFormat({required this.type, this.jsonSchema});

ResponseFormat.jsonSchema({required this.json_schema}) : type = 'json_schema';
ResponseFormat.jsonSchema({required this.jsonSchema}) : type = 'json_schema';

Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['type'] = type;
if (json_schema != null) {
data['json_schema'] = json_schema!.toJson();
if (jsonSchema != null) {
data['json_schema'] = jsonSchema!.toJson();
}

return data;
Expand Down
16 changes: 9 additions & 7 deletions lib/src/model/message/response/content_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ class ContentV2 {
final type = json["type"];
final image = (type == 'image_url' || type == 'image_file')
? json[type] != null
? ImageData.fromJson(json[type]!)
: null
? ImageData.fromJson(json[type]!)
: null
: null;

return ContentV2(
type: type,
text: type == 'text' && json["text"] != null ? TextData.fromJson(json["text"]!) : null,
text: type == 'text' && json["text"] != null
? TextData.fromJson(json["text"]!)
: null,
image: image,
);
}

Map<String, dynamic> toJson() => {
"type": type,
"text": text?.toJson(),
type: image?.toJson(), // Dynamically set 'image_url' or 'image_file'
};
"type": type,
"text": text?.toJson(),
type: image?.toJson(), // Dynamically set 'image_url' or 'image_file'
};
}
16 changes: 8 additions & 8 deletions lib/src/model/message/response/image_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class ImageData {
});

factory ImageData.fromJson(Map<String, dynamic> json) => ImageData(
fileId: json["file_id"] ?? '',
url: json["url"] ?? '',
detail: json["detail"] ?? '',
);
fileId: json["file_id"] ?? '',
url: json["url"] ?? '',
detail: json["detail"] ?? '',
);

Map<String, dynamic> toJson() => {
"file_id": fileId,
"url": url,
"detail": detail,
};
"file_id": fileId,
"url": url,
"detail": detail,
};
}
3 changes: 1 addition & 2 deletions lib/src/openai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class OpenAI implements IOpenAI {

assert(setup.proxy.isEmpty || !setup.streamingWebApi,
'You can\'t provide both proxy and experimental streaming api support currently');
assert(
!setup.streamingWebApi || kIsWeb,
assert(!setup.streamingWebApi || kIsWeb,
'You can\'t run web specific API on other platforms');

if (setup.streamingWebApi) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chat_gpt_sdk
description: create chat bot and other bot with ChatGPT SDK Support GPT-4 , 3.5 and SSE Generate Prompt (Stream)
version: 3.1.3
version: 3.1.4
homepage: https://www.facebook.com/REDEVRX
repository: https://github.com/redevRx/Flutter-ChatGPT

Expand Down

0 comments on commit bae4917

Please sign in to comment.