Skip to content

Commit 564a8a0

Browse files
Merge pull request #74 from pabl-o-ce/deepseek
Add: DeepseekCoder v2 chat format
2 parents fb1c42c + 3bc7b24 commit 564a8a0

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

ReadMe.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# llama-cpp-agent
22

33
[![PyPI - Version](https://img.shields.io/pypi/v/llama-cpp-agent?logo=pypi&color=%2341bb13)](https://pypi.org/project/llama-cpp-agent/)
4-
[![Discord](https://img.shields.io/discord/1237393014154985582?logo=Discord&logoColor=%23ffffff&label=Discord&link=https%3A%2F%2Fdiscord.gg%2FsRMvWKrh)](https://discord.gg/sRMvWKrh)
4+
[![Discord](https://img.shields.io/discord/1237393014154985582?logo=Discord&logoColor=%23ffffff&label=Discord&link=https%3A%2F%2Fdiscord.gg%2FsRMvWKrh)](https://discord.gg/fgr5RycPFP)
55

66
![llama-cpp-agent logo](https://raw.githubusercontent.com/Maximilian-Winter/llama-cpp-agent/master/logo/logo_orange.png)
77

@@ -126,6 +126,8 @@ The llama-cpp-agent framework provides predefined message formatters to format m
126126
- `MessagesFormatterType.B22`: Formats messages using the B22 format.
127127
- `MessagesFormatterType.LLAMA_3`: Formats messages using the LLAMA 3 format.
128128
- `MessagesFormatterType.PHI_3`: Formats messages using the PHI 3 format.
129+
- `MessagesFormatterType.AUTOCODER`: Formats messages using the Autocoder format.
130+
- `MessagesFormatterType.DEEP_SEEK_CODER_2`: Formats messages using the DeepSeek Coder v2 format.
129131

130132
### Creating Custom Messages Formatter
131133

src/llama_cpp_agent/messages_formatter.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class MessagesFormatterType(Enum):
2727
OPEN_INTERPRETER = 14
2828
AUTOCODER = 15
2929
GEMMA_2 = 16
30+
DEEP_SEEK_CODER_2 = 17
3031

3132
@dataclass
3233
class PromptMarkers:
@@ -236,6 +237,12 @@ def _format_response(
236237
Roles.assistant: PromptMarkers("Assistant: ", "<|EOT|>\n"),
237238
Roles.tool: PromptMarkers("", ""),
238239
}
240+
deep_seek_coder_2_chat_prompt_markers = {
241+
Roles.system: PromptMarkers("""<|begin▁of▁sentence|>""", """\n\n"""),
242+
Roles.user: PromptMarkers("""User: """, """ \n\n"""),
243+
Roles.assistant: PromptMarkers("""Assistant: """, """<|end▁of▁sentence|>"""),
244+
Roles.tool: PromptMarkers("", ""),
245+
}
239246

240247
"""
241248
### Instruction:
@@ -358,7 +365,22 @@ def _format_response(
358365
eos_token="<|EOT|>",
359366
)
360367

361-
gemma_2_chat_formatter = MessagesFormatter("", gemma_2_prompt_markers, True, ["<end_of_turn>", "<start_of_turn>"])
368+
gemma_2_chat_formatter = MessagesFormatter(
369+
"",
370+
gemma_2_prompt_markers,
371+
True,
372+
["<end_of_turn>", "<start_of_turn>"]
373+
)
374+
375+
deep_seek_coder_2_chat_formatter = MessagesFormatter(
376+
"",
377+
deep_seek_coder_2_chat_prompt_markers,
378+
True,
379+
["<|end▁of▁sentence|>"],
380+
bos_token="<|begin▁of▁sentence|>",
381+
eos_token="<|end▁of▁sentence|>",
382+
)
383+
362384
predefined_formatter = {
363385
MessagesFormatterType.MISTRAL: mixtral_formatter,
364386
MessagesFormatterType.CHATML: chatml_formatter,
@@ -375,7 +397,8 @@ def _format_response(
375397
MessagesFormatterType.PHI_3: phi_3_chat_formatter,
376398
MessagesFormatterType.OPEN_INTERPRETER: open_interpreter_chat_formatter,
377399
MessagesFormatterType.AUTOCODER: autocoder_chat_formatter,
378-
MessagesFormatterType.GEMMA_2: gemma_2_chat_formatter
400+
MessagesFormatterType.GEMMA_2: gemma_2_chat_formatter,
401+
MessagesFormatterType.DEEP_SEEK_CODER_2: deep_seek_coder_2_chat_formatter
379402
}
380403

381404

0 commit comments

Comments
 (0)