fix log bug

This commit is contained in:
musistudio
2025-09-25 23:11:33 +08:00
parent 9dfff02135
commit 4d3708fbdf
2 changed files with 10 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ class ImageCache {
constructor(maxSize = 100) { constructor(maxSize = 100) {
this.cache = new LRUCache({ this.cache = new LRUCache({
max: maxSize, max: maxSize,
ttl: 24 * 60 * 60 * 1000, ttl: 5 * 60 * 1000,
}); });
} }
@@ -130,6 +130,12 @@ export class ImageAgent implements IAgent {
delete args.imageId; 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) { if (Object.keys(args).length > 0) {
imageMessages.push({ imageMessages.push({
type: "text", type: "text",
@@ -137,6 +143,7 @@ export class ImageAgent implements IAgent {
}); });
} }
// Send to analysis agent and get response // Send to analysis agent and get response
const agentResponse = await fetch(`http://127.0.0.1:${context.config.PORT}/v1/messages`, { const agentResponse = await fetch(`http://127.0.0.1:${context.config.PORT}/v1/messages`, {
method: "POST", method: "POST",

View File

@@ -139,11 +139,11 @@ async function run(options: RunOptions = {}) {
// Add global error handlers to prevent the service from crashing // Add global error handlers to prevent the service from crashing
process.on("uncaughtException", (err) => { process.on("uncaughtException", (err) => {
server.log.error("Uncaught exception:", err); server.logger.error("Uncaught exception:", err);
}); });
process.on("unhandledRejection", (reason, promise) => { 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 // Add async preHandler hook for authentication
server.addHook("preHandler", async (req, reply) => { server.addHook("preHandler", async (req, reply) => {