mirror of
https://github.com/basketikun/infinite-canvas.git
synced 2026-07-24 15:24:06 +08:00
feat(agent): enhance model resolution logic by normalizing model options and improving generation model selection
This commit is contained in:
@@ -5,8 +5,3 @@ description: 当前版本已实现但仍需人工验证的变更项
|
||||
|
||||
# 待测试
|
||||
|
||||
- 在线 `Agent` 工具卡片详情不再保存和展示完整上下文消息,只展示当前工具调用和执行结果;需要验证详情内容体积不会随对话历史膨胀。
|
||||
- 文本生成和在线 `Agent` 的 Responses API 请求已改为流式输出;需要验证生成文本、工具确认前后的对话回复会实时刷新。
|
||||
- 在线 `Agent` 自动执行工具时会显示已完成工具卡片,并且从生成配置节点触发生成时会使用配置节点的提示词;需要验证关闭工具确认后连接节点并生图时请求不再发送空 `prompt`。
|
||||
- 网站端在线 `Agent` 工具已对齐本地 Agent 的通用画布工具,支持创建节点、创建生成流程、直接触发文本/图片/视频/音频生成和 `canvas_apply_ops`;需要验证只有文本节点时也能通过 `canvas_generate_image` 创建生图流程并执行。
|
||||
- 网站端在线 `Agent` 新建生成配置节点时会继承当前页面的默认生成设置,包括生图模型、尺寸和数量;需要验证 AI 创建生图流程时使用的模型和手动添加生成配置节点一致。
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"buildCommand": "cd web && bun run build",
|
||||
"installCommand": "cd web && bun install --frozen-lockfile",
|
||||
"outputDirectory": "web/.next",
|
||||
"framework": "nextjs"
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import { Bot, Copy, Cpu, History, PanelRightClose, Plus, Settings2, Trash2, X }
|
||||
import { Button, Modal, Segmented, Switch, Tooltip } from "antd";
|
||||
import { motion } from "motion/react";
|
||||
|
||||
import { modelOptionName, resolveModelChannel, selectableModelsByCapability, useConfigStore, useEffectiveConfig, type AiConfig } from "@/stores/use-config-store";
|
||||
import { modelOptionName, normalizeModelOptionValue, resolveModelChannel, selectableModelsByCapability, useConfigStore, useEffectiveConfig, type AiConfig } from "@/stores/use-config-store";
|
||||
import { canvasThemes } from "@/lib/canvas-theme";
|
||||
import { nanoid } from "nanoid";
|
||||
import { requestToolResponse, type ResponseFunctionTool, type ResponseInputMessage, type ResponseToolCall } from "@/services/api/image";
|
||||
@@ -1021,7 +1021,7 @@ function configNodeOp(id: string, input: Record<string, unknown>, x: number, y:
|
||||
composerContent: prompt,
|
||||
prompt,
|
||||
status: "idle",
|
||||
model: stringOptional(input.model) || defaultGenerationModel(config, mode),
|
||||
model: resolveGenerationModel(config, mode, stringOptional(input.model)),
|
||||
size: stringOptional(input.size) || config.size,
|
||||
quality: stringOptional(input.quality) || config.quality,
|
||||
count: numberOptional(input.count) ?? generationCount(mode === "image" ? config.canvasImageCount || config.count : config.count),
|
||||
@@ -1199,6 +1199,11 @@ function defaultGenerationModel(config: AiConfig, mode: "text" | "image" | "vide
|
||||
return config.textModel || config.model;
|
||||
}
|
||||
|
||||
function resolveGenerationModel(config: AiConfig, mode: "text" | "image" | "video" | "audio", model?: string) {
|
||||
const normalized = normalizeModelOptionValue(model, config.channels);
|
||||
return normalized && selectableModelsByCapability(config, mode).includes(normalized) ? normalized : defaultGenerationModel(config, mode);
|
||||
}
|
||||
|
||||
function generationCount(value: string) {
|
||||
return Math.max(1, Math.min(15, Math.floor(Math.abs(Number(value)) || 1)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user