Skip to content

Commit

Permalink
feat: update llm-ls to 0.5.3 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
McPatate committed May 24, 2024
1 parent c9e1faf commit 66a6ce6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 40 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
FETCH_DEPTH: 0 # pull in the tags for the version string
LLM_LS_VERSION: 0.5.2
LLM_LS_VERSION: 0.5.3

jobs:
package:
Expand Down Expand Up @@ -41,16 +41,16 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- uses: robinraju/release-downloader@v1.8
- uses: robinraju/release-downloader@v1.10
with:
repository: "huggingface/llm-ls"
tag: ${{ env.LLM_LS_VERSION }}
Expand All @@ -71,7 +71,7 @@ jobs:
run: npx vsce package -o "./llm-ls-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}

- name: Upload artifacts
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: pkg-${{ matrix.target }}
path: ./llm-ls-${{ matrix.code-target }}.vsix
Expand All @@ -82,14 +82,14 @@ jobs:
needs: ["package"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Install Nodejs
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- run: 'echo "HEAD_SHA: $HEAD_SHA"'
Expand All @@ -98,37 +98,37 @@ jobs:
env:
BRANCH: ${{ github.ref_name }}
id: split
run: echo "::set-output name=tag::${BRANCH##*/}"
run: echo "tag=${BRANCH##*/}" >> $GITHUB_OUTPUT

- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-aarch64-apple-darwin
path: pkg
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-apple-darwin
path: pkg
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-unknown-linux-gnu
path: pkg
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-unknown-linux-musl
path: pkg
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-aarch64-unknown-linux-gnu
path: pkg
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-arm-unknown-linux-gnueabihf
path: pkg
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: pkg-x86_64-pc-windows-msvc
path: pkg
# - uses: actions/download-artifact@v1
# - uses: actions/download-artifact@v4
# with:
# name: pkg-aarch64-pc-windows-msvc
# path: pkg
Expand Down
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,8 @@ const data = { inputs, ...configuration.requestBody };
const model = configuration.modelId;
let endpoint;
switch(configuration.backend) {
case "huggingface":
let url;
if (configuration.url === null) {
url = "https://api-inference.huggingface.co";
} else {
url = configuration.url;
}
endpoint = `${url}/models/${model}`;
break;
case "ollama":
case "openai":
case "tgi":
endpoint = configuration.url;
break;
// cf URL construction
let endpoint = build_url(configuration);
}

const res = await fetch(endpoint, {
Expand All @@ -110,6 +98,15 @@ const json = await res.json() as { generated_text: string };

Note that the example above is a simplified version to explain what is happening under the hood.

#### URL construction

The endpoint URL that is queried to fetch suggestions is build the following way:
- depending on the backend, it will try to append the correct path to the base URL located in the configuration (e.g. `{url}/v1/completions` for the `openai` backend)
- if no URL is set for the `huggingface` backend, it will automatically use the default URL
- it will error for other backends as there is no sensible default URL
- if you do set the **correct** path at the end of the URL it will not add it a second time as it checks if it is already present
- there is an option to disable this behavior: `llm.disableUrlPathCompletion`

### Suggestion behavior

You can tune the way the suggestions behave:
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "huggingface-vscode",
"displayName": "llm-vscode",
"description": "LLM powered development for VS Code",
"version": "0.2.0",
"version": "0.2.1",
"publisher": "HuggingFace",
"icon": "small_logo.png",
"engines": {
Expand Down Expand Up @@ -219,6 +219,11 @@
"pattern": "**"
},
"description": "Filter documents to enable suggestions for"
},
"llm.disableUrlPathCompletion": {
"type": "boolean",
"default": false,
"description": "When setting `llm.url`, llm-ls will try to append the correct path to your URL if it doesn't end with such a path, e.g. for an OpenAI backend if it doesn't end with `/v1/completions`. Set this to `true` to disable this behavior."
}
}
}
Expand Down Expand Up @@ -260,4 +265,4 @@
"ovsx": "^0.8.3",
"typescript": "^5.3.3"
}
}
}
14 changes: 8 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ let ctx: vscode.ExtensionContext;
let loadingIndicator: vscode.StatusBarItem;

function createLoadingIndicator(): vscode.StatusBarItem {
let li = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10)
li.text = "$(loading~spin) LLM"
li.tooltip = "Generating completions..."
return li
let li = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
li.text = "$(loading~spin) LLM";
li.tooltip = "Generating completions...";
return li;
}

export async function activate(context: vscode.ExtensionContext) {
Expand All @@ -48,6 +48,7 @@ export async function activate(context: vscode.ExtensionContext) {
if (command.startsWith("~/")) {
command = homedir() + command.slice("~".length);
}

const serverOptions: ServerOptions = {
run: {
command, transport: TransportKind.stdio, options: {
Expand Down Expand Up @@ -81,7 +82,7 @@ export async function activate(context: vscode.ExtensionContext) {
clientOptions
);

loadingIndicator = createLoadingIndicator()
loadingIndicator = createLoadingIndicator();

await client.start();

Expand Down Expand Up @@ -173,6 +174,7 @@ export async function activate(context: vscode.ExtensionContext) {
tlsSkipVerifyInsecure: config.get("tlsSkipVerifyInsecure") as boolean,
ide: "vscode",
tokenizerConfig,
disableUrlPathCompletion: config.get("disableUrlPathCompletion") as boolean,
};
try {
loadingIndicator.show()
Expand Down Expand Up @@ -345,4 +347,4 @@ async function delay(milliseconds: number, token: vscode.CancellationToken): Pro
resolve(token.isCancellationRequested)
}, milliseconds);
});
}
}

0 comments on commit 66a6ce6

Please sign in to comment.