You've already forked agentic-coding-workflow
改动
This commit is contained in:
+41
-15
@@ -105,18 +105,19 @@ type ConversationDTO struct {
|
||||
|
||||
// MessageDTO is the JSON representation of a Message.
|
||||
type MessageDTO struct {
|
||||
ID int64 `json:"id"`
|
||||
ConversationID uuid.UUID `json:"conversation_id"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Thinking *string `json:"thinking,omitempty"`
|
||||
Status string `json:"status"`
|
||||
ErrorMessage *string `json:"error_message,omitempty"`
|
||||
PromptTokens *int `json:"prompt_tokens,omitempty"`
|
||||
CompletionTokens *int `json:"completion_tokens,omitempty"`
|
||||
ThinkingTokens *int `json:"thinking_tokens,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID int64 `json:"id"`
|
||||
ConversationID uuid.UUID `json:"conversation_id"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Thinking *string `json:"thinking,omitempty"`
|
||||
Status string `json:"status"`
|
||||
ErrorMessage *string `json:"error_message,omitempty"`
|
||||
PromptTokens *int `json:"prompt_tokens,omitempty"`
|
||||
CompletionTokens *int `json:"completion_tokens,omitempty"`
|
||||
ThinkingTokens *int `json:"thinking_tokens,omitempty"`
|
||||
Attachments []AttachmentDTO `json:"attachments"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AttachmentDTO is the JSON representation of an Attachment.
|
||||
@@ -205,11 +206,18 @@ type ModelUsageDTO struct {
|
||||
CostUSD float64 `json:"cost_usd"`
|
||||
}
|
||||
|
||||
// AdminUsageItem is a single aggregated usage row keyed by user/model/day.
|
||||
type AdminUsageItem struct {
|
||||
Key string `json:"key"`
|
||||
PromptTokens int `json:"prompt_tokens"`
|
||||
CompletionTokens int `json:"completion_tokens"`
|
||||
ThinkingTokens int `json:"thinking_tokens"`
|
||||
CostUSD float64 `json:"cost_usd"`
|
||||
}
|
||||
|
||||
// AdminUsageResp is the response body for GET /admin/usage.
|
||||
type AdminUsageResp struct {
|
||||
ByUser []UserUsageDTO `json:"by_user"`
|
||||
ByModel []ModelUsageDTO `json:"by_model"`
|
||||
ByDay []DayUsageDTO `json:"by_day"`
|
||||
Items []AdminUsageItem `json:"items"`
|
||||
}
|
||||
|
||||
// ===== Conversion helpers =====
|
||||
@@ -241,11 +249,29 @@ func toMessageDTO(m *Message) MessageDTO {
|
||||
PromptTokens: m.PromptTokens,
|
||||
CompletionTokens: m.CompletionTokens,
|
||||
ThinkingTokens: m.ThinkingTokens,
|
||||
Attachments: toAttachmentDTOs(m.Attachments),
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// toAttachmentDTOs maps a slice of Attachment to DTOs, always returning a
|
||||
// non-nil (possibly empty) slice so the JSON field serializes as [].
|
||||
func toAttachmentDTOs(atts []Attachment) []AttachmentDTO {
|
||||
out := make([]AttachmentDTO, 0, len(atts))
|
||||
for _, a := range atts {
|
||||
out = append(out, AttachmentDTO{
|
||||
ID: a.ID,
|
||||
Filename: a.Filename,
|
||||
MimeType: a.MimeType,
|
||||
SizeBytes: a.SizeBytes,
|
||||
SHA256: a.SHA256,
|
||||
CreatedAt: a.CreatedAt,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func toTemplateDTO(t *PromptTemplate) TemplateDTO {
|
||||
return TemplateDTO{
|
||||
ID: t.ID,
|
||||
|
||||
Reference in New Issue
Block a user