mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 22:03:45 +00:00
fix: use consistent model comparison including provider
This commit is contained in:
parent
64e7c80c7e
commit
a7efe3d4c1
5 changed files with 25 additions and 17 deletions
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import type { Agent, AgentEvent, AgentState, AppMessage, Attachment, ThinkingLevel } from "@mariozechner/pi-agent-core";
|
||||
import type { AssistantMessage, Message, Model, TextContent } from "@mariozechner/pi-ai";
|
||||
import { isContextOverflow, supportsXhigh } from "@mariozechner/pi-ai";
|
||||
import { isContextOverflow, modelsAreEqual, supportsXhigh } from "@mariozechner/pi-ai";
|
||||
import { getModelsPath } from "../config.js";
|
||||
import { type BashResult, executeBash as executeBashCommand } from "./bash-executor.js";
|
||||
import { calculateContextTokens, compact, prepareCompaction, shouldCompact } from "./compaction.js";
|
||||
|
|
@ -596,9 +596,7 @@ export class AgentSession {
|
|||
if (this._scopedModels.length <= 1) return null;
|
||||
|
||||
const currentModel = this.model;
|
||||
let currentIndex = this._scopedModels.findIndex(
|
||||
(sm) => sm.model.id === currentModel?.id && sm.model.provider === currentModel?.provider,
|
||||
);
|
||||
let currentIndex = this._scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
|
||||
|
||||
if (currentIndex === -1) currentIndex = 0;
|
||||
const len = this._scopedModels.length;
|
||||
|
|
@ -627,9 +625,7 @@ export class AgentSession {
|
|||
if (availableModels.length <= 1) return null;
|
||||
|
||||
const currentModel = this.model;
|
||||
let currentIndex = availableModels.findIndex(
|
||||
(m) => m.id === currentModel?.id && m.provider === currentModel?.provider,
|
||||
);
|
||||
let currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
|
||||
|
||||
if (currentIndex === -1) currentIndex = 0;
|
||||
const len = availableModels.length;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import type { ThinkingLevel } from "@mariozechner/pi-agent-core";
|
||||
import type { Api, KnownProvider, Model } from "@mariozechner/pi-ai";
|
||||
import { type Api, type KnownProvider, type Model, modelsAreEqual } from "@mariozechner/pi-ai";
|
||||
import chalk from "chalk";
|
||||
import { isValidThinkingLevel } from "../cli/args.js";
|
||||
import type { ModelRegistry } from "./model-registry.js";
|
||||
|
|
@ -184,7 +184,7 @@ export async function resolveModelScope(patterns: string[], modelRegistry: Model
|
|||
}
|
||||
|
||||
// Avoid duplicates
|
||||
if (!scopedModels.find((sm) => sm.model.id === model.id && sm.model.provider === model.provider)) {
|
||||
if (!scopedModels.find((sm) => modelsAreEqual(sm.model, model))) {
|
||||
scopedModels.push({ model, thinkingLevel });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Model } from "@mariozechner/pi-ai";
|
||||
import { type Model, modelsAreEqual } from "@mariozechner/pi-ai";
|
||||
import {
|
||||
Container,
|
||||
Input,
|
||||
|
|
@ -143,8 +143,8 @@ export class ModelSelectorComponent extends Container {
|
|||
|
||||
// Sort: current model first, then by provider
|
||||
models.sort((a, b) => {
|
||||
const aIsCurrent = this.currentModel?.id === a.model.id && this.currentModel?.provider === a.provider;
|
||||
const bIsCurrent = this.currentModel?.id === b.model.id && this.currentModel?.provider === b.provider;
|
||||
const aIsCurrent = modelsAreEqual(this.currentModel, a.model);
|
||||
const bIsCurrent = modelsAreEqual(this.currentModel, b.model);
|
||||
if (aIsCurrent && !bIsCurrent) return -1;
|
||||
if (!aIsCurrent && bIsCurrent) return 1;
|
||||
return a.provider.localeCompare(b.provider);
|
||||
|
|
@ -176,7 +176,7 @@ export class ModelSelectorComponent extends Container {
|
|||
if (!item) continue;
|
||||
|
||||
const isSelected = i === this.selectedIndex;
|
||||
const isCurrent = this.currentModel?.id === item.model.id;
|
||||
const isCurrent = modelsAreEqual(this.currentModel, item.model);
|
||||
|
||||
let line = "";
|
||||
if (isSelected) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue