From 25ecc4ad878db34d00a2e2f1fc15796496369e49 Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Thu, 2 Jan 2025 15:59:08 +0100 Subject: [PATCH] add code context for implement --- claudy.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/claudy.vim b/claudy.vim index ab39d57..6e1b83b 100644 --- a/claudy.vim +++ b/claudy.vim @@ -30,7 +30,9 @@ endfunction function! ClaudyImplement(user_prompt) - let system_prompt = "reply with an implementation of one function in C should be able to copied right into an editor, no explaining text, start always with ```c and end with ```" + let system_prompt = "detect programming language, reply only with new functions, no explaining text, start always with ``` and end with ```" + + let l:code_context = shellescape(join(getbufline(bufnr('%'), 1, '$'))) let json_data = { \ 'model': 'claude-3-5-sonnet-20241022', @@ -39,6 +41,14 @@ function! ClaudyImplement(user_prompt) \ 'messages': [ \ { \ 'role': 'user', + \ 'content': l:code_context + \ }, + \ { + \ 'role': 'assistant', + \ 'content': "I see your existing code. What would you like to add or modify?" + \ }, + \ { + \ 'role': 'user', \ 'content': a:user_prompt \ } \ ] -- 2.7.4