mirror of
https://github.com/musistudio/claude-code-router.git
synced 2026-01-30 06:12:06 +00:00
fix log bug
This commit is contained in:
@@ -13,7 +13,7 @@ class ImageCache {
|
||||
constructor(maxSize = 100) {
|
||||
this.cache = new LRUCache({
|
||||
max: maxSize,
|
||||
ttl: 24 * 60 * 60 * 1000,
|
||||
ttl: 5 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,6 +130,12 @@ export class ImageAgent implements IAgent {
|
||||
delete args.imageId;
|
||||
}
|
||||
|
||||
const userMessage = context.req.body.messages[context.req.body.messages.length - 1]
|
||||
if (userMessage.role === 'user' && Array.isArray(userMessage.content)) {
|
||||
const msgs = userMessage.content.filter(item => item.type === 'text' && !item.text.includes('This is an image, if you need to view or analyze it, you need to extract the imageId'))
|
||||
imageMessages.push(...msgs)
|
||||
}
|
||||
|
||||
if (Object.keys(args).length > 0) {
|
||||
imageMessages.push({
|
||||
type: "text",
|
||||
@@ -137,6 +143,7 @@ export class ImageAgent implements IAgent {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Send to analysis agent and get response
|
||||
const agentResponse = await fetch(`http://127.0.0.1:${context.config.PORT}/v1/messages`, {
|
||||
method: "POST",
|
||||
|
||||
@@ -139,11 +139,11 @@ async function run(options: RunOptions = {}) {
|
||||
|
||||
// Add global error handlers to prevent the service from crashing
|
||||
process.on("uncaughtException", (err) => {
|
||||
server.log.error("Uncaught exception:", err);
|
||||
server.logger.error("Uncaught exception:", err);
|
||||
});
|
||||
|
||||
process.on("unhandledRejection", (reason, promise) => {
|
||||
server.log.error("Unhandled rejection at:", promise, "reason:", reason);
|
||||
server.logger.error("Unhandled rejection at:", promise, "reason:", reason);
|
||||
});
|
||||
// Add async preHandler hook for authentication
|
||||
server.addHook("preHandler", async (req, reply) => {
|
||||
|
||||
Reference in New Issue
Block a user