d440fb1ae7
CI / docker (push) Has been cancelled
引入用户端对话/生图与管理端 Provider 配置,统一 invoke 编排、Gateway、请求日志与模型管理;前端按设计规范拆分布局,Go module 更名为 github.com/rose_cat707/Atlas;生图长任务 SSE 推送;管理端登录防爆破;协议与服务类型联动;Replicate 模型同步修复;用户端创作台 UI 重构;管理端创作历史替代请求日志。 Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
package domain
|
|
|
|
import "encoding/json"
|
|
|
|
type ServiceType string
|
|
|
|
const (
|
|
ServiceChat ServiceType = "chat"
|
|
ServiceImageGeneration ServiceType = "image_generation"
|
|
ServiceTextToImage ServiceType = "text_to_image" // legacy invoke/history kind
|
|
ServiceImageToImage ServiceType = "image_to_image" // legacy invoke/history kind
|
|
)
|
|
|
|
func IsImageInvokeService(st ServiceType) bool {
|
|
return st == ServiceImageGeneration || st == ServiceTextToImage || st == ServiceImageToImage
|
|
}
|
|
|
|
type InvokeMode string
|
|
|
|
const (
|
|
ModeStream InvokeMode = "stream"
|
|
ModeSync InvokeMode = "sync"
|
|
ModeAsync InvokeMode = "async"
|
|
)
|
|
|
|
type InvokeContext struct {
|
|
ConversationID int64 `json:"conversation_id,omitempty"`
|
|
Messages []ChatMessage `json:"messages,omitempty"`
|
|
}
|
|
|
|
type ChatMessage struct {
|
|
Role string `json:"role"`
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
type InvokeRequest struct {
|
|
SessionID string `json:"session_id"`
|
|
ServiceType ServiceType `json:"service_type"`
|
|
ProviderID int64 `json:"provider_id,omitempty"`
|
|
Model string `json:"model"`
|
|
Params json.RawMessage `json:"params"`
|
|
Mode InvokeMode `json:"mode"`
|
|
Context *InvokeContext `json:"context,omitempty"`
|
|
}
|
|
|
|
type StreamChunk struct {
|
|
Delta string `json:"delta"`
|
|
Done bool `json:"done"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
type InvokeResult struct {
|
|
GenerationID int64 `json:"generation_id,omitempty"`
|
|
TaskID *int64 `json:"task_id,omitempty"`
|
|
Output json.RawMessage `json:"output,omitempty"`
|
|
Stream <-chan StreamChunk `json:"-"`
|
|
}
|