From bec57f25dba8ea435b2c28b7251446e827007c06 Mon Sep 17 00:00:00 2001 From: Knut Leborg Date: Mon, 14 Oct 2024 08:57:39 +0200 Subject: [PATCH] describe issue and workaround for #64 including quick mentions including a reference to details to relevant README sections, as well as default sublime-settings template --- README.md | 68 +++++++++++++++++++++++++++++++++-------- openAI.sublime-settings | 2 ++ 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f07b722..d72172c 100644 --- a/README.md +++ b/README.md @@ -134,15 +134,15 @@ Phantom is the overlay UI placed inline in the editor view (see the picture belo ### Open Source models support (llama.cpp, ollama) 1. Replace `"url"` setting of a given model to point to whatever host you're server running on (e.g.`"http://localhost:8080"`). -2. [Optional] Provide a `"token"` if your provider required one. +2. ~~[Optional] Provide a `"token"` if your provider required one.~~ **Temporarily mandatory, see warning below.** 3. Tweak `"chat_model"` to a model of your choice and you're set. +> [!IMPORTANT] +> Due to a known issue, a token value of 10 or more characters is currently required even for unsecured servers. [More details here.](#workaround-for-64) + > [!NOTE] > You can set both `url` and `token` either global or on per assistant instance basis, thus being capable to freely switching between closed source and open sourced models within a single session. -> [!TIP] -> In some cases, even if your provider does not require authentication, you may receive an error message stating _"No API token provided, you have to set the OpenAI token into the settings to make things work."_ To resolve this, simply set your `token` value to any string with 10 characters or more. - ## Settings The OpenAI Completion plugin has a settings file where you can set your OpenAI API key. This is required for the most of providers to work. To set your API key, open the settings within `Preferences` -> `Package Settings` -> `OpenAI` -> `Settings` and paste your API key in the token property, as follows: @@ -153,6 +153,9 @@ The OpenAI Completion plugin has a settings file where you can set your OpenAI A } ``` +> [!IMPORTANT] +> Due to a known issue, a token value of 10 or more characters is currently required even for unsecured servers. [More details here.](#workaround-for-64) + ### Advertisement disabling To disable advertisement you have to add `"advertisement": false` line into an assistant setting where you wish it to be disabled. @@ -191,18 +194,57 @@ You can setup it up by overriding the proxy property in the `OpenAI completion` ## Known bugs -### "No API token provided" even if server does not require authentication - -There is currently a known issue which will trigger this error message even when connecting to an unsecured server: +### Workaround for [#64](/issues/64) -> [!WARNING] -> **Error:** "No API token provided, you have to set the OpenAI token into the settings to make things work." +> [!CAUTION] +> There is currently a known issue which will trigger the following error even when connecting to an unsecured server. +> +> **"No API token provided, you have to set the OpenAI token into the settings to make things work."** -It is highly recommended to enable authentication in most cases, but especially when self-hosting models on your local this can be inconvenient. -In such cases, there is a simple workaround which should allow you to avoid this error until a permanent solution can be released. +It is highly recommended to enable authentication in most cases, but especially when self-hosting models on your local system this can be inconvenient. > [!TIP] -> **Solution:** Simply ensure your assistant configuration includes a `token` value longer than 10 characters. It can be anything, since the server doesn't care, but must be present to prevent a validation error. +> Use the following workaround to avoid this error until a permanent solution can be released. +> +> **Simply ensure your assistant configuration defines a `"token",` value longer than 10 characters. It can be anything, since the server doesn't care, but must be present to prevent a validation error.** + +#### Sample config + +```json +{ + "url": "http://localhost:1234", // Url to your unsecured server + "token": "xxxxxxxxxx", // Token can be anything so long as it is at least 10 characters long + "assistants": [ + { + // Inherits token from top-level, no error + "name": "Code assistant", + "prompt_mode": "panel", + "chat_model": "codestral-22b-v0.1", + "assistant_role": "You are a software developer, you develop software programs and applications using programming languages and development tools.", + "temperature": 1, + "max_tokens": 2048, + }, + { + // Overrides top-level token incorrectly, will get error + "name": "Lazy Assistant", + "token": "", + "prompt_mode": "phantom", + "chat_model": "llama-3-8b-instruct-32k-v0.1", + "assistant_role": "You are very unhelpful.", + "max_tokens": 4000, + }, + { + // Overrides top-level token correctly, no error + "name": "General Assistant", + "token": "abcdefghijklmn", + "prompt_mode": "phantom", + "chat_model": "llama-3-8b-instruct-32k-v0.1", + "assistant_role": "You are very helpful.", + "max_tokens": 4000, + }, + ] +} +``` ## Disclaimers @@ -215,4 +257,4 @@ In such cases, there is a simple workaround which should allow you to avoid this [stars]: https://github.com/yaroslavyaroslav/OpenAI-sublime-text/stargazers [img-stars]: static/media/star-on-github.svg [downloads]: https://packagecontrol.io/packages/OpenAI%20completion -[img-downloads]: https://img.shields.io/packagecontrol/dt/OpenAI%2520completion.svg \ No newline at end of file +[img-downloads]: https://img.shields.io/packagecontrol/dt/OpenAI%2520completion.svg diff --git a/openAI.sublime-settings b/openAI.sublime-settings index 6d85e36..e40c7b9 100644 --- a/openAI.sublime-settings +++ b/openAI.sublime-settings @@ -6,6 +6,8 @@ "url": "https://api.openai.com", // Your openAI token + // IMPORTANT: Due to a known issue, a token value of 10 or more characters is currently required even for unsecured servers. + // See this comment for a workaround: https://github.com/yaroslavyaroslav/OpenAI-sublime-text/issues/64#issuecomment-2410170986 "token": "", // Apply Sublime Text markdown syntax highlight to OpenAI completion output panel text.