mirror of
https://github.com/musistudio/claude-code-router.git
synced 2026-02-03 07:10:51 +08:00
fix image agent error
This commit is contained in:
@@ -102,12 +102,12 @@ export class ImageAgent implements IAgent {
|
|||||||
"required": ["imageId", "task"]
|
"required": ["imageId", "task"]
|
||||||
},
|
},
|
||||||
handler: async (args, context) => {
|
handler: async (args, context) => {
|
||||||
console.log('args', JSON.stringify(args, null, 2))
|
|
||||||
const imageMessages = [];
|
const imageMessages = [];
|
||||||
let imageId;
|
let imageId;
|
||||||
|
|
||||||
// Create image messages from cached images
|
// Create image messages from cached images
|
||||||
if (args.imageId && Array.isArray(args.imageId)) {
|
if (args.imageId) {
|
||||||
|
if (Array.isArray(args.imageId)) {
|
||||||
args.imageId.forEach((imgId: string) => {
|
args.imageId.forEach((imgId: string) => {
|
||||||
const image = imageCache.getImage(`${context.req.id}_Image#${imgId}`);
|
const image = imageCache.getImage(`${context.req.id}_Image#${imgId}`);
|
||||||
if (image) {
|
if (image) {
|
||||||
@@ -117,6 +117,15 @@ export class ImageAgent implements IAgent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
const image = imageCache.getImage(`${context.req.id}_Image#${args.imageId}`);
|
||||||
|
if (image) {
|
||||||
|
imageMessages.push({
|
||||||
|
type: "image",
|
||||||
|
source: image,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
imageId = args.imageId;
|
imageId = args.imageId;
|
||||||
delete args.imageId;
|
delete args.imageId;
|
||||||
}
|
}
|
||||||
@@ -155,7 +164,6 @@ Always ensure that your response reflects a clear, accurate interpretation of th
|
|||||||
}).then(res => res.json()).catch(err => {
|
}).then(res => res.json()).catch(err => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
console.log(agentResponse.content);
|
|
||||||
if (!agentResponse || !agentResponse.content) {
|
if (!agentResponse || !agentResponse.content) {
|
||||||
return 'analyzeImage Error';
|
return 'analyzeImage Error';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ async function run(options: RunOptions = {}) {
|
|||||||
req,
|
req,
|
||||||
config
|
config
|
||||||
});
|
});
|
||||||
console.log('result', toolResult)
|
|
||||||
toolMessages.push({
|
toolMessages.push({
|
||||||
"tool_use_id": currentToolId,
|
"tool_use_id": currentToolId,
|
||||||
"type": "tool_result",
|
"type": "tool_result",
|
||||||
@@ -318,7 +317,6 @@ async function run(options: RunOptions = {}) {
|
|||||||
|
|
||||||
// 处理流提前关闭的错误
|
// 处理流提前关闭的错误
|
||||||
if (error.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
if (error.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||||
console.log('Stream prematurely closed, aborting operations');
|
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -368,7 +366,6 @@ async function run(options: RunOptions = {}) {
|
|||||||
done(null, payload)
|
done(null, payload)
|
||||||
});
|
});
|
||||||
server.addHook("onSend", async (req, reply, payload) => {
|
server.addHook("onSend", async (req, reply, payload) => {
|
||||||
console.log('主应用onSend')
|
|
||||||
event.emit('onSend', req, reply, payload);
|
event.emit('onSend', req, reply, payload);
|
||||||
return payload;
|
return payload;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -502,7 +502,6 @@ export function LogViewer({ open, onOpenChange, showToast }: LogViewerProps) {
|
|||||||
// 如果在分组模式且选中了具体请求,显示该请求的日志
|
// 如果在分组模式且选中了具体请求,显示该请求的日志
|
||||||
if (groupByReqId && groupedLogs && selectedReqId && groupedLogs.groups[selectedReqId]) {
|
if (groupByReqId && groupedLogs && selectedReqId && groupedLogs.groups[selectedReqId]) {
|
||||||
const requestLogs = groupedLogs.groups[selectedReqId];
|
const requestLogs = groupedLogs.groups[selectedReqId];
|
||||||
console.log(requestLogs)
|
|
||||||
// 提取原始JSON字符串并每行一个
|
// 提取原始JSON字符串并每行一个
|
||||||
return requestLogs.map(log => JSON.stringify(log)).join('\n');
|
return requestLogs.map(log => JSON.stringify(log)).join('\n');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user