Skip to content

Commit ad8d291

Browse files
committed
build for 1.0.5
1 parent f16c0d7 commit ad8d291

File tree

9 files changed

+30
-4
lines changed

9 files changed

+30
-4
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ A new Flutter project which communicates with [OpenAI API](https://platform.open
1515
- Support [system message](https://platform.openai.com/docs/guides/chat/introduction)
1616
- Support [streaming message](https://platform.openai.com/docs/api-reference/chat/create#chat/create-stream) like ChatGPT
1717
- Support to choose GPT models (gpt-3.5-turbo, gpt-4, gpt-4-32k)
18+
- Support to limit the count of conversation history when sending
19+
- Support to show token usage in real time
1820

1921
## How to use
2022

2123
1. Get [OpenAI API Key](https://platform.openai.com/docs/api-reference/authentication)
2224
2. Tap setting button on top right corner to set API Key (required) and Organization (optional)
2325
3. Add a new conversation
24-
4. Chat with Open AI
26+
4. Chat with OpenAI
2527

2628
## Architecture
2729

@@ -41,14 +43,17 @@ Build apk:
4143
flutter build apk
4244
```
4345

46+
NOTE: It may take quite long time to finish build. On my MacBook Pro, it takes about 1 hour to finish.
47+
4448
## References
4549

4650
Mainly used Flutter packages:
4751

4852
- [shared_preferences](https://pub.dev/packages/shared_preferences) to store app settings & conversations
4953
- [flutter_bloc](https://pub.dev/packages/flutter_bloc) for state management
50-
- [settings_ui](https://pub.dev/packages/settings_ui) for setting page
54+
- [settings_ui](https://pub.dev/packages/settings_ui) for setting screen
5155
- [flutter_markdown](https://pub.dev/packages/flutter_markdown) to render messages in markdown format
56+
- Unofficial [tiktoken](https://pub.dev/packages/tiktoken) to calculate token usage
5257

5358
## License
5459

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.2.0'
9+
classpath 'com.android.tools.build:gradle:7.4.2'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

document/readme_screenshot_01.png

-575 Bytes
Loading

document/readme_screenshot_02.png

25.7 KB
Loading

document/readme_screenshot_03.png

-561 Bytes
Loading

document/readme_screenshot_04.png

-79.6 KB
Loading

lib/main.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'dart:async';
22
import 'dart:developer';
3+
import 'dart:isolate';
34

45
import 'package:flutter/material.dart';
6+
import 'package:flutter/services.dart';
57
import 'package:flutter_bloc/flutter_bloc.dart';
68
import 'package:http/http.dart' as http;
79

@@ -10,6 +12,7 @@ import 'bloc/blocs.dart';
1012
import 'screens/conversation_screen.dart';
1113
import 'services/chat_service.dart';
1214
import 'services/local_storage_service.dart';
15+
import 'services/token_service.dart';
1316
import 'util/extend_http_client.dart';
1417

1518
void main() async {
@@ -19,6 +22,18 @@ void main() async {
1922
final openAiApi = OpenAiApi(SafeHttpClient(http.Client()));
2023
final chatService = ChatService(apiServer: openAiApi);
2124

25+
// init token service in background
26+
// TODO: this doesn't help to decrease the loading time in chat screen
27+
RootIsolateToken rootIsolateToken = RootIsolateToken.instance!;
28+
Isolate.spawn(
29+
(RootIsolateToken token) async {
30+
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
31+
await LocalStorageService().init();
32+
TokenService.getToken('a');
33+
},
34+
rootIsolateToken,
35+
);
36+
2237
runZonedGuarded(
2338
() => runApp(App(chatService: chatService)),
2439
(error, stackTrace) => log(error.toString(), stackTrace: stackTrace),

macos/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ PODS:
33
- shared_preferences_foundation (0.0.1):
44
- Flutter
55
- FlutterMacOS
6+
- url_launcher_macos (0.0.1):
7+
- FlutterMacOS
68

79
DEPENDENCIES:
810
- FlutterMacOS (from `Flutter/ephemeral`)
911
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`)
12+
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
1013

1114
EXTERNAL SOURCES:
1215
FlutterMacOS:
1316
:path: Flutter/ephemeral
1417
shared_preferences_foundation:
1518
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos
19+
url_launcher_macos:
20+
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
1621

1722
SPEC CHECKSUMS:
1823
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
1924
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
25+
url_launcher_macos: 5335912b679c073563f29d89d33d10d459f95451
2026

2127
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
2228

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
19-
version: 1.0.4+1
19+
version: 1.0.5+1
2020

2121
environment:
2222
sdk: '>=2.19.3 <3.0.0'

0 commit comments

Comments
 (0)