Architectural improvements in the http adapter

This commit is contained in:
2026-05-05 08:25:32 -05:00
parent c5ce270090
commit 281202e313
7 changed files with 81 additions and 40 deletions

View File

@@ -93,7 +93,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Size: res.Artifact.Size,
Hash: res.Artifact.Hash,
},
Validation: res.Validation,
Validation: mapValidation(res.Validation),
Metadata: metadataDTO{
ProfileID: res.ProfileID,
ProfileVersion: res.ProfileVersion,
@@ -101,14 +101,29 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Endpoint: res.Endpoint,
InputHashes: res.InputHashes,
PromptHash: res.PromptHash,
Usage: res.Usage,
StartTime: res.StartTime,
EndTime: res.EndTime,
Usage: tokenUsageDTO{
PromptTokens: res.Usage.PromptTokens,
CompletionTokens: res.Usage.CompletionTokens,
TotalTokens: res.Usage.TotalTokens,
},
StartTime: res.StartTime,
EndTime: res.EndTime,
},
RawModelOutput: res.RawOutput,
})
}
func mapValidation(v domain.ValidationResult) validationDTO {
return validationDTO{
Status: string(v.Status),
Mode: string(v.Mode),
Errors: v.Errors,
SchemaPath: v.SchemaPath,
RepairAttempts: v.RepairAttempts,
IsValid: v.IsValid,
}
}
func mapRunError(err error) (int, string) {
switch {
case errors.Is(err, profile.ErrProfileNotFound):