Process AI jobs concurrently
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"ai-service/internal/llm"
|
||||
@@ -94,6 +95,18 @@ func (w *Worker) tick(ctx context.Context) {
|
||||
slog.Error("claim jobs failed", "error", err)
|
||||
return
|
||||
}
|
||||
if len(jobs) > 1 {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(jobs))
|
||||
for _, job := range jobs {
|
||||
go func(job *model.Job) {
|
||||
defer wg.Done()
|
||||
w.process(ctx, job)
|
||||
}(job)
|
||||
}
|
||||
wg.Wait()
|
||||
return
|
||||
}
|
||||
for _, job := range jobs {
|
||||
w.process(ctx, job)
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ spec:
|
||||
value: "llm_chat,chat_completion,call_analysis,telegram_classification"
|
||||
- name: WORKER_MODEL_PROFILES
|
||||
value: "qwen2.5-14b"
|
||||
- name: WORKER_CLAIM_LIMIT
|
||||
value: "8"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: ai-service-config
|
||||
|
||||
Reference in New Issue
Block a user