separate ollama text & image models

This commit is contained in:
2026-01-31 17:54:45 +03:00
parent 9e30086af2
commit 23052fae0f
3 changed files with 27 additions and 13 deletions
+2 -2
View File
@@ -57,7 +57,7 @@ export class OllamaChat extends ChatCommand {
if (imagesCount) { if (imagesCount) {
try { try {
const modelInfo = await chatCommands.find(c => c instanceof OllamaGetModel).loadModelInfo(); const modelInfo = await chatCommands.find(c => c instanceof OllamaGetModel).loadImageModelInfo();
if (modelInfo) { if (modelInfo) {
const caps = modelInfo.capabilities || []; const caps = modelInfo.capabilities || [];
if (!caps.includes("vision")) { if (!caps.includes("vision")) {
@@ -84,7 +84,7 @@ export class OllamaChat extends ChatCommand {
}); });
const stream = await ollama.chat({ const stream = await ollama.chat({
model: Environment.OLLAMA_MODEL, model: imagesCount ? Environment.OLLAMA_IMAGE_MODEL : Environment.OLLAMA_MODEL,
stream: true, stream: true,
think: false, think: false,
messages: chatMessages, messages: chatMessages,
+22 -10
View File
@@ -11,25 +11,37 @@ export class OllamaGetModel extends ChatCommand {
async execute(msg: Message): Promise<void> { async execute(msg: Message): Promise<void> {
try { try {
const showResponse = await this.loadModelInfo(); let modelInfo = await this.loadModelInfo();
const modelText = "```Text\n" + this.getModelText(Environment.OLLAMA_MODEL, modelInfo) + "```";
modelInfo = await this.loadImageModelInfo();
const imageModelText = "```Image\n" + this.getModelText(Environment.OLLAMA_IMAGE_MODEL, modelInfo) + "```";
const caps = showResponse.capabilities; await replyToMessage({
message: msg,
text: modelText + "\n\n" + imageModelText,
parse_mode: "Markdown"
}).catch(logError);
const text = "```Ollama\n" +
`model: ${Environment.OLLAMA_MODEL}\n\n` +
`vision: ${boolToEmoji(caps.includes("vision"))}\n` +
`thinking: ${boolToEmoji(caps.includes("thinking"))}\n` +
`tools: ${boolToEmoji(caps.includes("tools"))}`
+ "```";
await replyToMessage({message: msg, text: text, parse_mode: "Markdown"}).catch(logError);
} catch (e) { } catch (e) {
logError(e); logError(e);
await replyToMessage({message: msg, text: e.toString()}).catch(logError); await replyToMessage({message: msg, text: e.toString()}).catch(logError);
} }
} }
private getModelText(model: string, info: ShowResponse): string {
const caps = info.capabilities;
return `model: ${model}\n\n` +
`vision: ${boolToEmoji(caps.includes("vision"))}\n` +
`thinking: ${boolToEmoji(caps.includes("thinking"))}\n` +
`tools: ${boolToEmoji(caps.includes("tools"))}`;
}
async loadModelInfo(): Promise<ShowResponse | null> { async loadModelInfo(): Promise<ShowResponse | null> {
return ollama.show({model: Environment.OLLAMA_MODEL}); return ollama.show({model: Environment.OLLAMA_MODEL});
} }
async loadImageModelInfo(): Promise<ShowResponse | null> {
return ollama.show({model: Environment.OLLAMA_IMAGE_MODEL});
}
} }
+3 -1
View File
@@ -27,6 +27,7 @@ export class Environment {
static OLLAMA_ADDRESS?: string; static OLLAMA_ADDRESS?: string;
static OLLAMA_MODEL?: string; static OLLAMA_MODEL?: string;
static OLLAMA_IMAGE_MODEL?: string;
static OLLAMA_API_KEY?: string; static OLLAMA_API_KEY?: string;
static GEMINI_API_KEY?: string; static GEMINI_API_KEY?: string;
@@ -61,7 +62,8 @@ export class Environment {
Environment.SYSTEM_PROMPT = process.env.SYSTEM_PROMPT?.trim(); Environment.SYSTEM_PROMPT = process.env.SYSTEM_PROMPT?.trim();
Environment.OLLAMA_ADDRESS = process.env.OLLAMA_ADDRESS; Environment.OLLAMA_ADDRESS = process.env.OLLAMA_ADDRESS;
Environment.OLLAMA_MODEL = process.env.OLLAMA_MODEL; Environment.OLLAMA_MODEL = process.env.OLLAMA_MODEL || "gemma3:4b";
Environment.OLLAMA_IMAGE_MODEL = process.env.OLLAMA_IMAGE_MODEL || "gemma3:4b";
Environment.OLLAMA_API_KEY = process.env.OLLAMA_API_KEY; Environment.OLLAMA_API_KEY = process.env.OLLAMA_API_KEY;
Environment.GEMINI_API_KEY = process.env.GEMINI_API_KEY; Environment.GEMINI_API_KEY = process.env.GEMINI_API_KEY;