feat: add vision_model param to profile

This commit is contained in:
gmuffiness 2025-02-09 21:57:45 +09:00
parent a22f9d439f
commit 2b5923f98f
3 changed files with 12 additions and 3 deletions

View file

@ -37,7 +37,7 @@ export class VisionInterpreter {
filename = await camera.capture();
}
if (!this.allow_vision || !this.agent.prompter.chat_model.sendVisionRequest) {
if (!this.allow_vision || !this.agent.prompter.vision_model.sendVisionRequest) {
log(this.agent.bot, "Vision is disabled. Using text-based environment description instead.");
log(this.agent.bot, this._nearbyBlocks());
} else {
@ -54,7 +54,7 @@ export class VisionInterpreter {
let filename = await camera.capture();
if (!this.allow_vision || !this.agent.prompter.chat_model.sendVisionRequest) {
if (!this.allow_vision || !this.agent.prompter.vision_model.sendVisionRequest) {
log(this.agent.bot, "Vision is disabled. Using text-based environment description instead.");
log(this.agent.bot, this._nearbyBlocks());
} else {
@ -70,7 +70,7 @@ export class VisionInterpreter {
const bot = this.agent.bot;
const imageBuffer = fs.readFileSync(`${this.fp}/${filename}.jpg`);
const messages = this.agent.history.getHistory();
res = await this.agent.prompter.chat_model.sendVisionRequest(messages, prompt, imageBuffer);
res = await this.agent.prompter.vision_model.sendVisionRequest(messages, prompt, imageBuffer);
log(bot, res);
} catch (error) {
log(this.agent.bot, `Error analyzing image: ${error.message}`);

View file

@ -47,6 +47,7 @@ export class Mistral {
];
messages.push(...strictFormat(turns));
console.log('Awaiting mistral api response...')
const response = await this.#client.chat.complete({
model,
messages,

View file

@ -65,6 +65,14 @@ export class Prompter {
this.code_model = this.chat_model;
}
if (this.profile.vision_model) {
let vision_model_profile = this._selectAPI(this.profile.vision_model);
this.vision_model = this._createModel(vision_model_profile);
}
else {
this.vision_model = this.chat_model;
}
let embedding = this.profile.embedding;
if (embedding === undefined) {
if (chat_model_profile.api !== 'ollama')