Fixes for linux and macosx.

This commit is contained in:
Adam Treat 2023-04-10 16:33:14 -04:00
parent e5805ae064
commit b088929df4
3 changed files with 17 additions and 9 deletions

View File

@ -45,13 +45,21 @@ install(TARGETS chat DESTINATION bin COMPONENT ${COMPONENT_NAME_MAIN})
set(CPACK_GENERATOR "IFW")
if (WIN32)
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
find_program(LINUXDEPLOYQT linuxdeployqt HINTS ${_qt_bin_dir})
message(AUTHOR_WARNING "heeeeeee ${LINUXDEPLOYQT}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-linux.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/deploy-qt-linux.cmake" @ONLY)
set(CPACK_PRE_BUILD_SCRIPTS ${CMAKE_BINARY_DIR}/cmake/deploy-qt-linux.cmake)
set(CPACK_IFW_ROOT "~/Qt/Tools/QtInstallerFramework/4.5")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
find_program(WINDEPLOYQT windeployqt HINTS ${_qt_bin_dir})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-windows.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake" @ONLY)
set(CPACK_PRE_BUILD_SCRIPTS ${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake)
set(CPACK_IFW_ROOT "C:/Qt/Tools/QtInstallerFramework/4.5")
endif (WIN32)
elseif(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
endif()
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")

View File

@ -650,7 +650,7 @@ bool GPTJ::loadModel(const std::string &modelPath, std::istream &fin) {
// load the model
if (!gptj_model_load(modelPath, fin, d_ptr->model, d_ptr->vocab)) {
std::cerr << "GPT-J ERROR: failed to load model from" << modelPath;
std::cerr << "GPT-J ERROR: failed to load model from " << modelPath;
return false;
}

12
llm.cpp
View File

@ -4,6 +4,7 @@
#include <QDir>
#include <QFile>
#include <QResource>
#include <fstream>
class MyLLM: public LLM { };
Q_GLOBAL_STATIC(MyLLM, llmInstance)
@ -28,13 +29,12 @@ bool GPTJObject::loadModel()
return true;
QString modelName("ggml-model-q4_0.bin");
QFile file(QCoreApplication::applicationDirPath() + QDir::separator() + modelName);
if (file.open(QIODevice::ReadOnly)) {
QString fileName = QCoreApplication::applicationDirPath() + QDir::separator() + modelName;
QFile file(fileName);
if (file.exists()) {
QByteArray data = file.readAll();
std::istringstream iss(data.toStdString());
m_gptj->loadModel(modelName.toStdString(), iss);
auto fin = std::ifstream(fileName.toStdString(), std::ios::binary);
m_gptj->loadModel(modelName.toStdString(), fin);
emit isModelLoadedChanged();
}