fix: use modelId instead of sessionId for unloading

The loop now extracts session info to retrieve the model ID, ensuring correct unloading of sessions by their associated model identifiers rather than session IDs. This aligns the cleanup process with the actual model resources being managed.
This commit is contained in:
Akarshan Biswas 2025-06-02 06:42:29 +05:30 committed by Louis
parent e3d6cbd80f
commit 331c0e04a5
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2

View File

@ -139,11 +139,11 @@ export default class llamacpp_extension extends AIEngine {
override async onUnload(): Promise<void> { override async onUnload(): Promise<void> {
// Terminate all active sessions // Terminate all active sessions
for (const [sessionId, _] of this.activeSessions) { for (const [_, sInfo] of this.activeSessions) {
try { try {
await this.unload(sessionId) await this.unload(sInfo.modelId)
} catch (error) { } catch (error) {
console.error(`Failed to unload session ${sessionId}:`, error) console.error(`Failed to unload model ${sInfo.modelId}:`, error)
} }
} }