Skip to content

Commit

Permalink
fix: empty tools exception (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit authored Jul 24, 2024
1 parent be12da7 commit 40386e7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 267;
CURRENT_PROJECT_VERSION = 268;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down Expand Up @@ -512,7 +512,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 267;
CURRENT_PROJECT_VERSION = 268;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -537,7 +537,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 267;
CURRENT_PROJECT_VERSION = 268;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down
2 changes: 1 addition & 1 deletion lib/data/res/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

class Build {
static const String name = "GPTBox";
static const int build = 267;
static const int build = 268;
}
10 changes: 7 additions & 3 deletions lib/view/page/home/req.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ Future<void> _onCreateText(
_loadingChatIds.add(chatId);
_autoScroll(chatId);

final useTools = OpenAICfg.canUseToolNow;
final useTools = Stores.tool.enabled.fetch() && OpenAICfg.canUseToolNow;

// #104
final singleChatScopeUseTools = workingChat.settings?.useTools != false;

// #111
final availableTools = OpenAIFuncCalls.tools;
final isToolsEmpty = availableTools.isEmpty;

/// TODO: after switching to http img url, remove this condition.
/// To save tokens, we don't use tools for image prompt
if (useTools && !hasImg && singleChatScopeUseTools) {
if (useTools && !hasImg && singleChatScopeUseTools && !isToolsEmpty) {
final toolReply = ChatHistoryItem.single(role: ChatRole.tool, raw: '');
workingChat.items.add(toolReply);
_loadingChatIds.add(toolReply.id);
Expand All @@ -160,7 +164,7 @@ Future<void> _onCreateText(
).toOpenAI,
...msgs,
],
tools: OpenAIFuncCalls.tools,
tools: availableTools,
);
} catch (e, s) {
_onErr(e, s, chatId, 'Tool');
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: gpt_box
description: "A third-party GPT Client for OpenAI API."
publish_to: 'none'
version: 1.0.267+267
version: 1.0.268+268

environment:
sdk: '>=3.3.0 <4.0.0'
Expand Down

0 comments on commit 40386e7

Please sign in to comment.