mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-22 05:29:20 +00:00
fix test
This commit is contained in:
parent
407cb81725
commit
e592a5890e
@ -1,6 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
project(gpt4all-backend-test VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(G4A_TEST_OLLAMA_URL "http://localhost:11434/" CACHE STRING "The base URL of the Ollama server to use.")
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
include(../common/common.cmake)
|
||||
|
||||
|
@ -1,19 +1,13 @@
|
||||
set(TARGET test-backend)
|
||||
|
||||
configure_file(config.cppm.in "${CMAKE_CURRENT_BINARY_DIR}/config.cppm")
|
||||
configure_file(config.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/config.h")
|
||||
|
||||
add_executable(${TARGET}
|
||||
main.cpp
|
||||
)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_23)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
target_compile_options(${TARGET} PUBLIC -fmodules-ts)
|
||||
endif()
|
||||
target_sources(${TARGET} PRIVATE
|
||||
FILE_SET gpt4all_backend TYPE CXX_MODULES BASE_DIRS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/config.cppm"
|
||||
target_include_directories(${TARGET} PRIVATE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/include"
|
||||
)
|
||||
gpt4all_add_warning_options(${TARGET})
|
||||
target_link_libraries(${TARGET} PRIVATE
|
||||
|
@ -1,10 +0,0 @@
|
||||
module;
|
||||
|
||||
#include <QString>
|
||||
|
||||
export module gpt4all.test.config;
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
|
||||
export inline QString OLLAMA_URL = u"@G4A_TEST_OLLAMA_URL@"_s;
|
6
gpt4all-backend-test/src/config.h.in
Normal file
6
gpt4all-backend-test/src/config.h.in
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
inline const QString OLLAMA_URL = QStringLiteral("@G4A_TEST_OLLAMA_URL@");
|
@ -1,20 +1,28 @@
|
||||
#include <QCoro/QCoroTask>
|
||||
#include <QLatin1StringView>
|
||||
|
||||
import fmt;
|
||||
import gpt4all.backend.main;
|
||||
import gpt4all.test.config;
|
||||
#include "config.h"
|
||||
|
||||
#include <QCoro/QCoroTask>
|
||||
#include <fmt/format.h>
|
||||
#include <gpt4all-backend/formatters.h>
|
||||
#include <gpt4all-backend/main.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QLatin1StringView>
|
||||
|
||||
using gpt4all::backend::LLMProvider;
|
||||
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
fmt::print("Connecting to server at {}\n", OLLAMA_URL);
|
||||
LLMProvider provider(OLLAMA_URL);
|
||||
auto version = QCoro::waitFor(provider.getVersion());
|
||||
if (version) {
|
||||
fmt::print("Server version: {}", *version);
|
||||
fmt::print("Server version: {}\n", *version);
|
||||
} else {
|
||||
fmt::print("Network error: {}", version.unexpected().errorString);
|
||||
fmt::print("Network error: {}\n", version.error().errorString);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user