Add txt and markdown files to attach feature. (#3135)

Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: AT <manyoso@users.noreply.github.com>
Co-authored-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
AT
2024-10-28 11:42:46 -04:00
committed by GitHub
parent da00527101
commit b19db6c20d
7 changed files with 69 additions and 70 deletions

View File

@@ -132,7 +132,13 @@ void Chat::newPromptResponsePair(const QString &prompt, const QList<QUrl> &attac
Q_ASSERT(url.isLocalFile());
const QString localFilePath = url.toLocalFile();
const QFileInfo info(localFilePath);
Q_ASSERT(info.suffix() == "xlsx"); // We only support excel right now
Q_ASSERT(
info.suffix().toLower() == "xlsx" ||
info.suffix().toLower() == "txt" ||
info.suffix().toLower() == "md" ||
info.suffix().toLower() == "rst"
);
PromptAttachment attached;
attached.url = url;

View File

@@ -40,6 +40,11 @@ public:
QString processedContent() const
{
const QString localFilePath = url.toLocalFile();
const QFileInfo info(localFilePath);
if (info.suffix().toLower() != "xlsx")
return u"## Attached: %1\n\n%2"_s.arg(file(), content);
QBuffer buffer;
buffer.setData(content);
buffer.open(QIODevice::ReadOnly);