binding.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // MIT License
  2. // Copyright (c) 2023 go-skynet authors
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. // The above copyright notice and this permission notice shall be included in
  10. // all copies or substantial portions of the Software.
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. // SOFTWARE.
  18. #ifdef __cplusplus
  19. #include <string>
  20. #include <vector>
  21. extern "C" {
  22. #endif
  23. #include <stdbool.h>
  24. extern unsigned char tokenCallback(void *, char *);
  25. int eval(void *p, void *c, char *text);
  26. void *load_model(const char *fname, int n_ctx, int n_seed, bool memory_f16,
  27. bool mlock, bool embeddings, bool mmap, bool low_vram,
  28. bool vocab_only, int n_gpu, int n_batch, const char *maingpu,
  29. const char *tensorsplit, bool numa);
  30. void *llama_allocate_params(
  31. const char *prompt, int seed, int threads, int tokens, int top_k,
  32. float top_p, float temp, float repeat_penalty, int repeat_last_n,
  33. bool ignore_eos, bool memory_f16, int n_batch, int n_keep,
  34. const char **antiprompt, int antiprompt_count, float tfs_z, float typical_p,
  35. float frequency_penalty, float presence_penalty, int mirostat,
  36. float mirostat_eta, float mirostat_tau, bool penalize_nl,
  37. const char *logit_bias, const char *session_file, bool prompt_cache_all,
  38. bool mlock, bool mmap, const char *maingpu, const char *tensorsplit,
  39. bool prompt_cache_ro);
  40. void llama_free_params(void *params_ptr);
  41. void llama_binding_free_model(void *ctx);
  42. int llama_predict(void *params_ptr, void *state_pr, char *result, bool debug);
  43. #ifdef __cplusplus
  44. }
  45. #endif