Skip to content

Commit

Permalink
Merge pull request #25 from chottolabs/deepseek-prompt-cache
Browse files Browse the repository at this point in the history
Add Deepseek templates for prompt caching
  • Loading branch information
chottolabs authored Sep 14, 2024
2 parents ddf5821 + a6a9cfd commit d2d4957
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/kznllm/presets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ local function make_data_for_deepseek_chat(prompt_args, opts)
local messages = {
{
role = 'system',
content = kznllm.make_prompt_from_template(template_directory / 'nous_research/fill_mode_system_prompt.xml.jinja', prompt_args),
content = kznllm.make_prompt_from_template(template_directory / 'deepseek/fill_mode_system_prompt.xml.jinja', prompt_args),
},
{
role = 'user',
content = kznllm.make_prompt_from_template(template_directory / 'nous_research/fill_mode_user_prompt.xml.jinja', prompt_args),
content = kznllm.make_prompt_from_template(template_directory / 'deepseek/fill_mode_user_prompt.xml.jinja', prompt_args),
},
}

Expand Down
5 changes: 5 additions & 0 deletions templates/deepseek/fill_mode_system_prompt.xml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if replace %}
You should replace the code that you are sent, only following the comments. Do not talk at all. Only output valid code. Do not provide any backticks that surround the code. Never ever output backticks like this ```. Any comment that is asking you for something should be removed after you satisfy them. Other comments should left alone. Do not output backticks
{% else %}
You are a Senior Engineer at a Fortune 500 Company. You will be provided with code samples, academic papers, and documentation as supporting context to assist you in answering user queries about coding. Your task is to analyze this information and use it to provide accurate, helpful responses to the user's coding-related questions.
{% endif %}
36 changes: 36 additions & 0 deletions templates/deepseek/fill_mode_user_prompt.xml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% if current_buffer_path or current_buffer_context or context_files %}
CONTEXT:
{% endif %}
{% if context_files %}
{% for file in context_files %}
Document:{{ loop.index }}
Title: {{ file.path }}
Content:
```
{{ file.content }}
```
{% endfor %}
{% endif %}
{% if current_buffer_path %}
Document:{{context_files | length + 1}}
Title: {{ current_buffer_path }}
{% endif %}
{% if current_buffer_context %}
Content:
```{{ current_buffer_filetype }}
{{ current_buffer_context }}
```
{% endif %}
{% if visual_selection %}
Code:
```{{ current_buffer_filetype }}
{{ visual_selection }}
```

{% if prefill %}
INSTRUCTION: Replace the code in the block given above. ONLY return the valid code fragment surrounded by a code fence with backticks.
{% else %}
INSTRUCTION: Replace the code in the block given above. ONLY return the code fragment that is requested in the code snippet WITHOUT backticks. DO NOT surround the code fragment in backticks.
{% endif %}
{% endif %}
QUERY: {{ user_query }}

0 comments on commit d2d4957

Please sign in to comment.