File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -210,9 +210,12 @@ llama_token sampling_id(struct MyModel* mymodel) {
210
210
const char * sampling (struct MyModel * mymodel) {
211
211
llama_context * ctx = mymodel->ctx ;
212
212
int id = sampling_id (mymodel);
213
- std::string ret;
214
- if (id == llama_token_eos ()) ret = " </s>" ;
215
- else ret = llama_token_to_str (ctx, id);
213
+ static std::string ret;
214
+ if (id == llama_token_eos ()) {
215
+ ret = " </s>" ;
216
+ } else {
217
+ ret = llama_token_to_str (ctx, id);
218
+ }
216
219
eval_id (mymodel, id);
217
220
return ret.c_str ();
218
221
}
Original file line number Diff line number Diff line change 5
5
#include " llama.h"
6
6
#include " build-info.h"
7
7
8
-
9
8
extern " C" {
10
9
11
10
typedef struct MyModel {
@@ -14,14 +13,13 @@ typedef struct MyModel {
14
13
int n_past = 0 ;
15
14
} MyModel;
16
15
17
-
18
16
struct MyModel * create_mymodel (int argc, char ** argv);
19
17
20
18
bool eval_float (void * model, float * input, int N);
21
19
bool eval_tokens (void * model, std::vector<llama_token> tokens);
22
20
bool eval_id (struct MyModel * mymodel, int id);
23
21
bool eval_string (struct MyModel * mymodel, const char * str);
24
- const char * sampling (struct MyModel * mymodel);
22
+ const char * sampling (struct MyModel * mymodel);
25
23
llama_token sampling_id (struct MyModel * mymodel);
26
24
void free_mymodel (struct MyModel * mymodel);
27
25
You can’t perform that action at this time.
0 commit comments