chat_session.go
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction"
)
type ChatSession struct {
Id int64 `json:",omitempty"` // 唯一标识
CompanyId int64 `json:",omitempty"` // 公司ID
UserId int64 `json:",omitempty"` // 用户ID
Title string `json:",omitempty"` // 会话标题
Abstract string `json:",omitempty"` // 摘要
Module int `json:",omitempty"` // 1:openai chat 2:星火文档问答
Type string `json:",omitempty"` // 类型 chat:普通问答 spark_dataset_chat:星火知识库问答 spark_documents_chat:星火多文档问答
Metadata *SessionMetadata `json:",omitempty"` // 元数据
Rank int64 `json:",omitempty"` // 排序(时间秒,置顶更新当前会话)
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
}
const (
ModuleOpenaiChat = 1
ModuleSparkChat = 2
)
const (
TypeChat = "chat"
TypeSparkDatasetChat = "spark_dataset_chat"
TypeSparkDocumentsChat = "spark_documents_chat"
)
type SessionMetadata struct {
DatasetId int64 `json:",omitempty"` // 知识库
DocumentIds []int64 `json:",omitempty"` // 多文档
}
type ChatSessionRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ChatSession) (*ChatSession, error)
Update(ctx context.Context, conn transaction.Conn, dm *ChatSession) (*ChatSession, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ChatSession) (*ChatSession, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ChatSession) (*ChatSession, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ChatSession, error)
FindOneUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*ChatSession, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ChatSession, error)
}