Skip to content

Commit

Permalink
feat: stable-code support, cancel download only for specific model
Browse files Browse the repository at this point in the history
  • Loading branch information
ex3ndr committed Jan 16, 2024
1 parent 241d47b commit 38a77bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"inference.model": {
"type": "string",
"enum": [
"stable-code:3b-code-q4_0",
"codellama:7b-code-q4_K_S",
"codellama:7b-code-q4_K_M",
"codellama:7b-code-q6_K",
Expand All @@ -70,7 +71,7 @@
"deepseek-coder:33b-base-fp16",
"custom"
],
"default": "deepseek-coder:1.3b-base-q4_1",
"default": "stable-code:3b-code-q4_0",
"description": "Inference model to use",
"order": 2
},
Expand All @@ -89,6 +90,7 @@
"inference.custom.format": {
"type": "string",
"enum": [
"stable-code",
"codellama",
"deepseek"
],
Expand Down
7 changes: 5 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import vscode from 'vscode';
import { ModelFormat } from './prompts/processors/models';

class Config {

Expand All @@ -22,13 +23,15 @@ class Config {

// Load model
let modelName = config.get('model') as string;
let modelFormat: 'codellama' | 'deepseek' = 'codellama';
let modelFormat: ModelFormat = 'codellama';
if (modelName === 'custom') {
modelName = config.get('custom.model') as string;
modelFormat = config.get('cutom.format') as 'codellama' | 'deepseek';
modelFormat = config.get('cutom.format') as ModelFormat;
} else {
if (modelName.startsWith('deepseek-coder')) {
modelFormat = 'deepseek';
} else if (modelName.startsWith('stable-code')) {
modelFormat = 'stable-code';
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/prompts/processors/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ModelFormat = 'codellama' | 'deepseek';
export type ModelFormat = 'codellama' | 'deepseek' | 'stable-code';

export function adaptPrompt(args: { format: ModelFormat, prefix: string, suffix: string }): { prompt: string, stop: string[] } {

Expand All @@ -18,6 +18,14 @@ export function adaptPrompt(args: { format: ModelFormat, prefix: string, suffix:
};
}

// Stable code FIM
if (args.format === 'stable-code') {
return {
prompt: `<fim_prefix>${args.prefix}<fim_suffix>${args.suffix}<fim_middle>`,
stop: [`<|endoftext|>`]
};
}

// Codellama FIM
return {
prompt: `<PRE> ${args.prefix} <SUF>${args.suffix} <MID>`,
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class PromptProvider implements vscode.InlineCompletionItemProvider {
if (!modelExists) {

// Check if user asked to ignore download
if (this.context.globalState.get('llama-coder-download-ignored')) {
if (this.context.globalState.get('llama-coder-download-ignored') === inferenceConfig.modelName) {
info(`Ingoring since user asked to ignore download.`);
return;
}
Expand All @@ -100,7 +100,7 @@ export class PromptProvider implements vscode.InlineCompletionItemProvider {
let download = await vscode.window.showInformationMessage(`Model ${inferenceConfig.modelName} is not downloaded. Do you want to download it? Answering "No" would require you to manually download model.`, 'Yes', 'No');
if (download === 'No') {
info(`Ingoring since user asked to ignore download.`);
this.context.globalState.update('llama-coder-download-ignored', true);
this.context.globalState.update('llama-coder-download-ignored', inferenceConfig.modelName);
return;
}

Expand Down

0 comments on commit 38a77bb

Please sign in to comment.