How to use my codebase for code completion?

Hi, I am a newbie here. I am trying to figure out how to get code completions. If I give a simple prompt to Chat GPT like "Write an SQL Query to fetch XXX from YYY and specify table names, columns, etc without training Chat GPT gives me an SQL query. But I have a whole framework that I want the GPT to understand. It is not public domain, some of the code is proprietary. I understand that Codex is deprecated. Reading the forum I got the impression that code can be provided to the model as fine tuning. But I am not able to figure out exactly how will it work. Please guide.

I use GPT4 for that often ant it gives me pretty useful results. I need to check and correct results but with few sub-questions GPT4 will provide pretty good results.
I use something like this:

"You are an AI programming assistant specialised for SQL query.

You work like follows:

  • I give you the file name followed by the SQL
  • You acknowledge it with “OK”
  • We repeat first two steps until I ask question
  • Then I ask for modifications

While answering, follow the following rules:

  • Think step-by-step but don’t output your steps.
  • Output your answer as code or code comments in a single code block.
  • Comment each line of generated code.
  • Minimize any other prose.

Answer with OK if you understood."

In following few messages I provide the context. And then I start with the questions and code generation.

Once when you are finished, you can delete the chat and it will not be used in further training.

Give it a try and let us know your results.

1 Like

Thanks for the prompt response, MARK0! Will try this out and update here. But I do not have access to GPT4. Will this work with GPT 3?

Most coders use an editor. Most editors now support the integration of tools like CoPilot. The results will be better if you perform such development actions in an editor that can see your entire context. It is also more productive because you don’t have to perform task switching - write a comment; watch it create the code.

1 Like

Thanks for the response, Bill! So you think it will be better to use tools like CoPilot for this purpose. Will check whether that can serve my purpose.

I do, but I prefer my AI pair programmer to be informed about my coding style and the greater aspects of the code I’m working on. CoPilot is not free, so there’s that. However, ChatGPT isn’t always available. It’s been my experience that while writing code, the AI recommendations are more on-point because the editor is sharing a lot of context. ChatGPT doesn’t have this insight, so it does its best without context – or – you have to give it more context.

1 Like