feat: add handler to serve raw files

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2026-03-14 22:27:40 +00:00
parent 2d2da7df95
commit e38f13ab8c
4 changed files with 20 additions and 7 deletions
+3 -3
View File
@@ -17,8 +17,8 @@ require (
github.com/google/uuid v1.6.0
github.com/jung-kurt/gofpdf v1.16.2
github.com/modelcontextprotocol/go-sdk v1.2.0
github.com/mudler/cogito v0.9.3
github.com/mudler/localrecall v0.5.4
github.com/mudler/cogito v0.9.2-0.20260225234859-b76691637703
github.com/mudler/localrecall v0.5.9-0.20260314221856-96d63875cc47
github.com/mudler/skillserver v0.0.5-0.20260221145827-0639a82c8f49
github.com/mudler/xlog v0.0.5
github.com/onsi/ginkgo/v2 v2.27.5
@@ -27,6 +27,7 @@ require (
github.com/robfig/cron/v3 v3.0.1
github.com/sashabaranov/go-openai v1.41.2
github.com/slack-go/slack v0.17.3
github.com/spf13/cobra v1.10.2
github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64
github.com/tmc/langchaingo v0.1.14
github.com/traefik/yaegi v0.16.1
@@ -95,7 +96,6 @@ require (
github.com/shopspring/decimal v1.4.0 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
+4 -4
View File
@@ -297,10 +297,10 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
github.com/mudler/cogito v0.9.3 h1:epVhDzNmzqmwiUCrGSpuRryV8nNXsZUFhcDMTbBHXJI=
github.com/mudler/cogito v0.9.3/go.mod h1:6sfja3lcu2nWRzEc0wwqGNu/eCG3EWgij+8s7xyUeQ4=
github.com/mudler/localrecall v0.5.4 h1:hVPGHRDBOkGUJYL6Zm37sG8uoZObc8jtIJlDY/+NVb4=
github.com/mudler/localrecall v0.5.4/go.mod h1:TZVXQI840MqjDtilBLc7kfmnctK4oNf1IR+cE68zno8=
github.com/mudler/cogito v0.9.2-0.20260225234859-b76691637703 h1:DVYONTwYj14uNvT1wumq3lV2Kl4cQ9vl+NAlkMHpdp4=
github.com/mudler/cogito v0.9.2-0.20260225234859-b76691637703/go.mod h1:6sfja3lcu2nWRzEc0wwqGNu/eCG3EWgij+8s7xyUeQ4=
github.com/mudler/localrecall v0.5.9-0.20260314221856-96d63875cc47 h1:fHIkLJgfcYDF4bhwVZdfFcQB2HVw93ClOQSKRci8qQs=
github.com/mudler/localrecall v0.5.9-0.20260314221856-96d63875cc47/go.mod h1:TZVXQI840MqjDtilBLc7kfmnctK4oNf1IR+cE68zno8=
github.com/mudler/skillserver v0.0.5-0.20260221145827-0639a82c8f49 h1:dAF1ALXqqapRZo80x56BIBBcPrPbRNerbd66rdyO8J4=
github.com/mudler/skillserver v0.0.5-0.20260221145827-0639a82c8f49/go.mod h1:z3yFhcL9bSykmmh6xgGu0hyoItd4CnxgtWMEWw8uFJU=
github.com/mudler/xlog v0.0.5 h1:2unBuVC5rNGhCC86UaA94TElWFml80NL5XLK+kAmNuU=
+10
View File
@@ -195,6 +195,16 @@ func (b *backendInProcess) ListSources(collection string) ([]SourceInfo, error)
return out, nil
}
func (b *backendInProcess) GetEntryFilePath(collection, entry string) (string, error) {
b.state.Mu.RLock()
kb, exists := b.state.Collections[collection]
b.state.Mu.RUnlock()
if !exists {
return "", fmt.Errorf("collection not found: %s", collection)
}
return kb.GetEntryFilePath(entry)
}
func (b *backendInProcess) EntryExists(collection, entry string) bool {
b.state.Mu.RLock()
kb, exists := b.state.Collections[collection]
+3
View File
@@ -35,6 +35,9 @@ type Backend interface {
RemoveSource(collection, url string) error
ListSources(collection string) ([]SourceInfo, error)
EntryExists(collection, entry string) bool
// GetEntryFilePath returns the filesystem path of the stored file for the
// given entry. This is used to serve the original uploaded binary file.
GetEntryFilePath(collection, entry string) (string, error)
}
// Config holds the configuration for the in-process collections backend.