Skip to content

Commit b465ea2

Browse files
committed
feat: delegate the prompt formatting to ollama
1 parent d4b65d6 commit b465ea2

File tree

5 files changed

+2
-102
lines changed

5 files changed

+2
-102
lines changed

package.json

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,6 @@
8383
},
8484
"inference.model": {
8585
"type": "string",
86-
"enum": [
87-
"stable-code:3b-code-q4_0",
88-
"codellama:7b-code-q4_K_S",
89-
"codellama:7b-code-q4_K_M",
90-
"codellama:7b-code-q6_K",
91-
"codellama:7b-code-fp16",
92-
"codellama:13b-code-q4_K_S",
93-
"codellama:13b-code-q4_K_M",
94-
"codellama:13b-code-q6_K",
95-
"codellama:13b-code-fp16",
96-
"codellama:34b-code-q4_K_S",
97-
"codellama:34b-code-q4_K_M",
98-
"codellama:34b-code-q6_K",
99-
"codellama:70b-code-q4_K_S",
100-
"codellama:70b-code-q4_K_M",
101-
"codellama:70b-code-q6_K",
102-
"codellama:70b-code-fp16",
103-
"deepseek-coder:1.3b-base-q4_0",
104-
"deepseek-coder:1.3b-base-q4_1",
105-
"deepseek-coder:1.3b-base-q8_0",
106-
"deepseek-coder:6.7b-base-q4_K_S",
107-
"deepseek-coder:6.7b-base-q4_K_M",
108-
"deepseek-coder:6.7b-base-q5_K_S",
109-
"deepseek-coder:6.7b-base-q5_K_M",
110-
"deepseek-coder:6.7b-base-q8_0",
111-
"deepseek-coder:6.7b-base-fp16",
112-
"deepseek-coder:33b-base-q4_K_S",
113-
"deepseek-coder:33b-base-q4_K_M",
114-
"deepseek-coder:33b-base-fp16",
115-
"custom"
116-
],
11786
"default": "stable-code:3b-code-q4_0",
11887
"description": "Inference model to use",
11988
"order": 2
@@ -124,23 +93,6 @@
12493
"description": "Temperature of the model. Increasing the temperature will make the model answer more creatively.",
12594
"order": 3
12695
},
127-
"inference.custom.model": {
128-
"type": "string",
129-
"default": "",
130-
"description": "Custom model name",
131-
"order": 4
132-
},
133-
"inference.custom.format": {
134-
"type": "string",
135-
"enum": [
136-
"stable-code",
137-
"codellama",
138-
"deepseek"
139-
],
140-
"default": "stable-code",
141-
"description": "Custom model prompt format",
142-
"order": 5
143-
},
14496
"inference.maxLines": {
14597
"type": "number",
14698
"default": 16,

src/config.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import vscode from 'vscode';
2-
import { ModelFormat } from './prompts/processors/models';
32

43
class Config {
54

@@ -24,17 +23,6 @@ class Config {
2423

2524
// Load model
2625
let modelName = config.get('model') as string;
27-
let modelFormat: ModelFormat = 'codellama';
28-
if (modelName === 'custom') {
29-
modelName = config.get('custom.model') as string;
30-
modelFormat = config.get('cutom.format') as ModelFormat;
31-
} else {
32-
if (modelName.startsWith('deepseek-coder')) {
33-
modelFormat = 'deepseek';
34-
} else if (modelName.startsWith('stable-code')) {
35-
modelFormat = 'stable-code';
36-
}
37-
}
3826

3927
let delay = config.get('delay') as number;
4028

@@ -45,7 +33,6 @@ class Config {
4533
maxTokens,
4634
temperature,
4735
modelName,
48-
modelFormat,
4936
delay
5037
};
5138
}

src/prompts/autocomplete.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { ollamaTokenGenerator } from '../modules/ollamaTokenGenerator';
22
import { countSymbol } from '../modules/text';
33
import { info } from '../modules/log';
4-
import { ModelFormat, adaptPrompt } from './processors/models';
54

65
export async function autocomplete(args: {
76
endpoint: string,
87
bearerToken: string,
98
model: string,
10-
format: ModelFormat,
119
prefix: string,
1210
suffix: string,
1311
maxLines: number,
@@ -16,15 +14,13 @@ export async function autocomplete(args: {
1614
canceled?: () => boolean,
1715
}): Promise<string> {
1816

19-
let prompt = adaptPrompt({ prefix: args.prefix, suffix: args.suffix, format: args.format });
20-
2117
// Calculate arguments
2218
let data = {
2319
model: args.model,
24-
prompt: prompt.prompt,
20+
prompt: args.prefix,
21+
suffix: args.suffix,
2522
raw: true,
2623
options: {
27-
stop: prompt.stop,
2824
num_predict: args.maxTokens,
2925
temperature: args.temperature
3026
}

src/prompts/processors/models.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/prompts/provider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ export class PromptProvider implements vscode.InlineCompletionItemProvider {
163163
endpoint: inferenceConfig.endpoint,
164164
bearerToken: inferenceConfig.bearerToken,
165165
model: inferenceConfig.modelName,
166-
format: inferenceConfig.modelFormat,
167166
maxLines: inferenceConfig.maxLines,
168167
maxTokens: inferenceConfig.maxTokens,
169168
temperature: inferenceConfig.temperature,

0 commit comments

Comments
 (0)