mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-22 13:41:08 +00:00
Fix typo and add new show references setting to localdocs.
This commit is contained in:
parent
8dcf68dbf4
commit
eab92a9d73
@ -189,6 +189,7 @@ 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;
|
||||||
@ -226,6 +227,7 @@ void Chat::responseStopped()
|
|||||||
const int index = m_chatModel->count() - 1;
|
const int index = m_chatModel->count() - 1;
|
||||||
m_chatModel->updateReferences(index, references.join("\n"), referencesContext);
|
m_chatModel->updateReferences(index, references.join("\n"), referencesContext);
|
||||||
emit responseChanged();
|
emit responseChanged();
|
||||||
|
}
|
||||||
|
|
||||||
m_responseInProgress = false;
|
m_responseInProgress = false;
|
||||||
m_responseState = Chat::ResponseStopped;
|
m_responseState = Chat::ResponseStopped;
|
||||||
|
@ -164,7 +164,7 @@
|
|||||||
"parameters": "13 billion",
|
"parameters": "13 billion",
|
||||||
"quant": "q4_2",
|
"quant": "q4_2",
|
||||||
"type": "LLaMA",
|
"type": "LLaMA",
|
||||||
"description": "<strong>Trained with RHLF by Stability AI</strong><br><ul><li>Instruction based<li>Cannot be used commercially</ul>",
|
"description": "<strong>Trained with RLHF by Stability AI</strong><br><ul><li>Instruction based<li>Cannot be used commercially</ul>",
|
||||||
"systemPrompt": "## Assistant: I am StableVicuna, a large language model created by CarperAI. I am here to chat!\n\n"
|
"systemPrompt": "## Assistant: I am StableVicuna, a large language model created by CarperAI. I am here to chat!\n\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ static bool default_forceMetal = false;
|
|||||||
static QString default_lastVersionStarted = "";
|
static QString default_lastVersionStarted = "";
|
||||||
static int default_localDocsChunkSize = 256;
|
static int default_localDocsChunkSize = 256;
|
||||||
static int default_localDocsRetrievalSize = 3;
|
static int default_localDocsRetrievalSize = 3;
|
||||||
|
static bool default_localDocsShowReferences = true;
|
||||||
static QString default_networkAttribution = "";
|
static QString default_networkAttribution = "";
|
||||||
static bool default_networkIsActive = false;
|
static bool default_networkIsActive = false;
|
||||||
static bool default_networkUsageStatsActive = false;
|
static bool default_networkUsageStatsActive = false;
|
||||||
@ -89,6 +90,7 @@ void MySettings::restoreLocalDocsDefaults()
|
|||||||
{
|
{
|
||||||
setLocalDocsChunkSize(default_localDocsChunkSize);
|
setLocalDocsChunkSize(default_localDocsChunkSize);
|
||||||
setLocalDocsRetrievalSize(default_localDocsRetrievalSize);
|
setLocalDocsRetrievalSize(default_localDocsRetrievalSize);
|
||||||
|
setLocalDocsShowReferences(default_localDocsShowReferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MySettings::eraseModel(const ModelInfo &m)
|
void MySettings::eraseModel(const ModelInfo &m)
|
||||||
@ -520,6 +522,24 @@ void MySettings::setLocalDocsRetrievalSize(int s)
|
|||||||
emit localDocsRetrievalSizeChanged();
|
emit localDocsRetrievalSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MySettings::localDocsShowReferences() const
|
||||||
|
{
|
||||||
|
QSettings setting;
|
||||||
|
setting.sync();
|
||||||
|
return setting.value("localdocs/showReferences", default_localDocsShowReferences).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySettings::setLocalDocsShowReferences(bool b)
|
||||||
|
{
|
||||||
|
if (localDocsShowReferences() == b)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QSettings setting;
|
||||||
|
setting.setValue("localdocs/showReferences", b);
|
||||||
|
setting.sync();
|
||||||
|
emit localDocsShowReferencesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
QString MySettings::networkAttribution() const
|
QString MySettings::networkAttribution() const
|
||||||
{
|
{
|
||||||
QSettings setting;
|
QSettings setting;
|
||||||
|
@ -19,6 +19,7 @@ class MySettings : public QObject
|
|||||||
Q_PROPERTY(QString lastVersionStarted READ lastVersionStarted WRITE setLastVersionStarted NOTIFY lastVersionStartedChanged)
|
Q_PROPERTY(QString lastVersionStarted READ lastVersionStarted WRITE setLastVersionStarted NOTIFY lastVersionStartedChanged)
|
||||||
Q_PROPERTY(int localDocsChunkSize READ localDocsChunkSize WRITE setLocalDocsChunkSize NOTIFY localDocsChunkSizeChanged)
|
Q_PROPERTY(int localDocsChunkSize READ localDocsChunkSize WRITE setLocalDocsChunkSize NOTIFY localDocsChunkSizeChanged)
|
||||||
Q_PROPERTY(int localDocsRetrievalSize READ localDocsRetrievalSize WRITE setLocalDocsRetrievalSize NOTIFY localDocsRetrievalSizeChanged)
|
Q_PROPERTY(int localDocsRetrievalSize READ localDocsRetrievalSize WRITE setLocalDocsRetrievalSize NOTIFY localDocsRetrievalSizeChanged)
|
||||||
|
Q_PROPERTY(bool localDocsShowReferences READ localDocsShowReferences WRITE setLocalDocsShowReferences NOTIFY localDocsShowReferencesChanged)
|
||||||
Q_PROPERTY(QString networkAttribution READ networkAttribution WRITE setNetworkAttribution NOTIFY networkAttributionChanged)
|
Q_PROPERTY(QString networkAttribution READ networkAttribution WRITE setNetworkAttribution NOTIFY networkAttributionChanged)
|
||||||
Q_PROPERTY(bool networkIsActive READ networkIsActive WRITE setNetworkIsActive NOTIFY networkIsActiveChanged)
|
Q_PROPERTY(bool networkIsActive READ networkIsActive WRITE setNetworkIsActive NOTIFY networkIsActiveChanged)
|
||||||
Q_PROPERTY(bool networkUsageStatsActive READ networkUsageStatsActive WRITE setNetworkUsageStatsActive NOTIFY networkUsageStatsActiveChanged)
|
Q_PROPERTY(bool networkUsageStatsActive READ networkUsageStatsActive WRITE setNetworkUsageStatsActive NOTIFY networkUsageStatsActiveChanged)
|
||||||
@ -81,6 +82,8 @@ public:
|
|||||||
void setLocalDocsChunkSize(int s);
|
void setLocalDocsChunkSize(int s);
|
||||||
int localDocsRetrievalSize() const;
|
int localDocsRetrievalSize() const;
|
||||||
void setLocalDocsRetrievalSize(int s);
|
void setLocalDocsRetrievalSize(int s);
|
||||||
|
bool localDocsShowReferences() const;
|
||||||
|
void setLocalDocsShowReferences(bool b);
|
||||||
|
|
||||||
// Network settings
|
// Network settings
|
||||||
QString networkAttribution() const;
|
QString networkAttribution() const;
|
||||||
@ -112,6 +115,7 @@ Q_SIGNALS:
|
|||||||
void lastVersionStartedChanged();
|
void lastVersionStartedChanged();
|
||||||
void localDocsChunkSizeChanged();
|
void localDocsChunkSizeChanged();
|
||||||
void localDocsRetrievalSizeChanged();
|
void localDocsRetrievalSizeChanged();
|
||||||
|
void localDocsShowReferencesChanged();
|
||||||
void networkAttributionChanged();
|
void networkAttributionChanged();
|
||||||
void networkIsActiveChanged();
|
void networkIsActiveChanged();
|
||||||
void networkUsageStatsActiveChanged();
|
void networkUsageStatsActiveChanged();
|
||||||
|
@ -170,6 +170,23 @@ MySettingsTab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Label {
|
||||||
|
id: showReferencesLabel
|
||||||
|
text: qsTr("Show references:")
|
||||||
|
color: theme.textColor
|
||||||
|
}
|
||||||
|
MyCheckBox {
|
||||||
|
id: showReferencesBox
|
||||||
|
checked: MySettings.localDocsShowReferences
|
||||||
|
onClicked: {
|
||||||
|
MySettings.localDocsShowReferences = !MySettings.localDocsShowReferences
|
||||||
|
}
|
||||||
|
ToolTip.text: qsTr("Shows any references in GUI generated by localdocs")
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 1
|
height: 1
|
||||||
|
@ -351,10 +351,12 @@ QHttpServerResponse Server::handleCompletionRequest(const QHttpServerRequest &re
|
|||||||
message.insert("role", "assistant");
|
message.insert("role", "assistant");
|
||||||
message.insert("content", result);
|
message.insert("content", result);
|
||||||
choice.insert("message", message);
|
choice.insert("message", message);
|
||||||
|
if (MySettings::globalInstance()->localDocsShowReferences()) {
|
||||||
QJsonArray references;
|
QJsonArray references;
|
||||||
for (const auto &ref : infos)
|
for (const auto &ref : infos)
|
||||||
references.append(resultToJson(ref));
|
references.append(resultToJson(ref));
|
||||||
choice.insert("references", references);
|
choice.insert("references", references);
|
||||||
|
}
|
||||||
choices.append(choice);
|
choices.append(choice);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -367,10 +369,12 @@ QHttpServerResponse Server::handleCompletionRequest(const QHttpServerRequest &re
|
|||||||
choice.insert("index", index++);
|
choice.insert("index", index++);
|
||||||
choice.insert("logprobs", QJsonValue::Null); // We don't support
|
choice.insert("logprobs", QJsonValue::Null); // We don't support
|
||||||
choice.insert("finish_reason", responseTokens == max_tokens ? "length" : "stop");
|
choice.insert("finish_reason", responseTokens == max_tokens ? "length" : "stop");
|
||||||
|
if (MySettings::globalInstance()->localDocsShowReferences()) {
|
||||||
QJsonArray references;
|
QJsonArray references;
|
||||||
for (const auto &ref : infos)
|
for (const auto &ref : infos)
|
||||||
references.append(resultToJson(ref));
|
references.append(resultToJson(ref));
|
||||||
choice.insert("references", references);
|
choice.insert("references", references);
|
||||||
|
}
|
||||||
choices.append(choice);
|
choices.append(choice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user