chore: restructure llm plugin to be more coherent & fix various bugs in llm ui
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Python / verify (pull_request) Successful in 1m35s
Rust / fmt (pull_request) Successful in 36s
Rust / clippy (pull_request) Successful in 54s
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Python / verify (pull_request) Successful in 1m35s
Rust / fmt (pull_request) Successful in 36s
Rust / clippy (pull_request) Successful in 54s
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
#include "prompts.hpp"
|
||||
|
||||
namespace ZShell::llm::prompts {
|
||||
|
||||
QString sandboxPreamble(const QString& workspace, const QStringList& files) {
|
||||
return QStringLiteral(
|
||||
"The user attached the following files to this "
|
||||
"conversation. They are available in your sandbox "
|
||||
"directory at %1:\n%2\nruncommand executes shell "
|
||||
"commands inside a bubblewrap sandbox: the rest of the "
|
||||
"filesystem is read-only, there is no network access, "
|
||||
"and only the sandbox directory is writable. Use it to "
|
||||
"inspect, transform, or extract attached files (for "
|
||||
"example to extract archives or search across many "
|
||||
"files). Files you create stay inside the sandbox "
|
||||
"directory. Use the webfetch tool for anything that "
|
||||
"needs the network.")
|
||||
.arg(workspace, files.join(QStringLiteral("\n")));
|
||||
}
|
||||
|
||||
QString titleSystemPrompt() {
|
||||
return QStringLiteral(
|
||||
"Write a short, concise title for a chat conversation starting "
|
||||
"with the user's message below. At most six words, no quotation "
|
||||
"marks, no trailing punctuation. Reply with the title only.");
|
||||
}
|
||||
|
||||
QString iconSystemPrompt() {
|
||||
return QStringLiteral(
|
||||
"Pick the single icon name from this list that best matches the "
|
||||
"topic of the user's message below: %1. Reply with only the "
|
||||
"icon "
|
||||
"name, exactly as written in the list, and nothing else.")
|
||||
.arg(iconNames().join(QStringLiteral(", ")));
|
||||
}
|
||||
|
||||
QStringList iconNames() {
|
||||
return {
|
||||
"chat", "lightbulb", "code", "description",
|
||||
"article", "school", "work", "build",
|
||||
"science", "palette", "music_note", "sports_esports",
|
||||
"takeout_dining", "flight", "photo_camera", "psychology_alt",
|
||||
"favorite", "savings", "gamepad", "auto_awesome",
|
||||
};
|
||||
}
|
||||
|
||||
QString cleanTitle(const QString& raw) {
|
||||
static const auto isQuote = [](QChar c) {
|
||||
return c == QLatin1Char('"') || c == QLatin1Char('\'') ||
|
||||
c == QChar(u'\u201C') || c == QChar(u'\u201D') ||
|
||||
c == QChar(u'\u2018') || c == QChar(u'\u2019');
|
||||
};
|
||||
|
||||
QString title = raw;
|
||||
while (title.size() >= 2 && isQuote(title.at(0)) &&
|
||||
isQuote(title.at(title.size() - 1)))
|
||||
title = title.mid(1, title.size() - 2).simplified();
|
||||
while (!title.isEmpty() && (title.endsWith(QLatin1Char('.')) ||
|
||||
title.endsWith(QLatin1Char('!')) ||
|
||||
title.endsWith(QLatin1Char('?'))))
|
||||
title.chop(1);
|
||||
|
||||
if (title.size() > MaxTitleLength)
|
||||
title = title.left(MaxTitleLength - 1) + QStringLiteral("…");
|
||||
return title;
|
||||
}
|
||||
|
||||
} // namespace ZShell::llm::prompts
|
||||
Reference in New Issue
Block a user