feat: separate Ollama text/image/think models + add YouTube downloader
Support OLLAMA_IMAGE_MODEL and new OLLAMA_THINK_MODEL (both default to OLLAMA_MODEL) Add /ollamathink command; validate thinking capability; disable image-analysis flow in think mode Make /ollama-get-model show Text/Image/Think blocks only when models differ Add /ytdl (/youtube) command + auto-detect YouTube URLs in messages Cache downloaded videos to data/video and schedule daily cleanup Move photo storage from data/temp to data/photo; improve env boolean parsing via ifTrue Update deps (youtubei.js, puppeteer*) and TS config (allowJs, allowSyntheticDefaultImports)
This commit is contained in:
@@ -11,14 +11,48 @@ export class OllamaGetModel extends ChatCommand {
|
||||
|
||||
async execute(msg: Message): Promise<void> {
|
||||
try {
|
||||
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 model = Environment.OLLAMA_MODEL;
|
||||
const imageModel = Environment.OLLAMA_IMAGE_MODEL;
|
||||
const thinkModel = Environment.OLLAMA_THINK_MODEL;
|
||||
|
||||
const promises: (Promise<ShowResponse | null> | null)[] = [this.loadModelInfo()];
|
||||
|
||||
if (imageModel && imageModel !== model) {
|
||||
promises.push(this.loadImageModelInfo());
|
||||
} else {
|
||||
promises.push(null);
|
||||
}
|
||||
|
||||
if (thinkModel && thinkModel !== model) {
|
||||
promises.push(this.loadThinkModelInfo());
|
||||
} else {
|
||||
promises.push(null);
|
||||
}
|
||||
|
||||
const infos = await Promise.all(promises);
|
||||
|
||||
let modelInfo = infos[0];
|
||||
const modelText = "```Text\n" + this.getModelText(model, modelInfo) + "```";
|
||||
|
||||
modelInfo = infos[1];
|
||||
const imageModelText = modelInfo ?
|
||||
"```Image\n" + this.getModelText(imageModel, modelInfo) + "```" : null;
|
||||
|
||||
modelInfo = infos[2];
|
||||
const thinkModelText = modelInfo ?
|
||||
"```Think\n" + this.getModelText(thinkModel, modelInfo) + "```" : null;
|
||||
|
||||
const modelInfos = [modelText];
|
||||
if (imageModelText) {
|
||||
modelInfos.push(imageModelText);
|
||||
}
|
||||
if (thinkModelText) {
|
||||
modelInfos.push(thinkModelText);
|
||||
}
|
||||
|
||||
await replyToMessage({
|
||||
message: msg,
|
||||
text: modelText + "\n\n" + imageModelText,
|
||||
text: modelInfos.join("\n\n"),
|
||||
parse_mode: "Markdown"
|
||||
}).catch(logError);
|
||||
|
||||
@@ -44,4 +78,8 @@ export class OllamaGetModel extends ChatCommand {
|
||||
async loadImageModelInfo(): Promise<ShowResponse | null> {
|
||||
return ollama.show({model: Environment.OLLAMA_IMAGE_MODEL});
|
||||
}
|
||||
|
||||
async loadThinkModelInfo(): Promise<ShowResponse | null> {
|
||||
return ollama.show({model: Environment.OLLAMA_THINK_MODEL});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user