fix: 修复502导致的内存泄漏问题

This commit is contained in:
leookun
2026-07-27 00:15:23 +08:00
parent 799dbda7e0
commit e401303f64
3 changed files with 36 additions and 31 deletions
+13
View File
@@ -25,6 +25,7 @@ func (gateway *DefaultProviderGateway) StartStream(ctx context.Context, req Prov
if ctx == nil {
ctx = context.Background()
}
defer releaseArtifactSession(req.Observer, req.RequestID, req.ModelCallID)
requestKnobs := make(map[string]any, len(req.RequestKnobs)+2)
for key, value := range req.RequestKnobs {
requestKnobs[key] = value
@@ -60,3 +61,15 @@ func (gateway *DefaultProviderGateway) StartStream(ctx context.Context, req Prov
}
return nil
}
type artifactSessionCleaner interface {
ClearActiveArtifacts(requestID string, modelCallID string)
}
func releaseArtifactSession(observer modeladapter.LLMArtifactObserver, requestID string, modelCallID string) {
cleaner, ok := observer.(artifactSessionCleaner)
if !ok {
return
}
cleaner.ClearActiveArtifacts(requestID, modelCallID)
}