leona / helix-gpt

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

Undefined is not an object #4

Closed gglanzani closed 5 months ago

gglanzani commented 5 months ago

I've set up helix-gpt (I think properly, see below), but when editing a Python file, I get

2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "TypeError: undefined is not an object (evaluating 'this.contents.split')\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at positionalUpdate (/$bunfs/root/helix-gpt:238:19)\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:232:9\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at forEach (:1:21)\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:231:7\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:230:41\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:260:9\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:258:39\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at emit (node:events:154:95)\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:319:7\n"
2024-01-26T14:08:07.382 helix_lsp::transport [ERROR] gpt err <- "      at receiveLine (/$bunfs/root/helix-gpt:313:23)\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "233 |       });\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "234 |       ctx.contentVersion = request.params.textDocument.version;\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "235 |     });\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "236 |   }\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "237 |   positionalUpdate(text, range) {\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "238 |     const lines = this.contents.split(\"\\n\");\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "                        ^\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "TypeError: undefined is not an object (evaluating 'this.contents.split')\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "      at positionalUpdate (/$bunfs/root/helix-gpt:238:19)\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:232:9\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "      at forEach (:1:21)\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:231:7\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:230:41\n"
2024-01-26T14:08:07.666 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:260:9\n"
2024-01-26T14:08:07.667 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:258:39\n"
2024-01-26T14:08:07.667 helix_lsp::transport [ERROR] gpt err <- "      at emit (node:events:154:95)\n"
2024-01-26T14:08:07.667 helix_lsp::transport [ERROR] gpt err <- "      at /$bunfs/root/helix-gpt:319:7\n"
2024-01-26T14:08:07.667 helix_lsp::transport [ERROR] gpt err <- "      at receiveLine (/$bunfs/root/helix-gpt:313:23)\n"

My languages.toml contains

[language-server.gpt]
command = "/opt/homebrew/bin/helix-gpt" 
config = {}
args = ["--logFile", "/tmp/helix-gpt.log", "--handler", "copilot", "--copilotApiKey", "xxxx"]

[[language]]
name = "python"
scope = "source.python"
language-servers = [ "gpt" ]

/opt/homebrew/bin/helix-gpt exists and is executable (I ran /opt/homebrew/bin/helix-gpt --authCopilot to get the copilot key).

An excerpt from the log shows

APP 2024-01-26T13:08:04.264Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}

APP 2024-01-26T13:08:04.265Z --> failed to parse line: | JSON Parse error: Unable to parse JSON string | Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 3888

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"import base64\nimport json\nimport os\nfrom pathlib import Path\nfrom typing import Any, Dict\n\nfrom utilities.parser import parse_query\nfrom utilities.salesforce import Salesforce\nfrom google.cloud import storage\nfrom google.cloud import pubsub_v1\nfrom google.oauth2 import service_account\nimport logging\n\nfrom google.cloud.bigquery import Client\n\n\nqueries = {p.stem: p.open().read() for p in Path(\"queries\").glob(\"*.sql\")}\n\ndef get_salesforce_client() -> Salesforce:\n    blob: str = (\n        storage.Client(project=os.environ[\"GOOGLE_CLOUD_PROJECT\"])\n        .get_bucket(os.environ[\"STORAGE_BUCKET\"])\n        .get_blob(os.environ[\"APP\"])\n        .download_as_string()\n    )\n\n    parsed = json.loads(blob)\n\n    conn_login = parsed[\"conn_login\"]\n    conn_password = parsed[\"conn_password\"]\n    conn_security_token = parsed[\"conn_security_token\"]\n    conn_host = parsed[\"conn_host\"]\n\n    return Salesforce(\n        conn_login=conn_login,\n        conn_password=conn_password,\n        conn_security_token=conn_security_token,\n        conn_host=conn_host,\n    )\n\n\ndef get_pandas_gbq_credentials():\n    blob: str = (\n        storage.Client(project=os.environ[\"GOOGLE_CLOUD_PROJECT\"])\n        .get_bucket(os.environ[\"STORAGE_BUCKET\"])\n        .get_blob(\"pandas.json\")\n        .download_as_string()\n    )\n\n    account_info = json.loads(blob)\n\n    credentials = service_account.Credentials.from_service_account_info(account_info)\n\n    return credentials\n\n\ndef schedule_events(event, context):\n    \"\"\"\n    Publish the tables that need to be fetched from salesforce\n\n    :param dict event: The dictionary with data specific to this type of\n         event. The `data` field contains the PubsubMessage message. The\n         `attributes` field will contain custom attributes if there are any.\n    :param google.cloud.functions.Context context: The Cloud Functions event\n         metadata. The `event_id` field contains the Pub/Sub message ID. The\n         `timestamp` field contains the publish time.\n    \"\"\"\n    topic = os.environ[\"APP\"]\n    project_id = os.environ[\"GOOGLE_CLOUD_PROJECT\"]\n    publisher = pubsub_v1.PublisherClient()\n    topic_name = f\"projects/{project_id}/topics/{topic}\"\n\n    for table in queries.keys():\n        publisher.publish(topic_name, bytes(table, \"utf-8\"))\n\n\ndef import_salesforce(event: Dict[str, Any], context):\n    \"\"\"\n    Import the tables from salesforce to bigquery\n\n    :param event: The dictionary with data specific to this type of\n         event. The `data` field contains the PubsubMessage message. The\n         `attributes` field will contain custom attributes if there are any.\n    :param context: The Cloud Functions event\n         metadata. The `event_id` field contains the Pub/Sub message ID. The\n         `timestamp` field contains the publish time.\n    \"\"\"\n\n    sf = get_salesforce_client()\n\n    if \"data\" in event:\n        table_name = base64.b64decode(event[\"data\"]).decode(\"utf-8\")\n        query = queries.get(table_name)\n\n        if query:\n            parsed = parse_query(\n                query, strip_aliases=True, strip_escapes=False, strip_comments=True\n            )\n            table: str = parsed.table\n            logging.info(\"Importing %s\" % table)\n            df = sf.query_df(soql=query)\n            Salesforce.insert_in_bq(\n                df,\n                destination_table=f\"salesforce_xebia.{table}\",\n                project_id=os.environ[\"GOOGLE_CLOUD_PROJECT\"],\n                credentials=get_pandas_gbq_credentials(),\n            )\n            logging.info(\"Finished %s\" % table)\n","uri":"file:///Users/gio/code/salesforce-to-bigquery/main.py","version":0}}}Content-Length: 86

{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

APP 2024-01-26T13:08:07.750Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":2,"line":15},"textDocument":{"uri":"file:///Users/gio/code/salesforce-to-bigquery/main.py"}},"id":1}

APP 2024-01-26T13:08:07.877Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":3,"line":15},"textDocument":{"uri":"file:///Users/gio/code/salesforce-to-bigquery/main.py"}},"id":2}

What could be wrong?

lemontheme commented 5 months ago

Appears to have been introduced in the latest release. At least, I wasn't seeing this until upgrading to the 0.8 tag.

Update: I reverted back through the tagged commits until I hit one that worked. For me (using Copilot), tag 0.5 / 6c5ba68 works.

leona commented 5 months ago

Appears to have been introduced in the latest release. At least, I wasn't seeing this until upgrading to the 0.8 tag.

Update: I reverted back through the tagged commits until I hit one that worked. For me (using Copilot), tag 0.5 / 6c5ba68 works.

I'll get that fixed shortly, thanks for reporting it. Will be adding the codeActions soon too, cheers for the suggestion.

image

leona commented 5 months ago

@lemontheme Could you try with 0.9 please?

lemontheme commented 5 months ago

I'm afraid 0.9 isn't working on my end.

Relevant messages in ~/.cache/helix/helix.log:

2024-01-26T18:11:42.140 helix_lsp::transport [ERROR] copilot err <- "264 |     const lines = this.contents.split(\"\\n\");\n"
2024-01-26T18:11:42.140 helix_lsp::transport [ERROR] copilot err <- "265 |     const start = range.start.line;\n"
2024-01-26T18:11:42.140 helix_lsp::transport [ERROR] copilot err <- "266 |     const end = range.end.line;\n"
2024-01-26T18:11:42.140 helix_lsp::transport [ERROR] copilot err <- "267 |     const startLine = lines[start];\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "268 |     const endLine = lines[end];\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "269 |     const startLineStart = startLine.substring(0, range.start.character);\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "                                 ^\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "TypeError: undefined is not an object (evaluating 'startLine.substring')\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at positionalUpdate (/$bunfs/root/helix-gpt:269:28)\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:253:9\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at forEach (:1:21)\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:252:7\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:251:41\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:286:9\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:284:39\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at emit (node:events:154:95)\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:345:7\n"
2024-01-26T18:11:42.141 helix_lsp::transport [ERROR] copilot err <- "      at receiveLine (/$bunfs/root/helix-gpt:339:23)\n"
2024-01-26T18:11:43.751 helix_term::application [ERROR] Ignoring unknown notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.

helix-gpt.log

APP 2024-01-26T17:15:41.116Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params"
:{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeA
ction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor
.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":tr
ue,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit","command"
]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSup
port":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupp
ort":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{
"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistra
tion":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInform
ation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"la
belOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configu
ration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynami
cRegistration":true,"relativePatternSupport":false},"executeCommand":{"dynamicRegistration":false},"
fileOperations":{"didRename":true,"willRename":true},"inlayHint":{"refreshSupport":false},"symbol":{
"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","norm
alizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}
},"clientInfo":{"name":"helix","version":"23.10 (9c56afef)"},"initializationOptions":{},"processId":
88424,"rootPath":"/Users/adriaan","rootUri":null,"workspaceFolders":[]},"id":0}

APP 2024-01-26T17:15:41.117Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"resul
t":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","
improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacter
s":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}
lemontheme commented 5 months ago

Okay, so this is weird: Just now I did get a single completion. Green dot with a notification in the top right corner: 'fetching completions'. After that, I wasn't able to get any other completions. No idea why it was a one-time thing.

leona commented 5 months ago

Okay, so this is weird: Just now I did get a single completion. Green dot with a notification in the top right corner: 'fetching completions'. After that, I wasn't able to get any other completions. No idea why it was a one-time thing.

Could you run helix in verbose mode if you aren't already hx -v file.ts and post the output of the 2 log files again please. Mainly the .cache one, but from before it starts just so I can see what's happening when the didOpen event fires.

lemontheme commented 5 months ago

Huh, interesting comment to give a thumbs-down.

Anyway, here you go. Hope there's something useful in there.

~/.cache/helix/helix.log

2024-01-27T10:21:07.948 helix_lsp::client [INFO] Using custom LSP config: {}
2024-01-27T10:21:07.948 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"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},"fileOperations":{"didRename":true,"willRename":true},"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 (9c56afef)"},"initializationOptions":{},"processId":91065,"rootPath":"/Users/adriaan/Code/cloned/dep/helix-gpt","rootUri":null,"workspaceFolders":[]},"id":0}
2024-01-27T10:21:07.981 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}
2024-01-27T10:21:07.981 helix_lsp::transport [INFO] copilot <- {"capabilities":{"codeActionProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"textDocumentSync":{"change":2}}}
2024-01-27T10:21:07.981 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-27T10:21:07.981 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
2024-01-27T10:21:07.981 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = (\"surround this\"\n    \"hi\")\n\n\n\"this is a line\" \n\nclass A:\n    ...\n\n\ndef hi(): ...\n\n\n\n# implementaation of a person class\n\n@dataclass # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int # age field, type integer\n    address: str # address field, type string\n\n\n# list of 10 instances of Person\nl\n","uri":"file:///Users/adriaan/test.py","version":0}}}
2024-01-27T10:21:12.232 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":1,"line":37},"start":{"character":1,"line":37}},"text":" "}],"textDocument":{"uri":"file:///Users/adriaan/test.py","version":1}}}
2024-01-27T10:21:12.233 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":2,"line":37},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":1}
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "264 |     const lines = this.contents.split(\"\\n\");\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "265 |     const start = range.start.line;\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "266 |     const end = range.end.line;\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "267 |     const startLine = lines[start];\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "268 |     const endLine = lines[end];\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "269 |     const startLineStart = startLine.substring(0, range.start.character);\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "                                 ^\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "TypeError: undefined is not an object (evaluating 'startLine.substring')\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at positionalUpdate (/$bunfs/root/helix-gpt:269:28)\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:253:9\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at forEach (:1:21)\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:252:7\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:251:41\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:286:9\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:284:39\n"
2024-01-27T10:21:12.237 helix_lsp::transport [ERROR] copilot err <- "      at emit (node:events:154:95)\n"
2024-01-27T10:21:12.238 helix_lsp::transport [ERROR] copilot err <- "      at /$bunfs/root/helix-gpt:345:7\n"
2024-01-27T10:21:12.238 helix_lsp::transport [ERROR] copilot err <- "      at receiveLine (/$bunfs/root/helix-gpt:339:23)\n"

and helix-gpt.log

APP 2024-01-27T09:24:43.607Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"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},"fileOperations":{"didRename":true,"willRename":true},"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 (9c56afef)"},"initializationOptions":{},"processId":91284,"rootPath":"/Users/adriaan/Code/cloned/dep/helix-gpt","rootUri":null,"workspaceFolders":[]},"id":0}

APP 2024-01-27T09:24:43.607Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}

APP 2024-01-27T09:24:43.609Z --> received request: | {"jsonrpc":"2.0","method":"initialized","params":{}}

APP 2024-01-27T09:24:43.609Z --> received request: | {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

APP 2024-01-27T09:24:47.828Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":2,"line":37},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":1}

APP 2024-01-27T09:24:48.033Z --> skipping |  | not in | {,(,),=,>, ,,,:,.,<,/

APP 2024-01-27T09:24:48.034Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}

APP 2024-01-27T09:24:48.035Z --> sent request | {"jsonrpc":"2.0","id":1,"result":{"isIncomplete":false,"items":[]}}

APP 2024-01-27T09:24:48.376Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":3,"line":37},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":2}

APP 2024-01-27T09:24:48.580Z --> skipping |  | not in | {,(,),=,>, ,,,:,.,<,/

APP 2024-01-27T09:24:48.581Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}

APP 2024-01-27T09:24:48.581Z --> sent request | {"jsonrpc":"2.0","id":2,"result":{"isIncomplete":false,"items":[]}}

APP 2024-01-27T09:24:48.674Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":4,"line":37},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":3}

APP 2024-01-27T09:24:48.878Z --> skipping |  | not in | {,(,),=,>, ,,,:,.,<,/

APP 2024-01-27T09:24:48.879Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}

APP 2024-01-27T09:24:48.879Z --> sent request | {"jsonrpc":"2.0","id":3,"result":{"isIncomplete":false,"items":[]}}

APP 2024-01-27T09:24:50.046Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":5,"line":37},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":4}

APP 2024-01-27T09:24:50.250Z --> skipping |  | not in | {,(,),=,>, ,,,:,.,<,/

APP 2024-01-27T09:24:50.251Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}

APP 2024-01-27T09:24:50.251Z --> sent request | {"jsonrpc":"2.0","id":4,"result":{"isIncomplete":false,"items":[]}}
lemontheme commented 5 months ago

Okay, so this is weird: Just now I did get a single completion. Green dot with a notification in the top right corner: 'fetching completions'. After that, I wasn't able to get any other completions. No idea why it was a one-time thing.

It just happened again!

Just brainstorming: could it be that your cleverly extracted Copilot endpoint is misbehaving in some way?

Something I'm obersving in the logs: when it does work, uri is set to the path of the current file. But then when I re-open the file, it's reported as missing again:

Invalid params: missing field `uri`
leona commented 5 months ago

Okay, so this is weird: Just now I did get a single completion. Green dot with a notification in the top right corner: 'fetching completions'. After that, I wasn't able to get any other completions. No idea why it was a one-time thing.

It just happened again!

Just brainstorming: could it be that your cleverly extracted Copilot endpoint is misbehaving in some way?

Something I'm obersving in the logs: when it does work, uri is set to the path of the current file. But then when I re-open the file, it's reported as missing again:

Invalid params: missing field `uri`

I think it's being caused by the didOpen event not firing for some reason. I've just pushed a change to update the uri in didChange and codeAction that might help resolve this.

notnmeyer commented 5 months ago

i also got 2024-01-27T12:42:58.850 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field uri. on 0.9.

0.10 fails a different way. inside helix, Completion failed: request error with status code 400, and the log is showing timeouts now, 2024-01-27T12:44:49.872 helix_view::editor [ERROR] editor error: Async job failed: request 3 timed out.

no invalid params error on 0.10 though /shrug

leona commented 5 months ago

i also got 2024-01-27T12:42:58.850 helix_term::application [ERROR] received malformed notification from Language Server: protocol error: InvalidParams: Invalid params: missing field uri. on 0.9.

0.10 fails a different way. inside helix, Completion failed: request error with status code 400, and the log is showing timeouts now, 2024-01-27T12:44:49.872 helix_view::editor [ERROR] editor error: Async job failed: request 3 timed out.

no invalid params error on 0.10 though /shrug

The helix-gpt log should show what exactly is being sent in the request. Would explain the 400 error.

notnmeyer commented 5 months ago

tried a go project and a ts project. both fail on 0.10 the same way. here's the log from a completion request on the ts project,

APP 2024-01-28T03:29:16.049Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"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":18644,"rootPath":"/Users/nate/code/optic","rootUri":"file:///Users/nate/code/optic","workspaceFolders":[{"name":"optic","uri":"file:///Users/nate/code/optic"}]},"id":0}

APP 2024-01-28T03:29:16.050Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}

APP 2024-01-28T03:29:16.051Z --> received request: | {"jsonrpc":"2.0","method":"initialized","params":{}}

APP 2024-01-28T03:29:16.052Z --> received request: | {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

APP 2024-01-28T03:29:22.101Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":5,"line":46},"textDocument":{"uri":"file:///Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts"}},"id":1}

APP 2024-01-28T03:29:22.308Z --> calling completion event | 5 | < | 5

APP 2024-01-28T03:29:22.309Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}}}]

APP 2024-01-28T03:29:22.309Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T03:29:22.309Z --> running completion handler: | copilot

APP 2024-01-28T03:29:22.310Z --> refreshing copilot token

APP 2024-01-28T03:29:22.737Z --> updated token | <redacted>

APP 2024-01-28T03:29:22.739Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts\n","stop":["\n\n"],"stream":true,"suffix":"","temperature":0.4,"top_p":1}

APP 2024-01-28T03:29:22.945Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T03:29:22.947Z --> copilot request failed: request error with status code 400

APP 2024-01-28T03:29:22.947Z --> completion failed | request error with status code 400

APP 2024-01-28T03:29:22.947Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}}}]

APP 2024-01-28T03:29:22.948Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T03:29:27.815Z --> received request: | {"jsonrpc":"2.0","method":"shutdown","id":2}

APP 2024-01-28T03:29:27.816Z --> received shutdown request

I think that 400 is indicating the request hitting copilot is malformed?

leona commented 5 months ago

tried a go project and a ts project. both fail on 0.10 the same way. here's the log from a completion request on the ts project,

APP 2024-01-28T03:29:16.049Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"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":18644,"rootPath":"/Users/nate/code/optic","rootUri":"file:///Users/nate/code/optic","workspaceFolders":[{"name":"optic","uri":"file:///Users/nate/code/optic"}]},"id":0}

APP 2024-01-28T03:29:16.050Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}

APP 2024-01-28T03:29:16.051Z --> received request: | {"jsonrpc":"2.0","method":"initialized","params":{}}

APP 2024-01-28T03:29:16.052Z --> received request: | {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

APP 2024-01-28T03:29:22.101Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":5,"line":46},"textDocument":{"uri":"file:///Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts"}},"id":1}

APP 2024-01-28T03:29:22.308Z --> calling completion event | 5 | < | 5

APP 2024-01-28T03:29:22.309Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}}}]

APP 2024-01-28T03:29:22.309Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T03:29:22.309Z --> running completion handler: | copilot

APP 2024-01-28T03:29:22.310Z --> refreshing copilot token

APP 2024-01-28T03:29:22.737Z --> updated token | <redacted>

APP 2024-01-28T03:29:22.739Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts\n","stop":["\n\n"],"stream":true,"suffix":"","temperature":0.4,"top_p":1}

APP 2024-01-28T03:29:22.945Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T03:29:22.947Z --> copilot request failed: request error with status code 400

APP 2024-01-28T03:29:22.947Z --> completion failed | request error with status code 400

APP 2024-01-28T03:29:22.947Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}}}]

APP 2024-01-28T03:29:22.948Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/nate/code/optic/projects/optic/src/utils/write-to-file.test.ts","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":46,"character":0},"end":{"line":47,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T03:29:27.815Z --> received request: | {"jsonrpc":"2.0","method":"shutdown","id":2}

APP 2024-01-28T03:29:27.816Z --> received shutdown request

I think that 400 is indicating the request hitting copilot is malformed?

Ok 2 problems. The content isn't being updated, and language is the number 3 for some reason, but should be a string.

I've just released 0.11 with some potential fixes, as well as more debug logging. Let me know how you get on with that one.

lemontheme commented 5 months ago

I'm afraid I also have to report status code 400 errors. The contents of both log files are pasted below.

Btw, the API token is being written to helix-gpt.log, whereas I believe in earlier versions it got redacted. That seems like an accident waiting to happen. (In fact it was a last-second decision to check before submitting this comment.)

I should also add that I'm building Helix off of master (I like shiny new things). I'm on helix 23.10 (4ab70295) to be precise, which has helix-lsp v23.10.0.

I'll check if things work better using a release version. UPDATE: Nope, same issue on the latest stable release.


helix.log

2024-01-28T10:46:42.730 helix_vcs [INFO] failed to obtain current head name for /Users/adriaan/test.py
2024-01-28T10:46:42.733 helix_lsp::client [INFO] Using custom LSP config: {}
2024-01-28T10:46:42.733 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"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},"fileOperations":{"didRename":true,"willRename":true},"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 (4ab70295)"},"initializationOptions":{},"processId":9414,"rootPath":"/Users/adriaan/.dotfiles","rootUri":null,"workspaceFolders":[]},"id":0}
2024-01-28T10:46:42.765 helix_lsp::transport [INFO] copilot <- {"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-28T10:46:42.765 helix_lsp::transport [INFO] copilot <- {"capabilities":{"codeActionProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","("," ","."]},"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"textDocumentSync":{"change":1,"openClose":true}}}
2024-01-28T10:46:42.765 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-28T10:46:42.766 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
2024-01-28T10:46:42.766 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\n\n    \n","uri":"file:///Users/adriaan/test.py","version":0}}}
2024-01-28T10:46:47.511 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":1},"position":{"character":0,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":1}
2024-01-28T10:46:47.722 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:47.722 helix_term::application [ERROR] Ignoring unknown notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-28T10:46:48.124 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:48.124 helix_term::application [ERROR] Ignoring unknown notification from Language Server: protocol error: InvalidParams: Invalid params: missing field `uri`.
2024-01-28T10:46:50.051 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\nd\n    \n"}],"textDocument":{"uri":"file:///Users/adriaan/test.py","version":1}}}
2024-01-28T10:46:50.150 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\nde\n    \n"}],"textDocument":{"uri":"file:///Users/adriaan/test.py","version":2}}}
2024-01-28T10:46:50.156 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":2},"position":{"character":2,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":2}
2024-01-28T10:46:50.360 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\ndef\n    \n"}],"textDocument":{"uri":"file:///Users/adriaan/test.py","version":3}}}
2024-01-28T10:46:50.362 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:50.366 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":2},"position":{"character":3,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":3}
2024-01-28T10:46:50.389 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:50.571 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:50.598 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:50.873 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\ndef \n    \n"}],"textDocument":{"uri":"file:///Users/adriaan/test.py","version":4}}}
2024-01-28T10:46:50.878 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerCharacter":" ","triggerKind":2},"position":{"character":4,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":4}
2024-01-28T10:46:51.084 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:51.110 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:51.636 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":1},"position":{"character":4,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":5}
2024-01-28T10:46:51.844 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:51.871 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:52.841 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\n\n    \n"}],"textDocument":{"uri":"file:///Users/adriaan/test.py","version":5}}}
2024-01-28T10:46:53.117 helix_lsp::transport [INFO] copilot -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":1},"position":{"character":0,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":6}
2024-01-28T10:46:53.324 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
2024-01-28T10:46:53.354 helix_lsp::transport [INFO] copilot <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

helix-gpt.log

APP 2024-01-28T09:46:42.765Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"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},"fileOperations":{"didRename":true,"willRename":true},"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 (4ab70295)"},"initializationOptions":{},"processId":9414,"rootPath":"/Users/adriaan/.dotfiles","rootUri":null,"workspaceFolders":[]},"id":0}

APP 2024-01-28T09:46:42.765Z --> sent request | {"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}}}}

APP 2024-01-28T09:46:42.767Z --> received request: | {"jsonrpc":"2.0","method":"initialized","params":{}}

APP 2024-01-28T09:46:42.767Z --> received request: | {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

APP 2024-01-28T09:46:47.514Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":1},"position":{"character":0,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":1}

APP 2024-01-28T09:46:47.721Z --> calling completion event | 0 | < | 0

APP 2024-01-28T09:46:47.721Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:47.722Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:47.722Z --> running completion handler: | copilot

APP 2024-01-28T09:46:47.723Z --> refreshing copilot token

APP 2024-01-28T09:46:48.042Z --> updated token | tid=<removed by me>;sku=free_engaged_oss;st=dotcom;chat=1;rt=1;8kp=<removed by me>

APP 2024-01-28T09:46:48.044Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: unknown\n","stop":["\n\n"],"stream":true,"suffix":"","temperature":0.4,"top_p":1}

APP 2024-01-28T09:46:48.122Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T09:46:48.123Z --> copilot request failed: request error with status code 400

APP 2024-01-28T09:46:48.123Z --> completion failed | request error with status code 400

APP 2024-01-28T09:46:48.124Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:48.124Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:50.054Z --> received didChange | language: undefined | contentVersion: 1

APP 2024-01-28T09:46:50.152Z --> received didChange | language: undefined | contentVersion: 2

APP 2024-01-28T09:46:50.157Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":2},"position":{"character":2,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":2}

APP 2024-01-28T09:46:50.361Z --> calling completion event | 2 | < | 2

APP 2024-01-28T09:46:50.362Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:50.362Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:50.362Z --> running completion handler: | copilot

APP 2024-01-28T09:46:50.363Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/adriaan/test.py\n# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\nde","stop":["\n\n"],"stream":true,"suffix":"    \n","temperature":0.4,"top_p":1}

APP 2024-01-28T09:46:50.363Z --> received didChange | language: undefined | contentVersion: 3

APP 2024-01-28T09:46:50.367Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":2},"position":{"character":3,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":3}

APP 2024-01-28T09:46:50.388Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T09:46:50.389Z --> copilot request failed: request error with status code 400

APP 2024-01-28T09:46:50.389Z --> completion failed | request error with status code 400

APP 2024-01-28T09:46:50.389Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:50.389Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:50.570Z --> calling completion event | 3 | < | 3

APP 2024-01-28T09:46:50.571Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:50.571Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:50.572Z --> running completion handler: | copilot

APP 2024-01-28T09:46:50.572Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/adriaan/test.py\n# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\ndef","stop":["\n\n"],"stream":true,"suffix":"    \n","temperature":0.4,"top_p":1}

APP 2024-01-28T09:46:50.597Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T09:46:50.598Z --> copilot request failed: request error with status code 400

APP 2024-01-28T09:46:50.598Z --> completion failed | request error with status code 400

APP 2024-01-28T09:46:50.598Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:50.598Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:50.874Z --> received didChange | language: undefined | contentVersion: 4

APP 2024-01-28T09:46:50.879Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerCharacter":" ","triggerKind":2},"position":{"character":4,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":4}

APP 2024-01-28T09:46:51.083Z --> calling completion event | 4 | < | 4

APP 2024-01-28T09:46:51.083Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:51.084Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:51.084Z --> running completion handler: | copilot

APP 2024-01-28T09:46:51.084Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/adriaan/test.py\n# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\ndef ","stop":["\n\n"],"stream":true,"suffix":"    \n","temperature":0.4,"top_p":1}

APP 2024-01-28T09:46:51.109Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T09:46:51.110Z --> copilot request failed: request error with status code 400

APP 2024-01-28T09:46:51.110Z --> completion failed | request error with status code 400

APP 2024-01-28T09:46:51.110Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:51.110Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:51.638Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":1},"position":{"character":4,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":5}

APP 2024-01-28T09:46:51.843Z --> calling completion event | 4 | < | 4

APP 2024-01-28T09:46:51.843Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:51.844Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:51.844Z --> running completion handler: | copilot

APP 2024-01-28T09:46:51.844Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/adriaan/test.py\n# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\ndef ","stop":["\n\n"],"stream":true,"suffix":"    \n","temperature":0.4,"top_p":1}

APP 2024-01-28T09:46:51.870Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T09:46:51.871Z --> copilot request failed: request error with status code 400

APP 2024-01-28T09:46:51.871Z --> completion failed | request error with status code 400

APP 2024-01-28T09:46:51.871Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:51.871Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:52.844Z --> received didChange | language: undefined | contentVersion: 5

APP 2024-01-28T09:46:53.119Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"context":{"triggerKind":1},"position":{"character":0,"line":42},"textDocument":{"uri":"file:///Users/adriaan/test.py"}},"id":6}

APP 2024-01-28T09:46:53.323Z --> calling completion event | 5 | < | 5

APP 2024-01-28T09:46:53.323Z --> sending diagnostics | [{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:53.324Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}

APP 2024-01-28T09:46:53.324Z --> running completion handler: | copilot

APP 2024-01-28T09:46:53.324Z --> sending completion request | {"extra":{"language":3,"next_indent":0,"prompt_tokens":500,"suffix_tokens":400,"trim_by_indentation":true},"max_tokens":500,"n":3,"nwo":"app","prompt":"// Path: /Users/adriaan/test.py\n# Simple python function to test lemon_repl\nfrom dataclasses import dataclass\n\n\ndef f() -> int:\n    return 2\n\n\na = 2\n\nprint(\"hello\")\n\ns = f\"the number is {a}\"\n\na = \"surround this\" \"hi\"\n\n\n\"this is a line\"\n\n\nclass A:\n    ...\n\n\ndef hi():\n    ...\n\n\n# implementaation of a person class\n\n\n@dataclass  # mark class as a dataclass\nclass Person:\n    name: str  # name field, type string\n    age: int  # age field, type integer\n    address: str  # address field, type string\n\n\n# List of 10 instances of Person\n\n\n# function that takes a number x and multiplies it by 2\n","stop":["\n\n"],"stream":true,"suffix":"    \n","temperature":0.4,"top_p":1}

APP 2024-01-28T09:46:53.352Z --> completion error | 400 | Bad request: invalid completion request: bad request: json: cannot unmarshal number into Go struct field Extra.extra.language of type string

APP 2024-01-28T09:46:53.353Z --> copilot request failed: request error with status code 400

APP 2024-01-28T09:46:53.353Z --> completion failed | request error with status code 400

APP 2024-01-28T09:46:53.354Z --> sending diagnostics | [{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}}}]

APP 2024-01-28T09:46:53.354Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/adriaan/test.py","diagnostics":[{"message":"Completion failed: request error with status code 400","severity":1,"range":{"start":{"line":42,"character":0},"end":{"line":43,"character":0}},"source":"helix-gpt"}]}}
leona commented 5 months ago

@lemontheme Good shout, I've removed that log in 0.12 now.

Also, the 400 requests should be resolved as well. It wasn't passing the correct filepath.

lemontheme commented 5 months ago

Yay, I'm receiving completions in insert mode again! Excellent, now we're getting somewhere :)

Code actions still trigger an undefined error though. I'm using Copilot. This is the message in the helix.log:

Chat failed: undefined is not an object (evaluating 'result.replace')"

And the corresponding event in helix-gpt.log

APP 2024-01-28T12:21:48.021Z --> sent request | {"jsonrpc":"2.0","id":16,"result":[{"title":"Generate documentation","kind":"quickfix","diagnostics":[],"command":{"title":"Generate documentation","command":"generateDocs","arguments":[{"range":{"end":{"character":0,"line":60},"start":{"character":0,"line":54}},"query":"Add documentation to this code."}]}},{"title":"Improve code","kind":"quickfix","diagnostics":[],"command":{"title":"Improve code","command":"improveCode","arguments":[{"range":{"end":{"character":0,"line":60},"start":{"character":0,"line":54}},"query":"Improve this code."}]}},{"title":"Refactor code from a comment","kind":"quickfix","diagnostics":[],"command":{"title":"Refactor code from a comment","command":"refactorFromComment","arguments":[{"range":{"end":{"character":0,"line":60},"start":{"character":0,"line":54}},"query":"Refactor this code based on the comment."}]}}]}

Some more feedback, which I can open separate issues for:

Let me give an example of the last point.

Suppose I start with this comment block:

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.

I open a new line and type def or hit Ctrl-x. Sometimes I get a complete implementation, e.g.

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.
def dfs(graph, start):
    visited = set()
    stack = [start]
    while stack:
        v = stack.pop()
        if v not in visited:
            visited.add(v)
            stack.extend(graph[v] - visited)
    return visited

But other times, on exactly the same line, I get either a partial implementation, e.g.

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.
def dfs(graph, start):
    visited = set()
    stack = [start]

Or just a function signature:

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.
def dfs(graph, start):
    ...

The weird thing is it's different every time. The helix-gpt logs don't contain anything about API errors or request timeouts.

My current guesses are a) the Copilot API is missing one or more parameters, e.g. the language type, or b) there's some post-processing going on that's truncating the responses.

leona commented 5 months ago

Yay, I'm receiving completions in insert mode again! Excellent, now we're getting somewhere :)

Code actions still trigger an undefined error though. I'm using Copilot. This is the message in the helix.log:

Chat failed: undefined is not an object (evaluating 'result.replace')"

And the corresponding event in helix-gpt.log

APP 2024-01-28T12:21:48.021Z --> sent request | {"jsonrpc":"2.0","id":16,"result":[{"title":"Generate documentation","kind":"quickfix","diagnostics":[],"command":{"title":"Generate documentation","command":"generateDocs","arguments":[{"range":{"end":{"character":0,"line":60},"start":{"character":0,"line":54}},"query":"Add documentation to this code."}]}},{"title":"Improve code","kind":"quickfix","diagnostics":[],"command":{"title":"Improve code","command":"improveCode","arguments":[{"range":{"end":{"character":0,"line":60},"start":{"character":0,"line":54}},"query":"Improve this code."}]}},{"title":"Refactor code from a comment","kind":"quickfix","diagnostics":[],"command":{"title":"Refactor code from a comment","command":"refactorFromComment","arguments":[{"range":{"end":{"character":0,"line":60},"start":{"character":0,"line":54}},"query":"Refactor this code based on the comment."}]}}]}

Some more feedback, which I can open separate issues for:

  • In the log messages, language is often undefined.
  • Perhaps relatedly, completions are often incomplete. They appear to be truncated.

Let me give an example of the last point.

Suppose I start with this comment block:

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.

I open a new line and type def or hit Ctrl-x. Sometimes I get a complete implementation, e.g.

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.
def dfs(graph, start):
    visited = set()
    stack = [start]
    while stack:
        v = stack.pop()
        if v not in visited:
            visited.add(v)
            stack.extend(graph[v] - visited)
    return visited

But other times, on exactly the same line, I get either a partial implementation, e.g.

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.
def dfs(graph, start):
    visited = set()
    stack = [start]

Or just a function signature:

# function implementing depth first search
# over a graph represented as a dict.
# Include an informative docstring.
def dfs(graph, start):
    ...

The weird thing is it's different every time. The helix-gpt logs don't contain anything about API errors or request timeouts.

My current guesses are a) the Copilot API is missing one or more parameters, e.g. the language type, or b) there's some post-processing going on that's truncating the responses.

I'll do some testing with Python to try reproduce. There is some post-processing going on, so I have a feeling that's it.

And the empty content I think is to do with the didOpen event not firing, and without changing anything in the document but triggering a completion/action, it doesn't have the current content.