Comments (6)
ohh that's an interesting suggestion.
might be nice to surface this as an additional ContextType
:
https://github.com/nvms/wingman/blob/main/src/template_render.ts#L32-L35
will definitely consider this!
from wingman.
since I left that comment, the ContextType
stuff was removed as it wasn't very useful and really only existed for UI purposes
from wingman.
The new OpenAI function calling stuff is really interesting. You could provide the model with a function that provides the source definition of a symbol via the LSP. You could then have the model decide to call that function with whatever symbol it thinks it need to understand and then add that to the context. So in the example above, instead of providing the source for g
automatically, the model could request it.
from wingman.
I just read up on all the function calling features - pretty cool!
maybe I'm overthinking this, but:
- store the
vscode.window.activeTextEditor.selection
at the time the command is issued - store an array of all tokens in the selection by splitting at common barriers (e.g.
[\s,.;:?!]
or something, but there may be a better way to do this)- store the character index of the beginning of the match:
{ word: .., index: ... }
.
having the index is useful, becauseexecuteDefinitionProvider
wants avscode.Position
and the second argument toPosition
is a character index.
- store the character index of the beginning of the match:
- when the model requests a symbol definition for
g
, we should have e.g.{ word: 'g', index: 1234 }
that we can use like:
const symbol = matches.find((match) => match.word === requestedSymbol);
const definition = await vscode.commands.executeCommand<vscode.DefinitionLink[]>(
"vscode.executeDefinitionProvider",
new vscode.Position(selection.start.line, selection.start.character + symbol.index)
);
since this is only a feature for the two newer ChatGPT models, I suppose it'd make sense to fall back to the original idea for models that do not support this
from wingman.
It looks like the LSP spec includes functionality around getting all the symbols in a document:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol
This can be called via vs code commands:
vscode.executeDocumentSymbolProvider
in https://code.visualstudio.com/api/references/commands
I think this would be much easier than trying to lex the code manually to get symbols.
I should actually look into what's available via the LSP. I had just assumed that there would a be parser in there somewhere that provided an AST that you could get access to, but it looks like I was wrong about that.
There's a vs code extension available that uses tree-sitter to get a parse tree:
https://github.com/cursorless-dev/vscode-parse-tree
I seriously doubt it would be worth adding the dependency though... especially since I think the combination of the symbol provider and definition provider from the LSP is probably enough for this use case.
from wingman.
I'm in favor of not bringing in treesitter as a dependency, because I think that means we also need to bring in a parser for every language we want to support (right?), which is maybe a bit too much for this feature.
executeDocumentSymbolProvider
seems like a solid path forward. I will need to experiment with it to understand it better, because I'm still fuzzy on how the following would be handled given that the docs say that the result of executeDocumentSymbolProvider
is a "list of symbols found in a given text document":
import f from "./f";
const g = () => {
return f();
};
does this mean that executeDocumentSymbolProvider
will include a definition for f
in the list for this document's symbols? I think the lack of clarity on my part is the usage of the word "found" as opposed to "defined". either way, I'm leaning towards this instead of building an AST at this point
from wingman.
Related Issues (20)
- Support configurable inference params per prompt HOT 8
- Context window and max_tokens management
- Disable the copy icon when generating HOT 1
- Write function comment prompt: ask before injecting the response into the file HOT 1
- New Goinfer provider HOT 3
- New Koboldcpp provider HOT 10
- Great Job! HOT 1
- A new theme sharing HOT 1
- Please include the julia language (.jl) extension also. HOT 1
- Wingman v2.0.8 , Local model is not supporting HOT 4
- Using the new version with local open source backends HOT 5
- Discussion: modelfusion HOT 2
- Missing Implementation of 'file' Placeholder as Mentioned in README HOT 1
- Feature Request: Enhance Contextual Understanding by Allowing Code File Integration
- Feature Request: Integration of Azure OpenAI Credentials Support HOT 1
- The selected code is forcibly replaced. HOT 4
- Model Installed in VS Code but No Settings No Logo in Sidebar Menu HOT 8
- `Error: Failed to open completion stream: 429 Too Many Requests` HOT 2
- Feature Request: Support Anthropic messages API
- Remove restriction on Ollama models
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wingman.