Skip to content

Commit 31792fa

Browse files
committed
[ Edit ] Removed the exposed field for configuring the package to use fetch_client instead of http_client manually withe is isWeb field, in favor of using dart.library.js and dart.library.io conditional imports to automatically detect the platform and use the appropriate client for it.
1 parent 4d4d01e commit 31792fa

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.1.5
4+
5+
- Removed the exposed field for configuring the package to use fetch_client instead of http_client manually withe is `isWeb` field, in favor of using `dart.library.js` and `dart.library.io` conditional imports to automatically detect the platform and use the appropriate client for it.
6+
37
## 4.1.4
48

59
- Exposed field for configuring the package to use fetch_client instead of http_client for making requests in web apps (flutter web, etc..)

README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,23 +162,6 @@ You can change the base url used in the package to your own, this can be helpful
162162
OpenAI.baseUrl = "https://api.openai.com/v1"; // the default one.
163163
```
164164

165-
### Configure the package for web environment (Flutter Web)
166-
167-
because the package uses the [http](https://pub.dev/packages/http) package, the streaming functionality will not work as expected for the Streaming methods, to get over this, you will need to let the package knows that you are using it in a web environment, Flutter as example exposes the `kIsWeb` property that you can use to check if you are in a web environment or not, just assign it to `OpenAI.isWeb`
168-
169-
```dart
170-
// import it from flutter/foundation.dart
171-
import 'package:flutter/foundation.dart' show kIsWeb;
172-
173-
void main() {
174-
// ...
175-
OpenAI.isWeb = kIsWeb;
176-
177-
runApp(MyApp());
178-
}
179-
```
180-
181-
Now, tha package will use the js fetch client for web with [fetch_client](https://pub.dev/packages/fetch_client) package, and the http package for all other IO platforms such as Android, iOS, MacOS, Linux, Windows..
182165

183166
## Models
184167

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dart_openai
22
description: Dart SDK for openAI Apis (GPT-3 & DALL-E), integrate easily the power of OpenAI's state-of-the-art AI models into their Dart applications.
3-
version: 4.1.4
3+
version: 4.1.5
44
homepage: https://github.com/anasfik/openai
55
repository: https://github.com/anasfik/openai
66
documentation: https://github.com/anasfik/openai/blob/main/README.md

0 commit comments

Comments
 (0)