llama-chat.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * llama.cpp - commit 46e3556e01b824e52395fb050b29804b6cff2a7c - do not edit this file
  3. *
  4. * MIT License
  5. *
  6. * Copyright (c) 2023-2024 The ggml authors
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all
  16. * copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE.
  25. */
  26. #pragma once
  27. #include <string>
  28. #include <vector>
  29. #include <cstdint>
  30. enum llm_chat_template {
  31. LLM_CHAT_TEMPLATE_CHATML,
  32. LLM_CHAT_TEMPLATE_LLAMA_2,
  33. LLM_CHAT_TEMPLATE_LLAMA_2_SYS,
  34. LLM_CHAT_TEMPLATE_LLAMA_2_SYS_BOS,
  35. LLM_CHAT_TEMPLATE_LLAMA_2_SYS_STRIP,
  36. LLM_CHAT_TEMPLATE_MISTRAL_V1,
  37. LLM_CHAT_TEMPLATE_MISTRAL_V3,
  38. LLM_CHAT_TEMPLATE_MISTRAL_V3_TEKKEN,
  39. LLM_CHAT_TEMPLATE_MISTRAL_V7,
  40. LLM_CHAT_TEMPLATE_PHI_3,
  41. LLM_CHAT_TEMPLATE_FALCON_3,
  42. LLM_CHAT_TEMPLATE_ZEPHYR,
  43. LLM_CHAT_TEMPLATE_MONARCH,
  44. LLM_CHAT_TEMPLATE_GEMMA,
  45. LLM_CHAT_TEMPLATE_ORION,
  46. LLM_CHAT_TEMPLATE_OPENCHAT,
  47. LLM_CHAT_TEMPLATE_VICUNA,
  48. LLM_CHAT_TEMPLATE_VICUNA_ORCA,
  49. LLM_CHAT_TEMPLATE_DEEPSEEK,
  50. LLM_CHAT_TEMPLATE_DEEPSEEK_2,
  51. LLM_CHAT_TEMPLATE_DEEPSEEK_3,
  52. LLM_CHAT_TEMPLATE_COMMAND_R,
  53. LLM_CHAT_TEMPLATE_LLAMA_3,
  54. LLM_CHAT_TEMPLATE_CHATGML_3,
  55. LLM_CHAT_TEMPLATE_CHATGML_4,
  56. LLM_CHAT_TEMPLATE_MINICPM,
  57. LLM_CHAT_TEMPLATE_EXAONE_3,
  58. LLM_CHAT_TEMPLATE_RWKV_WORLD,
  59. LLM_CHAT_TEMPLATE_GRANITE,
  60. LLM_CHAT_TEMPLATE_GIGACHAT,
  61. LLM_CHAT_TEMPLATE_MEGREZ,
  62. LLM_CHAT_TEMPLATE_UNKNOWN,
  63. };
  64. struct llama_chat_message;
  65. llm_chat_template llm_chat_template_from_str(const std::string & name);
  66. llm_chat_template llm_chat_detect_template(const std::string & tmpl);
  67. int32_t llm_chat_apply_template(
  68. llm_chat_template tmpl,
  69. const std::vector<const llama_chat_message *> & chat,
  70. std::string & dest, bool add_ass);