Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Brave search tool #2737

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f4fb3df
Brave search tool calling.
manyoso Jul 25, 2024
a71db10
Change the name to announce the beta.
manyoso Jul 25, 2024
1c9911a
Fix problem with only displaying one source for tool call excerpts.
manyoso Jul 25, 2024
c78c95a
Add the extra snippets to the source excerpts.
manyoso Jul 25, 2024
dda59a9
Fix the way we're injecting the context back into the model for web s…
manyoso Jul 27, 2024
d2ee235
Change the suggestion mode to turn on for tool calls by default.
manyoso Jul 27, 2024
b0578e2
Change the name to inc the beta.
manyoso Jul 27, 2024
b9684ff
Inc again for new beta.
manyoso Jul 28, 2024
7c7558e
Stop hardcoding the tool call checking and rely upon the format advoc…
manyoso Jul 30, 2024
fffd9f3
Refactor to handle errors in tool calling better and add source comme…
manyoso Jul 30, 2024
dfe3e95
Refactor the brave search and introduce an abstraction for tool calls.
manyoso Jul 31, 2024
01f67c7
Begin converting the localdocs to a tool.
manyoso Aug 1, 2024
27b86da
Serialize the source excerpts from and to pure json
manyoso Aug 1, 2024
5fc2ff8
Use parameters which is in keeping with other standard practices.
manyoso Aug 1, 2024
244b826
Implement error handling for tool calls.
manyoso Aug 7, 2024
cedba6c
Tool model.
manyoso Aug 8, 2024
f93b764
Move the usearch submodule to third_party dir.
manyoso Aug 10, 2024
00ecbb7
Add jinja third party dependency.
manyoso Aug 10, 2024
c3cfaff
Refactor and make use of jinja templates.
manyoso Aug 9, 2024
587dd55
Get rid of the name change now that 3.2.0 has been released.
manyoso Aug 13, 2024
227dbfd
Use an enum for tool usage mode.
manyoso Aug 13, 2024
48117cd
Move the jinja processing to mysettings and validation.
manyoso Aug 13, 2024
a673087
Move to a brave search specific settings page.
manyoso Aug 13, 2024
f118720
Don't advertise brave.
manyoso Aug 14, 2024
75dbf9d
Handle the forced usage of tool calls outside of the recursive prompt…
manyoso Aug 14, 2024
991afc6
Abstract the built-in web search completely away from ChatLLM.
manyoso Aug 14, 2024
4cb9569
Breakout the ask before running which can be thought of as a security…
manyoso Aug 14, 2024
054ca43
Display the antenna by introducing notion of privacy scopes to tools.
manyoso Aug 14, 2024
3a56468
Implement all the settings for the web search.
manyoso Aug 14, 2024
4ae6acd
Force tool usage and refactor.
manyoso Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Breakout the ask before running which can be thought of as a security…
… feature.

Signed-off-by: Adam Treat <[email protected]>
  • Loading branch information
manyoso committed Aug 14, 2024
commit 4cb95694ffd515575268f202872bd16dc0519fef
2 changes: 2 additions & 0 deletions gpt4all-chat/chatllm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand Down
6 changes: 5 additions & 1 deletion gpt4all-chat/tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -74,6 +74,9 @@ class Tool : public QObject {
// [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; }

Expand All @@ -88,6 +91,7 @@ class Tool : public QObject {

Q_SIGNALS:
void usageModeChanged();
void askBeforeRunningChanged();
};

#endif // TOOL_H
4 changes: 4 additions & 0 deletions gpt4all-chat/toolmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ToolModel : public QAbstractListModel
KeyRequiredRole,
IsBuiltinRole,
UsageModeRole,
AskBeforeRole,
ExcerptsRole,
};

Expand Down Expand Up @@ -53,6 +54,8 @@ class ToolModel : public QAbstractListModel
return item->isBuiltin();
case UsageModeRole:
return QVariant::fromValue(item->usageMode());
case AskBeforeRole:
return item->askBeforeRunning();
case ExcerptsRole:
return item->excerpts();
}
Expand All @@ -72,6 +75,7 @@ class ToolModel : public QAbstractListModel
roles[KeyRequiredRole] = "keyRequired";
roles[IsBuiltinRole] = "isBuiltin";
roles[UsageModeRole] = "usageMode";
roles[AskBeforeRole] = "askBeforeRunning";
roles[ExcerptsRole] = "excerpts";
return roles;
}
Expand Down