Respect provider rate limits and preserve bank connections on throttling
This commit is contained in:
@@ -70,7 +70,7 @@ func (a *App) Preview(ctx context.Context, r PreviewRequest) (Preview, error) {
|
||||
}
|
||||
a.mu.Lock()
|
||||
s, err := a.snapshot(ctx)
|
||||
client := a.classifier
|
||||
client := a.classifier.WithModel(r.Model)
|
||||
a.mu.Unlock()
|
||||
if err != nil {
|
||||
return Preview{}, err
|
||||
@@ -78,7 +78,6 @@ func (a *App) Preview(ctx context.Context, r PreviewRequest) (Preview, error) {
|
||||
if r.Revision != s.Revision {
|
||||
return Preview{}, errors.New("revision conflict: reload before analysing")
|
||||
}
|
||||
client.Model = r.Model
|
||||
p := Preview{ID: domain.NewID("preview"), Revision: s.Revision, Changes: []Change{}, Errors: []ClassificationError{}, created: time.Now()}
|
||||
baseMerchants := len(s.Data.Merchants)
|
||||
for _, t := range s.Data.Transactions {
|
||||
@@ -90,6 +89,9 @@ func (a *App) Preview(ctx context.Context, r PreviewRequest) (Preview, error) {
|
||||
}
|
||||
p.Analysed++
|
||||
proposal, e := client.Classify(ctx, t.Facts, s.Data, true)
|
||||
if err = ctx.Err(); err != nil {
|
||||
return Preview{}, err
|
||||
}
|
||||
if e != nil {
|
||||
p.Errors = append(p.Errors, ClassificationError{t.Facts.ID, e.Error()})
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user