90 lines
2.8 KiB
Go
90 lines
2.8 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// --- Global DB Models ---
|
|
|
|
// LLMProvider stores LLM provider configuration
|
|
type LLMProvider struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
Name string `json:"name"`
|
|
Provider string `json:"provider"` // Ollama, DeepSeek, OpenAI, Qwen
|
|
BaseURL string `json:"url"`
|
|
APIKey string `json:"key"`
|
|
ModelID string `json:"model"`
|
|
Enabled bool `json:"enabled"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// VectorDBConfig stores Qdrant connection settings
|
|
type VectorDBConfig struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Endpoint string `json:"endpoint"`
|
|
APIKey string `json:"apiKey"`
|
|
Status string `json:"status"` // connected, disconnected
|
|
}
|
|
|
|
// Project represents a top-level engineering project
|
|
type Project struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
Name string `json:"name"`
|
|
Path string `json:"path"` // project DB file path
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// --- Project-scoped DB Models ---
|
|
|
|
// SourceFile represents an imported engineering document
|
|
type SourceFile struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
ProjectID string `gorm:"index" json:"projectId"`
|
|
Name string `json:"name"`
|
|
Type string `json:"type"` // pdf, cad, gis, excel, word
|
|
Category string `json:"category"`
|
|
FilePath string `json:"filePath"`
|
|
Size string `json:"size"`
|
|
ParsedContent string `json:"parsedContent,omitempty"`
|
|
VectorStatus string `json:"vectorStatus"` // pending, processing, done, error
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// ChatMessage stores conversation history per project
|
|
type ChatMessage struct {
|
|
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
ProjectID string `gorm:"index" json:"projectId"`
|
|
Role string `json:"role"` // user, assistant
|
|
Content string `json:"content"`
|
|
Sources string `json:"sources,omitempty"` // JSON array of source names
|
|
Citations string `json:"citations,omitempty"` // JSON array of citation objects
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
// TemplateChapter stores delivery template chapters per project
|
|
type TemplateChapter struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
ProjectID string `gorm:"index" json:"projectId"`
|
|
TemplateName string `json:"templateName"`
|
|
Title string `json:"title"`
|
|
Status string `json:"status"` // idle, loading, done
|
|
Progress int `json:"progress"`
|
|
Content string `json:"content"`
|
|
SortOrder int `json:"sortOrder"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// TextChunk represents a vectorized text segment
|
|
type TextChunk struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
ProjectID string `gorm:"index" json:"projectId"`
|
|
SourceID string `gorm:"index" json:"sourceId"`
|
|
Content string `json:"content"`
|
|
ChunkIdx int `json:"chunkIdx"`
|
|
CreatedAt time.Time
|
|
}
|