Skip to content

Commit d970ca6

Browse files
authored
feat: recognition of emailRessouce metadatas (#4609)
Adding email metadata required for later display in the "Resources" section
2 parents fbf15df + 1ef2e2b commit d970ca6

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

model/rag/chat.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ type QueryMessage struct {
7878
}
7979

8080
type Source struct {
81-
ID string `json:"id"`
82-
DocType string `json:"doctype"`
83-
Filename string `json:"filename"`
84-
FileURL string `json:"fileUrl"`
85-
ChunkURL string `json:"chunkUrl"`
86-
Page int `json:"page"`
81+
ID string `json:"id"`
82+
DocType string `json:"doctype"`
83+
Filename string `json:"filename"`
84+
FileURL string `json:"fileUrl"`
85+
ChunkURL string `json:"chunkUrl"`
86+
Page int `json:"page"`
87+
EmailPreview string `json:"email.preview,omitempty"`
88+
GroupID string `json:"email.groupId,omitempty"`
89+
Subject string `json:"email.subject,omitempty"`
90+
Date string `json:"email.date,omitempty"`
8791
}
8892

8993
func Chat(inst *instance.Instance, payload ChatPayload) (*ChatConversation, error) {
@@ -155,6 +159,10 @@ func getSources(event map[string]interface{}) ([]Source, error) {
155159
if !ok {
156160
continue
157161
}
162+
subject, _ := src["email.subject"].(string)
163+
date, _ := src["email.date"].(string)
164+
emailpreview, _ := src["email.preview"].(string)
165+
groupID, _ := src["email.groupId"].(string)
158166
doctype, _ := src["doctype"].(string)
159167
file_id, _ := src["file_id"].(string)
160168
file_name, _ := src["filename"].(string)
@@ -165,12 +173,16 @@ func getSources(event map[string]interface{}) ([]Source, error) {
165173
file_url, _ := src["file_url"].(string)
166174
chunk_url, _ := src["chunk_url"].(string)
167175
sources = append(sources, Source{
168-
ID: file_id,
169-
DocType: doctype,
170-
Filename: file_name,
171-
Page: page,
172-
FileURL: file_url,
173-
ChunkURL: chunk_url,
176+
ID: file_id,
177+
DocType: doctype,
178+
Filename: file_name,
179+
Page: page,
180+
FileURL: file_url,
181+
ChunkURL: chunk_url,
182+
EmailPreview: emailpreview,
183+
GroupID: groupID,
184+
Subject: subject,
185+
Date: date,
174186
})
175187
}
176188
return sources, nil

0 commit comments

Comments
 (0)