Skip to content

Commit 6d8b363

Browse files
committed
add quick pick types
1 parent 6a058cf commit 6d8b363

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/chat/aiConfig.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
import Configuration from "../configuration";
2+
import { Config } from '../config';
3+
import * as vscode from 'vscode';
4+
import { stat } from 'fs/promises';
5+
import ollama, { ListResponse } from "ollama";
6+
import { AiProvider, LLMConfig } from "./types";
27

3-
export type AiProvider = "Ollama"|"GitHub Copilot";
8+
9+
export class AiModelQuickPick implements vscode.QuickPickItem {
10+
label: string // model title
11+
description?: string; // model details
12+
detail?: string; // ai provider
13+
14+
constructor(object: LLMConfig) {
15+
this.label = object.model;
16+
this.description = object.provider;
17+
}
18+
}
19+
20+
export async function getOllamaModels() {
21+
const ollamaModels: ListResponse = await ollama.list();
22+
const formattedModels: LLMConfig[] = ollamaModels.models.map((model) => {
23+
return {
24+
model: model.name, // Assuming 'id' is the correct property for the model identifier
25+
provider: "Ollama" as AiProvider,
26+
};
27+
});
28+
29+
return formattedModels;
30+
}
431

532
export class AiConfig {
33+
634
static getProvider(): AiProvider {
735
return Configuration.get<AiProvider>(`ai.provider`);
836
}

src/chat/send.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
LanguageModelChatResponse,
88
} from "vscode";
99
import Configuration from "../configuration";
10-
import { AiConfig, AiProvider } from "./aiConfig";
10+
import { AiConfig } from "./aiConfig";
11+
import { AiProvider } from "./types";
1112

1213
export async function chatRequest(
1314
provider: AiProvider,

src/chat/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface LLMConfig {
2+
model: string;
3+
provider: AiProvider
4+
}
5+
6+
export type AiProvider = "Ollama"|"GitHub Copilot";

0 commit comments

Comments
 (0)