diff --git a/plugins/plugin_llama-cpp-web.cpp b/plugins/plugin_llama-cpp-web.cpp index a5a1c7b..a9133c2 100644 --- a/plugins/plugin_llama-cpp-web.cpp +++ b/plugins/plugin_llama-cpp-web.cpp @@ -28,11 +28,11 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) } try { - //auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI); + auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI); // static store, could be anywhere tho // construct with fetched dependencies - g_lcw = std::make_unique(); + g_lcw = std::make_unique(*conf); // register types PLUG_PROVIDE_INSTANCE(LlamaCppWeb, plugin_name, g_lcw.get()); diff --git a/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.cpp b/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.cpp index b23cd59..1d46415 100644 --- a/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.cpp +++ b/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.cpp @@ -18,6 +18,11 @@ static std::string convertToSafeGrammarString(std::string_view input) { return res; } +LlamaCppWeb::LlamaCppWeb( + ConfigModelI& conf +) : _conf(conf), _cli(_conf.get_string("LlamaCppWeb", "server").value_or("localhost:8080")) { +} + LlamaCppWeb::~LlamaCppWeb(void) { } diff --git a/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.hpp b/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.hpp index 485d644..1485874 100644 --- a/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.hpp +++ b/src/solanaceae/llama-cpp-web/llama_cpp_web_impl.hpp @@ -2,6 +2,8 @@ #include "./text_completion_interface.hpp" +#include + #include #include @@ -9,14 +11,19 @@ #include struct LlamaCppWeb : public TextCompletionI { - // this mutex locks internally - httplib::Client _cli{"http://localhost:8080"}; + ConfigModelI& _conf; + + // this mutex-locks internally + httplib::Client _cli; // this is a bad idea static std::minstd_rand thread_local _rng; std::atomic _use_server_cache {true}; + LlamaCppWeb( + ConfigModelI& conf + ); ~LlamaCppWeb(void); bool isGood(void) override; diff --git a/src/test1.cpp b/src/test1.cpp index 5020132..293dab1 100644 --- a/src/test1.cpp +++ b/src/test1.cpp @@ -1,5 +1,7 @@ #include +#include + #include #include @@ -9,7 +11,8 @@ #include int main(void) { - LlamaCppWeb lcw; + SimpleConfigModel scm; + LlamaCppWeb lcw{scm}; if (!lcw.isGood()) { std::cerr << lcw._cli.host() << " " << lcw._cli.port() << " endpoint not healthy\n";