feat(web): 将原生 select 替换为 shadcn/ui Select 组件并支持图片消息发送
- 在 AccountForm、AssetGallery、ChatView、ConfigForm、PromptEditor 中将 `<select>` 替换为 shadcn/ui 的 Select 组件以统一 UI 风格 - 在 ChatView 和 useChat hook 中支持发送图片附件 - 更新 pi-bridge 和 ws/chat 以处理 agent 调用中的图片数据
This commit is contained in:
@@ -44,7 +44,7 @@ interface RunContext {
|
||||
currentAssistantMsgId: string | null;
|
||||
}
|
||||
|
||||
export async function runAgentChat(ws: WebSocket, convId: string, userContent: string) {
|
||||
export async function runAgentChat(ws: WebSocket, convId: string, userContent: string, images?: Array<{ type: 'image'; data: string; mimeType: string }>) {
|
||||
const userMsgId = saveUserMessage(convId, userContent);
|
||||
ws.send(JSON.stringify({ type: 'message', data: { id: userMsgId, role: 'user', content: userContent } }));
|
||||
|
||||
@@ -84,7 +84,7 @@ export async function runAgentChat(ws: WebSocket, convId: string, userContent: s
|
||||
ws.send(JSON.stringify({ type: 'status', data: { status: 'thinking' } }));
|
||||
|
||||
try {
|
||||
await agent.prompt(userContent);
|
||||
await agent.prompt(userContent, images);
|
||||
} catch (err) {
|
||||
const errMsg = (err as Error).message;
|
||||
console.error('[pi-bridge] Agent error:', errMsg);
|
||||
|
||||
@@ -34,7 +34,7 @@ export function handleChat(ws: WebSocket) {
|
||||
ws.send(JSON.stringify({ type: 'error', data: { message: '没有活跃对话,请先创建或选择一个对话' } }));
|
||||
return;
|
||||
}
|
||||
await runAgentChat(ws, conversationId, msg.content);
|
||||
await runAgentChat(ws, conversationId, msg.content, msg.images);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('WebSocket error:', e);
|
||||
|
||||
Reference in New Issue
Block a user