leona / helix-gpt

Code assistant language server for Helix with support for Copilot/OpenAI/Codeium/Ollama
MIT License
383 stars 28 forks source link

chat handler: openai doesn't exist #7

Closed webdev23 closed 8 months ago

webdev23 commented 8 months ago

Test cli: helix-gpt --handler openai --openaiKey 'sk-ogR5nc.......'

Hanging, no errors, no infos

Helix languages.toml:

[language-server.gpt]
command = "helix-gpt"
config = {}
args = ["--handler", "openai", "--openaiKey", "sk-ogR5nc......."

[[language]]
name = "bash"
auto-format = true
language-servers = [ "gpt" ]

[[language]]
name = "php"
language-servers = ["phpactor","gpt"]
auto-format = true

In Helix, % , Space + a, generate documentation

It's not working, no logs.

tail -f /root/.cache/helix/helix.log Blank

tail -f /app/helix-gpt.log # Or wherever you set --logFile to No found

locate helix-gpt.log Not found

leona commented 8 months ago

The code actions are only implemented for copilot at the moment, I'll add openai support soon. Could you check ~/.cache/helix for the log file instead?

webdev23 commented 8 months ago

tail -f ~/.cache/helix/helix.log

Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.

Willing to help debugging. Thank you.

leona commented 8 months ago

tail -f ~/.cache/helix/helix.log

Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.

Willing to help debugging. Thank you.

Haven't seen that error before. Best guess is that it's some helix weirdness with a language I haven't tested. I'll test it with your config when I'm home.

leona commented 8 months ago

Also if you could run helix in verbose mode hx -v test.js that might give us a better idea

webdev23 commented 8 months ago

hx -v test.php

tail -f ~/.cache/helix/helix.log

2024-01-26T19:30:26.369 helix_lsp::transport [ERROR] Tried sending response into a closed channel (id=Num(6)), original request likely timed out
2024-01-26T19:30:26.369 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:26.370 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:28.517 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"arguments":[{"query":"Refactor this code based on the comment.","range":{"end":{"character":0,"line":3},"start":{"character":6,"line":2}}}],"command":"refactorFromComment"},"id":8}
2024-01-26T19:30:28.519 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Executing refactorFromComment...","range":{"end":{"character":0,"line":3},"start":{"character":6,"line":2}},"severity":3,"source":"helix-gpt"}]}}
2024-01-26T19:30:28.519 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:28.520 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"chat handler: openai does not exist","severity":1,"range":{"end":{"character":0,"line":3},"start":{"character":6,"line":2}},"source":"helix-gpt"}]}}
2024-01-26T19:30:28.520 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:31.714 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:31.715 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:38.526 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:38.526 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:38.526 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:38.527 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:48.518 helix_term::commands::lsp [ERROR] execute LSP command: request 8 timed out
leona commented 8 months ago

hx -v test.php

tail -f ~/.cache/helix/helix.log

2024-01-26T19:30:26.369 helix_lsp::transport [ERROR] Tried sending response into a closed channel (id=Num(6)), original request likely timed out
2024-01-26T19:30:26.369 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:26.370 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:28.517 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"arguments":[{"query":"Refactor this code based on the comment.","range":{"end":{"character":0,"line":3},"start":{"character":6,"line":2}}}],"command":"refactorFromComment"},"id":8}
2024-01-26T19:30:28.519 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Executing refactorFromComment...","range":{"end":{"character":0,"line":3},"start":{"character":6,"line":2}},"severity":3,"source":"helix-gpt"}]}}
2024-01-26T19:30:28.519 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:28.520 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"chat handler: openai does not exist","severity":1,"range":{"end":{"character":0,"line":3},"start":{"character":6,"line":2}},"source":"helix-gpt"}]}}
2024-01-26T19:30:28.520 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:31.714 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:31.715 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:38.526 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:38.526 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
2024-01-26T19:30:38.526 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:38.527 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-26T19:30:48.518 helix_term::commands::lsp [ERROR] execute LSP command: request 8 timed out

Thanks. And what version of helix are you on?

webdev23 commented 8 months ago

23.10, compiled from source.

Other LSP, such as phpactor, are working alright are fairly usable.

I tried to deactivate them all and run only helix-gpt, same errors as above^.

Same with other languages, such as bash.

leona commented 8 months ago

23.10, compiled from source.

Other LSP, such as phpactor, are working alright are fairly usable.

I tried to deactivate them all and run only helix-gpt, same errors as above^.

Same with other languages, such as bash.

Ok leave it with me I'll check when I'm home. The error is pretty clear at least, the filepath isn't being passed.

leona commented 8 months ago

23.10, compiled from source.

Other LSP, such as phpactor, are working alright are fairly usable.

I tried to deactivate them all and run only helix-gpt, same errors as above^.

Same with other languages, such as bash.

Could you try with release 0.11

webdev23 commented 8 months ago
2024-01-28T08:55:15.555 helix_vcs [INFO] file is untracked
2024-01-28T08:55:15.555 helix_vcs [INFO] failed to open diff base for /media/<--REMOVED-->/test.php
2024-01-28T08:55:15.556 helix_lsp::client [INFO] Using custom LSP config: {}
2024-01-28T08:55:15.556 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActioÆnLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit","command"]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.10 (f6021dd0)"},"initializationOptions":{},"processId":2627793,"rootPath":"/media/<--REMOVED-->","rootUri":"file:///media/<--REMOVED-->","workspaceFolders":[{"name":"SHELIX","uri":"file:///media/<--REMOVED-->"}]},"id":0}
2024-01-28T08:55:15.632 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":1,"openClose":true}}}}
2024-01-28T08:55:15.632 helix_lsp::transport [INFO] gpt <- {"capabilities":{"codeActionProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"textDocumentSync":{"change":1,"openClose":true}}}
2024-01-28T08:55:15.632 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-28T08:55:15.632 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
2024-01-28T08:55:15.633 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"php","text":"\n","uri":"file:///media/<--REMOVED-->/test.php","version":0}}}
2024-01-28T08:55:47.769 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"<\n"}],"textDocument":{"uri":"file:///media/<--REMOVED-->/test.php","version":1}}}
2024-01-28T08:55:47.769 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":1,"line":0},"textDocument":{"uri":"file:///media/<--REMOVED-->/test.php"}},"id":1}
2024-01-28T08:55:47.975 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///media/<--REMOVED-->/test.php","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T08:55:48.164 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"<?\n"}],"textDocument":{"uri":"file:///media/<--REMOVED-->/test.php","version":2}}}
2024-01-28T08:55:48.638 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///media/<--REMOVED-->/test.php","diagnostics":[{"message":"Completion failed: request error with status code 429","severity":1,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"helix-gpt"}]}}y

Updated to v0.11.

hx -v test.php

tail -f ~/.cache/helix/helix.log

UI: Completion failed. Request Error with status 429


Well, now that i have an error code, that error 429 is an API quota rate limit: https://help.openai.com/en/articles/6891829-error-code-429-rate-limit-reached-for-requests

That's a bit of a misfortune :/ . i have other tools that are querying that api, and are still running. (Not the auto-completion service).

I see that each key type is sending a request, and in my opinion that is a bit aggressive, this will rapidly leads to troubles^

At this stage, can't confirm that helix-gpt runs fine, but it looks ok, thank you.

leona commented 8 months ago

It should only be triggered by the characters below. But Helix has its own set of characters/rules to trigger too. I haven't had any 429s yet though, so that's strange. triggerCharacters: ["{", "(", ")", "=", ">", " ", ",", ":", ".", "<", "/"]

webdev23 commented 8 months ago

Looks like I am ban^ (I code a lot)

triggerCharacters: ["{", "(", ")", "=", ">", " ", ",", ":", ".", "<", "/"]

We tend to use them quite often^

Might come back later to report for your app, i guess next month.

Thanks again.

leona commented 8 months ago

Looks like I am ban^ (I code a lot)

triggerCharacters: ["{", "(", ")", "=", ">", " ", ",", ":", ".", "<", "/"]

We tend to use them quite often^

Might come back later to report for your app, i guess next month.

Thanks again.

Yea do please. Still early days, but I think all of the features I want implemented are finished now. So my focus is on fixing any issues.

For the next release, I've updated the trigger characters to ["{", "(", " ", "."] As I see with PHP you would be triggering it a lot with the previous set. There's also a 200ms debounce, but that's not always effective.