add markdown parsing + latex + tree-sitter highlighting for codeblocks in llm responses

This commit is contained in:
2026-08-24 23:55:51 +02:00
parent aae3757daf
commit e18875a752
53 changed files with 5043 additions and 618 deletions
+59
View File
@@ -0,0 +1,59 @@
#include "tool.hpp"
namespace ZShell::llm {
LlmTool::LlmTool(QObject* parent) : QObject(parent) {}
LlmTool::~LlmTool() = default;
void LlmTool::cancel() {}
QJsonObject LlmTool::specification() const {
QJsonObject function;
function[QStringLiteral("name")] = name();
function[QStringLiteral("description")] = description();
function[QStringLiteral("parameters")] = parameters();
QJsonObject spec;
spec[QStringLiteral("type")] = QStringLiteral("function");
spec[QStringLiteral("function")] = function;
return spec;
}
ToolRegistry::ToolRegistry(QObject* parent) : QObject(parent) {}
void ToolRegistry::setEnabled(bool value) {
if (m_enabled == value)
return;
m_enabled = value;
Q_EMIT enabledChanged();
}
void ToolRegistry::registerTool(LlmTool* tool) {
if (!tool || m_tools.contains(tool))
return;
tool->setParent(this);
m_tools.append(tool);
}
LlmTool* ToolRegistry::tool(const QString& name) const {
for (const auto* tool : m_tools)
if (tool->name() == name)
return const_cast<LlmTool*>(tool);
return nullptr;
}
QJsonArray ToolRegistry::specifications() const {
if (!m_enabled)
return {};
QJsonArray specs;
for (const auto* tool : m_tools)
specs.append(tool->specification());
return specs;
}
void ToolRegistry::cancelAll() {
for (auto* tool : m_tools)
tool->cancel();
}
} // namespace ZShell::llm