diff --git a/gpt4all-chat/chatllm.cpp b/gpt4all-chat/chatllm.cpp index d86de0d0..09a89287 100644 --- a/gpt4all-chat/chatllm.cpp +++ b/gpt4all-chat/chatllm.cpp @@ -761,6 +761,7 @@ bool ChatLLM::promptInternal(const QList &collectionList, const QString int32_t n_predict, int32_t top_k, float top_p, float min_p, float temp, int32_t n_batch, float repeat_penalty, int32_t repeat_penalty_tokens) { + // FIXME: Honor the ask before running feature // FIXME: The only localdocs specific thing here should be the injection of the parameters // FIXME: Get the list of tools ... if force usage is set, then we *try* and force usage here. QList localDocsExcerpts; @@ -898,6 +899,7 @@ bool ChatLLM::promptRecursive(const QList &toolContexts, const QString return handleFailedToolCall(trimmed, totalTime); } + // FIXME: Honor the ask before running feature // Inform the chat that we're executing a tool call emit toolCalled(toolInstance->name().toLower()); diff --git a/gpt4all-chat/tool.h b/gpt4all-chat/tool.h index 92a3b758..86f95904 100644 --- a/gpt4all-chat/tool.h +++ b/gpt4all-chat/tool.h @@ -19,7 +19,6 @@ namespace ToolEnums { enum class UsageMode { Disabled, // Completely disabled Enabled, // Enabled and the model decides whether to run - AskBeforeRunning, // Enabled and model decides but the user is queried whether they want the tool to run in every instance ForceUsage, // Attempt to force usage of the tool rather than let the LLM decide. NOTE: Not always possible. }; Q_ENUM_NS(UsageMode) @@ -35,6 +34,7 @@ class Tool : public QObject { Q_PROPERTY(QUrl url READ url CONSTANT) Q_PROPERTY(bool isBuiltin READ isBuiltin CONSTANT) Q_PROPERTY(ToolEnums::UsageMode usageMode READ usageMode NOTIFY usageModeChanged) + Q_PROPERTY(bool askBeforeRunning READ askBeforeRunning NOTIFY askBeforeRunningChanged) Q_PROPERTY(bool excerpts READ excerpts CONSTANT) public: @@ -74,6 +74,9 @@ public: // [Optional] The current usage mode virtual ToolEnums::UsageMode usageMode() const { return ToolEnums::UsageMode::Disabled; } + // [Optional] The user is queried whether they want the tool to run in every instance + virtual bool askBeforeRunning() const { return false; } + // [Optional] Whether json result produces source excerpts. virtual bool excerpts() const { return false; } @@ -88,6 +91,7 @@ public: Q_SIGNALS: void usageModeChanged(); + void askBeforeRunningChanged(); }; #endif // TOOL_H diff --git a/gpt4all-chat/toolmodel.h b/gpt4all-chat/toolmodel.h index f1b59922..315b7360 100644 --- a/gpt4all-chat/toolmodel.h +++ b/gpt4all-chat/toolmodel.h @@ -23,6 +23,7 @@ public: KeyRequiredRole, IsBuiltinRole, UsageModeRole, + AskBeforeRole, ExcerptsRole, }; @@ -53,6 +54,8 @@ public: return item->isBuiltin(); case UsageModeRole: return QVariant::fromValue(item->usageMode()); + case AskBeforeRole: + return item->askBeforeRunning(); case ExcerptsRole: return item->excerpts(); } @@ -72,6 +75,7 @@ public: roles[KeyRequiredRole] = "keyRequired"; roles[IsBuiltinRole] = "isBuiltin"; roles[UsageModeRole] = "usageMode"; + roles[AskBeforeRole] = "askBeforeRunning"; roles[ExcerptsRole] = "excerpts"; return roles; }