compaction de contexte, filtre/pagination/suppression des conversations
- compaction automatique du contexte LLM quand la taille atteint le seuil (contexte max - taille de réponse max), par résumé de l'historique ancien - filtre textuel (?q=) et pagination (20/page) de l'historique des conversations - correctif ORM : offset de pagination en base 0 - suppression d'une conversation : messages associés supprimés, session en cours annulée, popup de confirmation (ConfirmDialog) - titres de conversation nettoyés du markdown - styles des listes markdown, variante danger du bouton - go.mod/go.sum : dépendances go-rod et stealth manquantes du commit précédent
This commit is contained in:
1 parent
a970bfa991
commit
51bbb45b32
86 files changed
+770
-113
No files matched your search
@@ -3,6 +3,7 @@ package turso
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"trankilou.fr/lassistanoque/backend/internal/adapter/database/orm"
|
||||
"trankilou.fr/lassistanoque/backend/internal/domain"
|
||||
@@ -29,15 +30,21 @@ func NewTursoChatRepository(db *sql.DB) *TursoChatRepository {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *TursoChatRepository) ListChats(userID string, teamID string, page int) ([]*domain.Chat, error) {
|
||||
func (r *TursoChatRepository) ListChats(userID string, teamID string, page int, query string) ([]*domain.Chat, error) {
|
||||
where := "team_id=$1 and team_id in (select team_id from user_teams where user_id=$2)"
|
||||
args := []any{teamID, userID}
|
||||
if query != "" {
|
||||
// % et _ sont des jokers LIKE : on les neutralise
|
||||
escaped := strings.ReplaceAll(query, `\`, `\\`)
|
||||
escaped = strings.ReplaceAll(escaped, `%`, `\%`)
|
||||
escaped = strings.ReplaceAll(escaped, `_`, `\_`)
|
||||
where += " and title like $3 escape '\\'"
|
||||
args = append(args, "%"+escaped+"%")
|
||||
}
|
||||
return r.chatTable.Select(
|
||||
orm.WithWhere(
|
||||
"team_id=$1 and team_id in (select team_id from user_teams where user_id=$2)",
|
||||
teamID,
|
||||
userID,
|
||||
),
|
||||
orm.WithWhere(where, args...),
|
||||
orm.WithOrder("_date_created desc"),
|
||||
orm.WithPagination(page, 50),
|
||||
orm.WithPagination(page, 20),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,6 +75,16 @@ func (r *TursoChatRepository) UpdateChat(userID string, chat *domain.Chat) (*dom
|
||||
}
|
||||
|
||||
func (r *TursoChatRepository) DeleteChat(userID string, teamID string, id string) error {
|
||||
// les messages n'ont pas de clé étrangère cascade : suppression explicite
|
||||
err := r.messageTable.DeleteWhere(
|
||||
"chat_id=$1 and team_id=$2 and team_id in (select team_id from user_teams where user_id=$3)",
|
||||
id,
|
||||
teamID,
|
||||
userID,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return r.chatTable.DeleteWhere(
|
||||
"id=$1 and team_id=$2 and team_id in (select team_id from user_teams where user_id=$3)",
|
||||
id,
|
||||
|
||||
Reference in new issue
Block a user