Skip to content

Commit

Permalink
llmodel: constify LLModel::threadCount()
Browse files Browse the repository at this point in the history
  • Loading branch information
imaami authored and manyoso committed May 22, 2023
1 parent efd39b0 commit 81fdc28
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion gpt4all-backend/gptj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,8 @@ void GPTJ::setThreadCount(int32_t n_threads) {
d_ptr->n_threads = n_threads;
}

int32_t GPTJ::threadCount() {
int32_t GPTJ::threadCount() const
{
return d_ptr->n_threads;
}

Expand Down
2 changes: 1 addition & 1 deletion gpt4all-backend/gptj.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GPTJ : public LLModel {
std::function<bool(bool)> recalculateCallback,
PromptContext &ctx) override;
void setThreadCount(int32_t n_threads) override;
int32_t threadCount() override;
int32_t threadCount() const override;

protected:
void recalculateContext(PromptContext &promptCtx,
Expand Down
3 changes: 2 additions & 1 deletion gpt4all-backend/llamamodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void LLamaModel::setThreadCount(int32_t n_threads) {
d_ptr->n_threads = n_threads;
}

int32_t LLamaModel::threadCount() {
int32_t LLamaModel::threadCount() const
{
return d_ptr->n_threads;
}

Expand Down
2 changes: 1 addition & 1 deletion gpt4all-backend/llamamodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LLamaModel : public LLModel {
std::function<bool(bool)> recalculateCallback,
PromptContext &ctx) override;
void setThreadCount(int32_t n_threads) override;
int32_t threadCount() override;
int32_t threadCount() const override;

protected:
void recalculateContext(PromptContext &promptCtx,
Expand Down
2 changes: 1 addition & 1 deletion gpt4all-backend/llmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LLModel {
std::function<bool(bool)> recalculateCallback,
PromptContext &ctx) = 0;
virtual void setThreadCount(int32_t n_threads) {}
virtual int32_t threadCount() { return 1; }
virtual int32_t threadCount() const { return 1; }

protected:
virtual void recalculateContext(PromptContext &promptCtx,
Expand Down
3 changes: 2 additions & 1 deletion gpt4all-backend/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ void MPT::setThreadCount(int32_t n_threads) {
d_ptr->n_threads = n_threads;
}

int32_t MPT::threadCount() {
int32_t MPT::threadCount() const
{
return d_ptr->n_threads;
}

Expand Down
2 changes: 1 addition & 1 deletion gpt4all-backend/mpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MPT : public LLModel {
std::function<bool(bool)> recalculateCallback,
PromptContext &ctx) override;
void setThreadCount(int32_t n_threads) override;
int32_t threadCount() override;
int32_t threadCount() const override;

protected:
void recalculateContext(PromptContext &promptCtx,
Expand Down
2 changes: 1 addition & 1 deletion gpt4all-chat/chatgpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void ChatGPT::setThreadCount(int32_t n_threads)
qt_noop();
}

int32_t ChatGPT::threadCount()
int32_t ChatGPT::threadCount() const
{
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion gpt4all-chat/chatgpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ChatGPT : public QObject, public LLModel {
std::function<bool(bool)> recalculateCallback,
PromptContext &ctx) override;
void setThreadCount(int32_t n_threads) override;
int32_t threadCount() override;
int32_t threadCount() const override;

void setModelName(const QString &modelName) { m_modelName = modelName; }
void setAPIKey(const QString &apiKey) { m_apiKey = apiKey; }
Expand Down

0 comments on commit 81fdc28

Please sign in to comment.