Fixes for linux and macosx.

pull/520/head
Adam Treat 2 years ago
parent b41b1210cf
commit ae91bfa48a

@ -45,13 +45,21 @@ install(TARGETS chat DESTINATION bin COMPONENT ${COMPONENT_NAME_MAIN})
set(CPACK_GENERATOR "IFW") 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}) find_program(WINDEPLOYQT windeployqt HINTS ${_qt_bin_dir})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-windows.cmake.in" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-windows.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake" @ONLY) "${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake" @ONLY)
set(CPACK_PRE_BUILD_SCRIPTS ${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake) set(CPACK_PRE_BUILD_SCRIPTS ${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake)
set(CPACK_IFW_ROOT "C:/Qt/Tools/QtInstallerFramework/4.5") 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_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1") set(CPACK_PACKAGE_VERSION_MINOR "1")

@ -650,7 +650,7 @@ bool GPTJ::loadModel(const std::string &modelPath, std::istream &fin) {
// load the model // load the model
if (!gptj_model_load(modelPath, fin, d_ptr->model, d_ptr->vocab)) { 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; return false;
} }

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

Loading…
Cancel
Save