This commit is contained in:
mudler
2023-06-01 16:09:06 +02:00
committed by AT
parent 5220356273
commit 243c762411
4 changed files with 21 additions and 23 deletions

View File

@@ -16,30 +16,27 @@
#include <iostream>
#include <unistd.h>
void* load_gpt4all_model(const char *fname, int n_threads) {
void* load_model(const char *fname, int n_threads) {
// load the model
llmodel_error new_error{};
fprintf(stderr, "%s: fname '%s'\n",
__func__, fname);
auto gptj4all = llmodel_model_create2(fname, "auto", &new_error);
if (gptj4all == NULL ){
fprintf(stderr, "%s: error '%s'\n",
__func__, new_error.message);
llmodel_error new_error{};
auto model = llmodel_model_create2(fname, "auto", &new_error);
if (model == nullptr ){
fprintf(stderr, "%s: error '%s'\n",
__func__, new_error.message);
return nullptr;
}
llmodel_setThreadCount(gptj4all, n_threads);
if (!llmodel_loadModel(gptj4all, fname)) {
llmodel_setThreadCount(model, n_threads);
if (!llmodel_loadModel(model, fname)) {
return nullptr;
}
return gptj4all;
return model;
}
std::string res = "";
void * mm;
void gpt4all_model_prompt( const char *prompt, void *m, char* result, int repeat_last_n, float repeat_penalty, int n_ctx, int tokens, int top_k,
void model_prompt( const char *prompt, void *m, char* result, int repeat_last_n, float repeat_penalty, int n_ctx, int tokens, int top_k,
float top_p, float temp, int n_batch,float ctx_erase)
{
llmodel_model* model = (llmodel_model*) m;
@@ -101,7 +98,7 @@ void gpt4all_model_prompt( const char *prompt, void *m, char* result, int repeat
free(prompt_context);
}
void gpt4all_free_model(void *state_ptr) {
void free_model(void *state_ptr) {
llmodel_model* ctx = (llmodel_model*) state_ptr;
llmodel_model_destroy(*ctx);
}