Skip to content

Commit 9680502

Browse files
authored
Merge pull request #42 from mylxsw/develop
v1.0.5
2 parents b5831a7 + c9e7ddd commit 9680502

40 files changed

+726
-460
lines changed

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ build-android:
1616
build-macos:
1717
flutter build macos --no-tree-shake-icons --release
1818
codesign -f -s "Developer ID Application: YIYAO GUAN (N95437SZ2A)" build/macos/Build/Products/Release/AIdea.app
19-
productbuild --component AIdea.app /Applications --sign "Developer ID Installer: YIYAO GUAN (N95437SZ2A)" --product AIdea.app/Contents/Info.plist AIdea.pkg
2019
open build/macos/Build/Products/Release/
2120

2221
build-web:
23-
flutter build web --web-renderer canvaskit --release --pwa-strategy none --dart2js-optimization O4 --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://resources.aicode.cc/canvaskit/
22+
flutter build web --web-renderer canvaskit --release --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://resources.aicode.cc/canvaskit/
2423
cd scripts && go run main.go ../build/web/main.dart.js && cd ..
2524
rm -fr build/web/fonts/ && mkdir build/web/fonts
2625
cp -r scripts/s build/web/fonts/s

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
一款集成了主流大语言模型以及绘图模型的 APP, 采用 Flutter 开发,代码完全开源,支持以下功能:
99

10-
- 支持 GPT-3.5/4 问答聊天
11-
- 支持国产模型:通义千问,文心一言、讯飞星火、商汤日日新
12-
- 支持开源模型:Llama2 ,ChatGLM2 ,AquilaChat 7B ,Bloomz 7B 等,后续还将开放更多
10+
- 支持 OpenAI 的 GPT-3.5,GPT-4 大语言模型
11+
- 支持 Anthropic 的 Claude instant,Claude 2.0 大语言模型
12+
- 支持国产模型:通义千问,文心一言,讯飞星火,商汤日日新,腾讯混元大语言模型
13+
- 支持开源大模型:Llama2,ChatGLM2,AquilaChat 7B,Bloomz 7B 等,后续还将开放更多
1314
- 支持文生图、图生图、超分辨率、黑白图片上色等功能,集成 Stable Diffusion 模型,支持 SDXL 1.0
1415

1516
开源代码:

ios/Podfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ SPEC CHECKSUMS:
196196
in_app_purchase_storekit: 4fb7ee9e824b1f09107fbfbbce8c4b276366dc43
197197
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
198198
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
199-
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
199+
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
200200
record: cae05d8dd3cdb1dea3511b20e5a5811a1ae00d0d
201201
SDWebImage: fd7e1a22f00303e058058278639bf6196ee431fe
202202
SDWebImageWebPCoder: 295a6573c512f54ad2dd58098e64e17dcf008499
203203
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
204-
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
204+
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
205205
sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
206206
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
207207
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
@@ -211,4 +211,4 @@ SPEC CHECKSUMS:
211211

212212
PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048
213213

214-
COCOAPODS: 1.11.3
214+
COCOAPODS: 1.12.1

ios/Runner.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
97C146E61CF9000F007C117D /* Project object */ = {
163163
isa = PBXProject;
164164
attributes = {
165-
LastUpgradeCheck = 1300;
165+
LastUpgradeCheck = 1430;
166166
ORGANIZATIONNAME = "";
167167
TargetAttributes = {
168168
97C146ED1CF9000F007C117D = {

ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1430"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

lib/helper/ability.dart

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import 'package:askaide/helper/constant.dart';
2+
import 'package:askaide/helper/platform.dart';
3+
import 'package:askaide/repo/api/info.dart';
24
import 'package:askaide/repo/settings_repo.dart';
35

46
class Ability {
57
late final SettingRepository setting;
8+
late final Capabilities capabilities;
69

7-
init(SettingRepository setting) {
10+
init(SettingRepository setting, Capabilities capabilities) {
811
this.setting = setting;
12+
this.capabilities = capabilities;
913
}
1014

1115
/// 单例
@@ -16,6 +20,39 @@ class Ability {
1620
return _instance;
1721
}
1822

23+
/// 首页支持的模型列表
24+
List<HomeModel> get homeModels {
25+
return capabilities.homeModels;
26+
}
27+
28+
/// 是否支持 OpenAI
29+
bool get enableOpenAI {
30+
return capabilities.openaiEnabled;
31+
}
32+
33+
/// 是否支持支付宝
34+
bool get enableAlipay {
35+
return capabilities.alipayEnabled;
36+
}
37+
38+
/// 是否支持 ApplePay
39+
bool get enableApplePay {
40+
return capabilities.applePayEnabled;
41+
}
42+
43+
/// 是否支持支付功能
44+
bool get enablePayment {
45+
if (!enableApplePay && !enableAlipay) {
46+
return false;
47+
}
48+
49+
if (PlatformTool.isIOS() && enableApplePay) {
50+
return true;
51+
}
52+
53+
return enableAlipay;
54+
}
55+
1956
/// 是否支持API Server
2057
bool supportAPIServer() {
2158
return setting.stringDefault(settingAPIServerToken, '') != '';

lib/helper/constant.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import 'package:flutter/material.dart';
22

33
// 客户端应用版本号
4-
const VERSION = '1.0.4';
4+
const clientVersion = '1.0.5';
55
// 本地数据库版本号
6-
const DB_VERSION = 23;
6+
const databaseVersion = 23;
77

88
const maxRoomNumForNonVIP = 50;
99
const coinSign = '个';
1010

1111
// API 服务器地址
1212
const apiServerURL = 'https://ai-api.aicode.cc';
13+
// const apiServerURL = 'http://localhost';
14+
1315
const settingAPIServerToken = 'api-token';
1416
const settingUserInfo = 'user-info';
1517
const settingUsingGuestMode = 'using-guest-mode';

lib/helper/error.dart

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:askaide/lang/lang.dart';
33
import 'package:dart_openai/openai.dart';
44

55
Object resolveErrorMessage(dynamic e) {
6+
// TODO
67
if (e is RequestFailedException) {
78
final msg = resolveHTTPStatusCode(e.statusCode);
89
if (msg != null) {

lib/helper/model_resolver.dart

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import 'dart:convert';
12
import 'dart:io';
23

34
import 'package:askaide/helper/constant.dart';
45
import 'package:askaide/helper/error.dart';
56
import 'package:askaide/helper/helper.dart';
6-
import 'package:askaide/helper/model.dart';
77
import 'package:askaide/repo/api_server.dart';
88
import 'package:askaide/repo/deepai_repo.dart';
99
import 'package:askaide/repo/model/message.dart';
@@ -166,24 +166,24 @@ class ModelResolver {
166166
}
167167

168168
// 聊天模型
169-
if ((await ModelAggregate.model(room.model)).isChatModel) {
170-
var chatContext = _buildRobotRequestContext(room, contextMessages);
171-
return await openAIRepo.chatStream(
172-
chatContext,
173-
onMessage,
174-
model: room.modelName(),
175-
maxTokens: maxTokens,
176-
roomId: room.isLocalRoom ? null : room.id,
177-
);
178-
}
179-
180-
// 非聊天模型
181-
return await openAIRepo.completionStream(
182-
room.modelName(),
183-
message.text,
184-
maxTokens: maxTokens,
169+
// if ((await ModelAggregate.model(room.model)).isChatModel) {
170+
var chatContext = _buildRobotRequestContext(room, contextMessages);
171+
return await openAIRepo.chatStream(
172+
chatContext,
185173
onMessage,
174+
model: room.modelName(),
175+
maxTokens: maxTokens,
176+
roomId: room.isLocalRoom ? null : room.id,
186177
);
178+
// }
179+
180+
// // 非聊天模型
181+
// return await openAIRepo.completionStream(
182+
// room.modelName(),
183+
// message.text,
184+
// maxTokens: maxTokens,
185+
// onMessage,
186+
// );
187187
}
188188

189189
/// 构建机器人请求上下文
@@ -205,7 +205,7 @@ class ModelResolver {
205205

206206
var contextMessages = recentMessages
207207
.where((e) => !e.isSystem() && !e.isInitMessage())
208-
.map((e) => e.user == 'robot'
208+
.map((e) => e.role == Role.receiver
209209
? OpenAIChatCompletionChoiceMessageModel(
210210
role: OpenAIChatMessageRole.assistant, content: e.text)
211211
: OpenAIChatCompletionChoiceMessageModel(

lib/lang/lang.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ mixin AppLocale {
9393

9494
static const String nameRequiredMessage = 'name-required-message';
9595
static const String promptFormatError = 'prompt-format-error';
96+
static const String modelRequiredMessage = 'model-required-message';
9697

9798
static const String writeYourIdeas = 'write-your-ideas';
9899
static const String describeYourImages = 'describe-your-images';
@@ -274,6 +275,7 @@ mixin AppLocale {
274275
promptUsage: '领域设定用于设置 AI 数字人的行为',
275276
nameRequiredMessage: '请输入数字人名称',
276277
promptFormatError: '角色设定不能超过1000字',
278+
modelRequiredMessage: '请选择 AI 模型',
277279
operateSuccess: '操作成功',
278280
operateFailed: '操作失败',
279281
confirmDelete: '确定要删除这些项目?',
@@ -345,14 +347,14 @@ mixin AppLocale {
345347
signInWithApple: '使用 Apple 账号登录',
346348
readAndAgree: '已阅读并同意',
347349
andWord: '和',
348-
accountInputTips: '输入您的手机号',
350+
accountInputTips: '输入您的手机或邮箱账号',
349351
phoneInputTips: '输入您的手机号',
350352
passwordInputTips: '输入您的密码',
351353
pleaseReadAgreeProtocol: '请先阅读并同意用户协议和隐私条款',
352354
signInSuccess: '登录成功',
353355
signInFailed: '登录失败',
354356
accountRequired: '请输入账号',
355-
accountFormatError: '账号格式有误\n请输入手机号',
357+
accountFormatError: '账号格式有误\n请输入手机号或邮箱账号',
356358
phoneNumberFormatError: '手机号码格式有误',
357359
passwordRequired: '请输入密码',
358360
passwordFormatError: '密码格式有误\n必须为8-20位字母、数字、特殊符号组合',
@@ -361,7 +363,7 @@ mixin AppLocale {
361363
verifyCode: '验证码',
362364
verifyCodeInputTips: '输入验证码',
363365
retryInSeconds: '秒后重试',
364-
verifyCodeSendSuccess: '验证码已发送至您的',
366+
verifyCodeSendSuccess: '验证码已发送',
365367
pleaseGetVerifyCodeFirst: '请先获取验证码',
366368
verifyCodeRequired: '请输入验证码',
367369
verifyCodeFormatError: '验证码格式有误',
@@ -463,6 +465,7 @@ mixin AppLocale {
463465
promptUsage: 'Prompt is used to set the behavior of the AI character',
464466
nameRequiredMessage: 'Please enter the name of the character',
465467
promptFormatError: 'Prompt cannot exceed 1000 words',
468+
modelRequiredMessage: 'Please select AI model',
466469
operateSuccess: 'Success',
467470
operateFailed: 'Failed',
468471
confirmDelete: 'Confirm to delete?',
@@ -541,15 +544,16 @@ mixin AppLocale {
541544
signInWithApple: 'Sign in with Apple',
542545
readAndAgree: 'Read and agree',
543546
andWord: 'and',
544-
accountInputTips: 'Enter your phone number',
547+
accountInputTips: 'Enter your phone number or email',
545548
phoneInputTips: 'Enter your phone number',
546549
passwordInputTips: 'Enter your password',
547550
pleaseReadAgreeProtocol:
548551
'Please read and agree to the user agreement and privacy policy first',
549552
signInSuccess: 'Sign in success',
550553
signInFailed: 'Sign in failed',
551554
accountRequired: 'Please enter your account',
552-
accountFormatError: 'Account format error\nPlease enter your phone number',
555+
accountFormatError:
556+
'Account format error\nPlease enter your phone number or email',
553557
phoneNumberFormatError: 'Phone number format error',
554558
passwordRequired: 'Please enter your password',
555559
passwordFormatError:
@@ -559,7 +563,7 @@ mixin AppLocale {
559563
verifyCode: 'Verify code',
560564
verifyCodeInputTips: 'Enter verify code',
561565
retryInSeconds: 'Retry in',
562-
verifyCodeSendSuccess: 'Verify code has been sent to your',
566+
verifyCodeSendSuccess: 'Verify code has been sent',
563567
pleaseGetVerifyCodeFirst: 'Please get the verification code first',
564568
verifyCodeRequired: 'Please enter the verification code',
565569
verifyCodeFormatError: 'Verification code format error',

0 commit comments

Comments
 (0)