mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-07 02:53:35 +00:00
Change the behavior of show references setting for localdocs.
Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
parent
e27653219b
commit
94a9943782
@ -184,46 +184,44 @@ void Chat::responseStopped()
|
|||||||
m_tokenSpeed = QString();
|
m_tokenSpeed = QString();
|
||||||
emit tokenSpeedChanged();
|
emit tokenSpeedChanged();
|
||||||
|
|
||||||
if (MySettings::globalInstance()->localDocsShowReferences()) {
|
const QString chatResponse = response();
|
||||||
const QString chatResponse = response();
|
QList<QString> references;
|
||||||
QList<QString> references;
|
QList<QString> referencesContext;
|
||||||
QList<QString> referencesContext;
|
int validReferenceNumber = 1;
|
||||||
int validReferenceNumber = 1;
|
for (const ResultInfo &info : databaseResults()) {
|
||||||
for (const ResultInfo &info : databaseResults()) {
|
if (info.file.isEmpty())
|
||||||
if (info.file.isEmpty())
|
continue;
|
||||||
continue;
|
if (validReferenceNumber == 1)
|
||||||
if (validReferenceNumber == 1)
|
references.append((!chatResponse.endsWith("\n") ? "\n" : QString()) + QStringLiteral("\n---"));
|
||||||
references.append((!chatResponse.endsWith("\n") ? "\n" : QString()) + QStringLiteral("\n---"));
|
QString reference;
|
||||||
QString reference;
|
{
|
||||||
{
|
QTextStream stream(&reference);
|
||||||
QTextStream stream(&reference);
|
stream << (validReferenceNumber++) << ". ";
|
||||||
stream << (validReferenceNumber++) << ". ";
|
if (!info.title.isEmpty())
|
||||||
if (!info.title.isEmpty())
|
stream << "\"" << info.title << "\". ";
|
||||||
stream << "\"" << info.title << "\". ";
|
if (!info.author.isEmpty())
|
||||||
if (!info.author.isEmpty())
|
stream << "By " << info.author << ". ";
|
||||||
stream << "By " << info.author << ". ";
|
if (!info.date.isEmpty())
|
||||||
if (!info.date.isEmpty())
|
stream << "Date: " << info.date << ". ";
|
||||||
stream << "Date: " << info.date << ". ";
|
stream << "In " << info.file << ". ";
|
||||||
stream << "In " << info.file << ". ";
|
if (info.page != -1)
|
||||||
if (info.page != -1)
|
stream << "Page " << info.page << ". ";
|
||||||
stream << "Page " << info.page << ". ";
|
if (info.from != -1) {
|
||||||
if (info.from != -1) {
|
stream << "Lines " << info.from;
|
||||||
stream << "Lines " << info.from;
|
if (info.to != -1)
|
||||||
if (info.to != -1)
|
stream << "-" << info.to;
|
||||||
stream << "-" << info.to;
|
stream << ". ";
|
||||||
stream << ". ";
|
|
||||||
}
|
|
||||||
stream << "[Context](context://" << validReferenceNumber - 1 << ")";
|
|
||||||
}
|
}
|
||||||
references.append(reference);
|
stream << "[Context](context://" << validReferenceNumber - 1 << ")";
|
||||||
referencesContext.append(info.text);
|
|
||||||
}
|
}
|
||||||
|
references.append(reference);
|
||||||
const int index = m_chatModel->count() - 1;
|
referencesContext.append(info.text);
|
||||||
m_chatModel->updateReferences(index, references.join("\n"), referencesContext);
|
|
||||||
emit responseChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int index = m_chatModel->count() - 1;
|
||||||
|
m_chatModel->updateReferences(index, references.join("\n"), referencesContext);
|
||||||
|
emit responseChanged();
|
||||||
|
|
||||||
m_responseInProgress = false;
|
m_responseInProgress = false;
|
||||||
m_responseState = Chat::ResponseStopped;
|
m_responseState = Chat::ResponseStopped;
|
||||||
emit responseInProgressChanged();
|
emit responseInProgressChanged();
|
||||||
|
@ -885,7 +885,7 @@ Rectangle {
|
|||||||
|
|
||||||
delegate: TextArea {
|
delegate: TextArea {
|
||||||
id: myTextArea
|
id: myTextArea
|
||||||
text: value + references
|
text: value + (MySettings.localDocsShowReferences ? references : "")
|
||||||
anchors.horizontalCenter: listView.contentItem.horizontalCenter
|
anchors.horizontalCenter: listView.contentItem.horizontalCenter
|
||||||
width: Math.min(1280, listView.contentItem.width)
|
width: Math.min(1280, listView.contentItem.width)
|
||||||
color: {
|
color: {
|
||||||
|
Loading…
Reference in New Issue
Block a user