Architectural improvements in the http adapter
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user