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