mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-18 03:25:46 +00:00
Cleanup the chatllm properly.
This commit is contained in:
parent
57ba554478
commit
76675536b0
@ -11,6 +11,17 @@ Chat::Chat(QObject *parent)
|
|||||||
, m_responseInProgress(false)
|
, m_responseInProgress(false)
|
||||||
, m_creationDate(QDateTime::currentSecsSinceEpoch())
|
, m_creationDate(QDateTime::currentSecsSinceEpoch())
|
||||||
, m_llmodel(new ChatLLM(this))
|
, m_llmodel(new ChatLLM(this))
|
||||||
|
{
|
||||||
|
connectLLM();
|
||||||
|
}
|
||||||
|
|
||||||
|
Chat::~Chat()
|
||||||
|
{
|
||||||
|
delete m_llmodel;
|
||||||
|
m_llmodel = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Chat::connectLLM()
|
||||||
{
|
{
|
||||||
// Should be in same thread
|
// Should be in same thread
|
||||||
connect(Download::globalInstance(), &Download::modelListChanged, this, &Chat::modelListChanged, Qt::DirectConnection);
|
connect(Download::globalInstance(), &Download::modelListChanged, this, &Chat::modelListChanged, Qt::DirectConnection);
|
||||||
|
@ -25,6 +25,8 @@ class Chat : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Chat(QObject *parent = nullptr);
|
explicit Chat(QObject *parent = nullptr);
|
||||||
|
virtual ~Chat();
|
||||||
|
void connectLLM();
|
||||||
|
|
||||||
QString id() const { return m_id; }
|
QString id() const { return m_id; }
|
||||||
QString name() const { return m_userName.isEmpty() ? m_name : m_userName; }
|
QString name() const { return m_userName.isEmpty() ? m_name : m_userName; }
|
||||||
|
@ -53,6 +53,13 @@ ChatLLM::ChatLLM(Chat *parent)
|
|||||||
m_llmThread.start();
|
m_llmThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChatLLM::~ChatLLM()
|
||||||
|
{
|
||||||
|
m_llmThread.quit();
|
||||||
|
m_llmThread.wait();
|
||||||
|
delete m_llmodel;
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatLLM::loadDefaultModel()
|
bool ChatLLM::loadDefaultModel()
|
||||||
{
|
{
|
||||||
const QList<QString> models = m_chat->modelList();
|
const QList<QString> models = m_chat->modelList();
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
ChatLLM(Chat *parent);
|
ChatLLM(Chat *parent);
|
||||||
|
virtual ~ChatLLM();
|
||||||
|
|
||||||
bool isModelLoaded() const;
|
bool isModelLoaded() const;
|
||||||
void regenerateResponse();
|
void regenerateResponse();
|
||||||
|
Loading…
Reference in New Issue
Block a user