separate ollama text & image models
This commit is contained in:
@@ -57,7 +57,7 @@ export class OllamaChat extends ChatCommand {
|
||||
|
||||
if (imagesCount) {
|
||||
try {
|
||||
const modelInfo = await chatCommands.find(c => c instanceof OllamaGetModel).loadModelInfo();
|
||||
const modelInfo = await chatCommands.find(c => c instanceof OllamaGetModel).loadImageModelInfo();
|
||||
if (modelInfo) {
|
||||
const caps = modelInfo.capabilities || [];
|
||||
if (!caps.includes("vision")) {
|
||||
@@ -84,7 +84,7 @@ export class OllamaChat extends ChatCommand {
|
||||
});
|
||||
|
||||
const stream = await ollama.chat({
|
||||
model: Environment.OLLAMA_MODEL,
|
||||
model: imagesCount ? Environment.OLLAMA_IMAGE_MODEL : Environment.OLLAMA_MODEL,
|
||||
stream: true,
|
||||
think: false,
|
||||
messages: chatMessages,
|
||||
|
||||
@@ -11,25 +11,37 @@ export class OllamaGetModel extends ChatCommand {
|
||||
|
||||
async execute(msg: Message): Promise<void> {
|
||||
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) {
|
||||
logError(e);
|
||||
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> {
|
||||
return ollama.show({model: Environment.OLLAMA_MODEL});
|
||||
}
|
||||
|
||||
async loadImageModelInfo(): Promise<ShowResponse | null> {
|
||||
return ollama.show({model: Environment.OLLAMA_IMAGE_MODEL});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user