tâches planifiées : prompts cron persistés, outil scheduler, conversations liées aux tâches, rattrapage des exécutions manquées au redémarrage (go-cron MissedRunOnce)
This commit is contained in:
1 parent
bedb6c98e7
commit
058370830f
71 files changed
+1627
-100
No files matched your search
@@ -151,7 +151,7 @@ type LLMEngine interface {
|
||||
}
|
||||
|
||||
type ChatRepository interface {
|
||||
ListChats(userID string, teamID string, page int, query string) ([]*Chat, error)
|
||||
ListChats(userID string, teamID string, page int, query string, taskID string) ([]*Chat, error)
|
||||
ListChatsWithUnfreshTitles(teamID string) ([]*Chat, error)
|
||||
GetChat(userID string, teamID string, id string) (*Chat, error)
|
||||
CreateChat(userID string, chat *Chat) (*Chat, error)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
// statuts d'une tâche planifiée
|
||||
TaskStatusActive = "active"
|
||||
TaskStatusDone = "done"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
ID string `db:"id" json:"id"`
|
||||
TeamID string `db:"team_id" json:"teamId"`
|
||||
ModelID string `db:"model_id" json:"modelId"`
|
||||
Label string `db:"label" json:"label"`
|
||||
Prompt string `db:"prompt" json:"prompt"`
|
||||
Cron string `db:"cron" json:"cron"`
|
||||
Repeat bool `db:"repeat" json:"repeat"`
|
||||
Status string `db:"status" json:"status"`
|
||||
NextDatetime *time.Time `db:"next_datetime" json:"nextDatetime"`
|
||||
LastDatetime *time.Time `db:"last_datetime" json:"lastDatetime"`
|
||||
DateCreated time.Time `db:"_date_created" json:"_date_created"`
|
||||
DateUpdated *time.Time `db:"_date_updated" json:"_date_updated"`
|
||||
VersionId string `db:"_version" json:"_version"`
|
||||
}
|
||||
|
||||
type TaskRepository interface {
|
||||
ListTasks(userID string, teamID string) ([]*Task, error)
|
||||
ListActiveTasks() ([]*Task, error)
|
||||
GetTaskByID(userID string, teamID string, id string) (*Task, error)
|
||||
CreateTask(task *Task) (*Task, error)
|
||||
UpdateTask(task *Task) (*Task, error)
|
||||
DeleteTask(userID string, teamID string, id string) error
|
||||
FirstUserOfTeam(teamID string) (string, error)
|
||||
}
|
||||
@@ -1,6 +1,41 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Clés de contexte passées aux outils lors de l'exécution : identité de
|
||||
// l'appelant et modèle en cours, pour les outils qui en dépendent
|
||||
// (ex. scheduler crée une tâche pour l'équipe courante).
|
||||
type contextKey int
|
||||
|
||||
const (
|
||||
contextKeyUserID contextKey = iota
|
||||
contextKeyTeamID
|
||||
contextKeyModelID
|
||||
)
|
||||
|
||||
func WithToolContext(ctx context.Context, userID string, teamID string, modelID string) context.Context {
|
||||
ctx = context.WithValue(ctx, contextKeyUserID, userID)
|
||||
ctx = context.WithValue(ctx, contextKeyTeamID, teamID)
|
||||
return context.WithValue(ctx, contextKeyModelID, modelID)
|
||||
}
|
||||
|
||||
func UserIDFromContext(ctx context.Context) (string, bool) {
|
||||
v, ok := ctx.Value(contextKeyUserID).(string)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func TeamIDFromContext(ctx context.Context) (string, bool) {
|
||||
v, ok := ctx.Value(contextKeyTeamID).(string)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func ModelIDFromContext(ctx context.Context) (string, bool) {
|
||||
v, ok := ctx.Value(contextKeyModelID).(string)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
type Tool struct {
|
||||
ID string `db:"id" json:"id"`
|
||||
|
||||
Reference in new issue
Block a user