refactor: Unify /url route and file URL handling

This commit is contained in:
begoniezhao
2026-02-26 15:26:03 +08:00
parent e24bfb05a2
commit daf7dee4d2
5 changed files with 56 additions and 152 deletions
+2 -11
View File
@@ -23,22 +23,13 @@ type KnowledgeService interface {
tagID string,
) (*types.Knowledge, error)
// CreateKnowledgeFromURL creates knowledge from a URL.
// When fileName or fileType is provided (or the URL path has a known file extension),
// the URL is treated as a direct file download instead of a web page crawl.
// tagID is optional - when provided, the knowledge will be assigned to the specified tag/category.
CreateKnowledgeFromURL(
ctx context.Context,
kbID string,
url string,
enableMultimodel *bool,
title string,
tagID string,
) (*types.Knowledge, error)
// CreateKnowledgeFromFileURL creates knowledge by downloading a file from a remote URL.
// fileName and fileType are optional - when not provided, they will be inferred from the URL or Content-Disposition header.
// tagID is optional - when provided, the knowledge will be assigned to the specified tag/category.
CreateKnowledgeFromFileURL(
ctx context.Context,
kbID string,
fileURL string,
fileName string,
fileType string,
enableMultimodel *bool,