Skip to content

Commit 5e9e806

Browse files
authored
fix: make sources' doctype generic (#4597)
Previously, the doc type was hardcoded as "io.cozy.files". This PR makes it generic by using the value from src["doctype"].(string).
2 parents 4829abd + 9835ea1 commit 5e9e806

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

model/rag/chat.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,22 @@ func getSources(event map[string]interface{}) ([]Source, error) {
155155
if !ok {
156156
continue
157157
}
158+
doctype, _ := src["doctype"].(string)
159+
file_id, _ := src["file_id"].(string)
160+
file_name, _ := src["filename"].(string)
161+
page := 0
162+
if p, ok := src["page"].(float64); ok {
163+
page = int(p)
164+
}
165+
file_url, _ := src["file_url"].(string)
166+
chunk_url, _ := src["chunk_url"].(string)
158167
sources = append(sources, Source{
159-
ID: src["file_id"].(string),
160-
DocType: "io.cozy.files",
161-
Filename: src["filename"].(string),
162-
Page: int(src["page"].(float64)),
163-
FileURL: src["file_url"].(string),
164-
ChunkURL: src["chunk_url"].(string),
168+
ID: file_id,
169+
DocType: doctype,
170+
Filename: file_name,
171+
Page: page,
172+
FileURL: file_url,
173+
ChunkURL: chunk_url,
165174
})
166175
}
167176
return sources, nil

0 commit comments

Comments
 (0)