mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-13 21:56:00 +00:00
Breakout the ask before running which can be thought of as a security feature.
Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
parent
991afc6ef2
commit
4cb95694ff
@ -761,6 +761,7 @@ bool ChatLLM::promptInternal(const QList<QString> &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<SourceExcerpt> localDocsExcerpts;
|
||||
@ -898,6 +899,7 @@ bool ChatLLM::promptRecursive(const QList<QString> &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());
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user