News for hackers. Stuff that matters.
Re:LSP-AI: open-source language server serving as back end f... by simonw on Saturday June 08, 2024 @12:07PM (#40618470)
You have to learn how to prompt tools like Copilot. A few tricks I use a lot:

1. Write comments saying what you want the next lines of code to do

2. Write function definitions with clear function names and type annotations on the arguments - this can result in the full function body being provided if your definitions are clear enough

3. For repetitive code (like parameterized unit tests) provide a couple of examples and then use comments to hint at what it should write for you next based on those examples

4. Sometimes it's good to temporarily copy and paste a chunk of code in from elsewhere. For example, copy a CREATE TABLE SQL statement into a Python file when you are writing code that will interact with that table - or even an HTML page when you are writing out the HTML for a form associated with that table

Re:LSP-AI: open-source language server serving as back end f... by verdverm on Saturday June 08, 2024 @12:26PM (#40618630)
For 4, this is where I think using the target language(s) LSP / intellesense would be useful. The AI tools should know that I'm referring to a specific tables/types/libraries through references/locality/imports and supply that automatically to the context for me.
Re:LSP-AI: open-source language server serving as back end f... by simonw on Saturday June 08, 2024 @12:31PM (#40618671)
Copilot does that in a really clever way already: any time it performs a completion it looks at other nearby files in the project and tries to find pieces of code that look semantically similar to the area you are editing, then includes those snippets in its prompt.

This works well as a general rule, but sometimes it doesn't fine the right snippets - which is why I occasionally help it out through copy and paste.

Re:LSP-AI: open-source language server serving as back end f... by verdverm on Saturday June 08, 2024 @12:54PM (#40618836)
As described, that seems to miss out on files that are far away through imports, and if not similar to existing code, such as when writing unique code.

My main thoughts behind this are that

1. The LLMs tend to hallucinate library functions

2. I don't want to have to copy and paste a schema

Re:LSP-AI: open-source language server serving as back end f... by simonw on Saturday June 08, 2024 @12:57PM (#40618862)
Definitely not disagreeing that this stuff can be done better!
Re:LSP-AI: open-source language server serving as back end f... by verdverm on Saturday June 08, 2024 @01:11PM (#40618925)
Yeah, needs a lot of plumbing for sure, and I suspect more complex (agent) systems over calling a single LLM