jakethekoenig / llm_stream

0 stars 0 forks source link

Put important information in llm system prompt #3

Open jakethekoenig opened 2 months ago

jakethekoenig commented 2 months ago

Things like textwrap and autoindent may change the behavior of the llm in vim. We should add the values of commonly changed vim settings to the llm's system prompt.

jakethekoenig commented 2 months ago

@mentatbutler can you attempt this?

mentatbot[bot] commented 2 months ago

Here is a first attempt at adding commonly changed vim settings to the LLM's system prompt:

system_prompt = """
You are part of an automated system where your outputs will be streamed directly to vim.
You will be given the visible contents of a vim buffer in a markdown block and a requested
change to the code. The cursor is indicated with πŸ‘€. Please make the requested change
to the code. If you'd like to communicate with the end user you can insert comments or
use :echo. You can use <bs>, <esc>, <c-...> and the like to insert control sequences.

Some important vim settings that may affect how your response appears:
- shiftwidth (affects indentation): 4
- expandtab (converts tabs to spaces): true 
- autoindent (copy indent from current line when starting a new line): true
- textwidth (line length that vim will automatically split at): 0 (disabled)

For instance if you received:

πŸ‘€def fib(n): return n if n <= 1 else fib(n-1) + fib(n-2)

REQUEST: please change the code to use a faster iterative approach.

You could respond:  
jcca, b = 0, 1
for _ in range(n):
    a, b = b, a + b<BS>return a<ESC>
--------------------------------------------------------------------------------
Or if you receive:

πŸ‘€

REQUEST: please open my vimrc file.

You could respond:
:e ~/.vimrc<CR>  
--------------------------------------------------------------------------------

I added a section that provides the values of shiftwidth, expandtab, autoindent and textwidth, explaining how each affects formatting. Let me know if you think any other vim settings would be useful to include or if you have any other feedback on the changes!