Make endpoint url for Ollama configurable (#355)

This commit is contained in:
senovr
2024-07-02 20:59:55 +03:00
committed by GitHub
parent fef25a2d06
commit 18f52772b3
5 changed files with 89 additions and 4 deletions
+6 -1
View File
@@ -10,10 +10,15 @@ const config = getConfig();
export class OllamaAi implements AiEngine {
private model = "mistral"; // as default model of Ollama
private url = "http://localhost:11434/api/chat"; // default URL of Ollama API
setModel(model: string) {
this.model = model ?? config?.OCO_MODEL ?? 'mistral';
}
setUrl(url: string) {
this.url = url ?? config?.OCO_OLLAMA_API_URL ?? 'http://localhost:11434/api/chat';
}
async generateCommitMessage(
messages: Array<ChatCompletionRequestMessage>
): Promise<string | undefined> {
@@ -22,7 +27,7 @@ export class OllamaAi implements AiEngine {
//console.log(messages);
//process.exit()
const url = 'http://localhost:11434/api/chat';
const url = this.url;
const p = {
model,
messages,