fix: truncate webfetch content to fit context
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 2m18s
C++ / clang-tidy (pull_request) Failing after 2m7s
JS/TS / fmt (pull_request) Failing after 9s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 29s
Rust / build (pull_request) Successful in 50s
Python / verify (pull_request) Successful in 1m38s
Rust / fmt (pull_request) Successful in 26s
Rust / clippy (pull_request) Successful in 47s
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 2m18s
C++ / clang-tidy (pull_request) Failing after 2m7s
JS/TS / fmt (pull_request) Failing after 9s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 29s
Rust / build (pull_request) Successful in 50s
Python / verify (pull_request) Successful in 1m38s
Rust / fmt (pull_request) Successful in 26s
Rust / clippy (pull_request) Successful in 47s
This commit is contained in:
@@ -6,6 +6,20 @@ LlmTool::LlmTool(QObject* parent) : QObject(parent) {}
|
||||
|
||||
LlmTool::~LlmTool() = default;
|
||||
|
||||
void LlmTool::setContextSize(int value) {
|
||||
if (m_contextSize == value) return;
|
||||
m_contextSize = value;
|
||||
}
|
||||
|
||||
int LlmTool::inlineBudgetChars() const {
|
||||
if (m_contextSize <= 0) return DefaultInlineChars;
|
||||
// About a quarter of the context window, clamped so tiny contexts
|
||||
// still get a usable result and huge ones stay sane.
|
||||
const int tokens =
|
||||
qBound(512, m_contextSize / 4, DefaultInlineChars / CharsPerToken);
|
||||
return tokens * CharsPerToken;
|
||||
}
|
||||
|
||||
void LlmTool::cancel() {}
|
||||
|
||||
QJsonObject LlmTool::specification() const {
|
||||
@@ -30,6 +44,7 @@ void ToolRegistry::setEnabled(bool value) {
|
||||
void ToolRegistry::registerTool(LlmTool* tool) {
|
||||
if (!tool || m_tools.contains(tool)) return;
|
||||
tool->setParent(this);
|
||||
tool->setContextSize(m_contextSize);
|
||||
m_tools.append(tool);
|
||||
}
|
||||
|
||||
@@ -52,4 +67,11 @@ void ToolRegistry::cancelAll() {
|
||||
tool->cancel();
|
||||
}
|
||||
|
||||
void ToolRegistry::setContextSize(int value) {
|
||||
if (m_contextSize == value) return;
|
||||
m_contextSize = value;
|
||||
for (auto* tool : m_tools)
|
||||
tool->setContextSize(value);
|
||||
}
|
||||
|
||||
} // namespace ZShell::llm
|
||||
|
||||
Reference in New Issue
Block a user