update see calss

This commit is contained in:
2026-08-23 22:03:57 +02:00
parent f3d4fb56ed
commit 8983cfc8a1
32 changed files with 1884 additions and 22 deletions
@@ -5,6 +5,8 @@ import (
"log"
"sort"
"strings"
"github.com/descrybe/descrybe-v2/apps/api/internal/aiaudit"
)
// MaxCategorizeOptions caps the taxonomy list injected into the categorize LLM
@@ -255,7 +257,9 @@ func runCategorizeStep(ctx context.Context, e *Engine, companyID string, out *St
if strings.TrimSpace(out.Category) != "" {
return
}
tryAICategorize(ctx, e, out, in, policy)
// Taxonomy picks and copy generation share one Completer; tag the role so the
// admin inspector can tell them apart.
tryAICategorize(aiaudit.WithCall(ctx, aiaudit.CallContext{Role: aiaudit.RoleCategorize}), e, out, in, policy)
if strings.TrimSpace(out.Category) == "" {
appendStepLog(out.GPTResponse, StepCategorize, map[string]any{
"status": "unset",
+14 -2
View File
@@ -9,6 +9,7 @@ import (
"strings"
"time"
"github.com/descrybe/descrybe-v2/apps/api/internal/aiaudit"
"github.com/descrybe/descrybe-v2/apps/api/internal/aiprompts"
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
"github.com/descrybe/descrybe-v2/apps/api/internal/catalog"
@@ -588,15 +589,23 @@ func (p *Pipeline) RetryJob(ctx context.Context, companyID, id uuid.UUID) (Job,
// Terminal job statuses (completed/cancelled/failed) are no-ops — RetryJob requeues work.
func (p *Pipeline) ProcessJob(ctx context.Context, jobID uuid.UUID) error {
var companyID uuid.UUID
var jobUserID *uuid.UUID
var status, processingType string
var alreadyProcessed int
err := p.Pool.QueryRow(ctx, `
SELECT company_id, status, processing_type, processed_products
SELECT company_id, user_id, status, processing_type, processed_products
FROM processing_jobs WHERE id = $1`, jobID).
Scan(&companyID, &status, &processingType, &alreadyProcessed)
Scan(&companyID, &jobUserID, &status, &processingType, &alreadyProcessed)
if err != nil {
return err
}
// Tag every LLM call this job makes so the admin AI inspector can group them
// by tenant, job and the user who started it (internal/aiaudit).
auditCall := aiaudit.CallContext{CompanyID: companyID, JobID: jobID, Role: aiaudit.RoleProcessing}
if jobUserID != nil {
auditCall.UserID = *jobUserID
}
ctx = aiaudit.WithCall(ctx, auditCall)
if !IsProcessableJobStatus(status) {
log.Printf("processing: skip job=%s status=%s reason=not_processable", jobID, status)
return nil
@@ -1439,6 +1448,9 @@ func (p *Pipeline) processOne(ctx context.Context, companyID, jobID uuid.UUID, i
if it == nil {
return false, 0, StepResult{}, fmt.Errorf("processing: nil job item")
}
// Narrow the job-level audit tag to this product so captured prompts are
// addressable per item, not just per job.
ctx = aiaudit.WithCall(ctx, aiaudit.CallContext{RawProductID: it.RawID})
gtin := it.gtin
mappedBytes := it.mappedBytes
rawBytes := it.rawBytes