@@ -73,7 +73,7 @@ static llama_v2_context * llama_ctx_v2;
73
73
static llama_v3_context * llama_ctx_v3;
74
74
static llama_context * llama_ctx_v4;
75
75
76
- static gpt_params * kcpp_params;
76
+ static gpt_params * kcpp_params = nullptr ;
77
77
static int max_context_limit_at_load = 0 ;
78
78
static int n_past = 0 ;
79
79
static int n_threads = 4 ;
@@ -1399,18 +1399,27 @@ ModelLoadResult gpttype_load_model(const load_model_inputs inputs, FileFormat in
1399
1399
1400
1400
bool gpttype_generate_abort ()
1401
1401
{
1402
+ if (kcpp_params==nullptr )
1403
+ {
1404
+ printf (" \n Warning: KCPP not initialized!\n " );
1405
+ }
1402
1406
stopper_unused_tokens = remaining_tokens;
1403
1407
remaining_tokens = 0 ;
1404
1408
return true ;
1405
1409
}
1406
1410
1407
1411
std::vector<int > gpttype_get_token_arr (const std::string & input)
1408
1412
{
1413
+ std::vector<int > toks;
1414
+ if (kcpp_params==nullptr )
1415
+ {
1416
+ printf (" \n Warning: KCPP not initialized!\n " );
1417
+ return toks;
1418
+ }
1409
1419
if (debugmode==1 )
1410
1420
{
1411
1421
printf (" \n FileFormat: %d, Tokenizing: %s" ,file_format ,input.c_str ());
1412
1422
}
1413
- std::vector<int > toks;
1414
1423
TokenizeString (input, toks, file_format);
1415
1424
int tokcount = toks.size ();
1416
1425
if (debugmode==1 )
@@ -1422,6 +1431,11 @@ std::vector<int> gpttype_get_token_arr(const std::string & input)
1422
1431
1423
1432
const std::string & gpttype_get_pending_output ()
1424
1433
{
1434
+ if (kcpp_params==nullptr )
1435
+ {
1436
+ printf (" \n Warning: KCPP not initialized!\n " );
1437
+ return concat_output_reader_copy;
1438
+ }
1425
1439
concat_output_mtx.lock ();
1426
1440
concat_output_reader_copy = concat_output;
1427
1441
concat_output_mtx.unlock ();
@@ -1430,6 +1444,14 @@ const std::string & gpttype_get_pending_output()
1430
1444
1431
1445
generation_outputs gpttype_generate (const generation_inputs inputs, generation_outputs &output)
1432
1446
{
1447
+ if (kcpp_params==nullptr )
1448
+ {
1449
+ printf (" \n Warning: KCPP not initialized!\n " );
1450
+ snprintf (output.text , sizeof (output.text ), " %s" , " " );
1451
+ output.status = 0 ;
1452
+ generation_finished = true ;
1453
+ return output;
1454
+ }
1433
1455
concat_output_mtx.lock ();
1434
1456
concat_output = " " ;
1435
1457
concat_output_reader_copy = " " ;
0 commit comments