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:"-"`
|
|
}
|