mirror of
https://github.com/mudler/LocalAI.git
synced 2026-03-31 13:15:51 -04:00
chore(api): add path to expose collection raw files
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -203,6 +203,26 @@ func RemoveCollectionSourceEndpoint(app *application.Application) echo.HandlerFu
|
||||
}
|
||||
}
|
||||
|
||||
// GetCollectionEntryRawFileEndpoint serves the original uploaded binary file.
|
||||
func GetCollectionEntryRawFileEndpoint(app *application.Application) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
svc := app.AgentPoolService()
|
||||
entryParam := c.Param("*")
|
||||
entry, err := url.PathUnescape(entryParam)
|
||||
if err != nil {
|
||||
entry = entryParam
|
||||
}
|
||||
fpath, err := svc.GetCollectionEntryFilePath(c.Param("name"), entry)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
return c.JSON(http.StatusNotFound, map[string]string{"error": err.Error()})
|
||||
}
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
}
|
||||
return c.File(fpath)
|
||||
}
|
||||
}
|
||||
|
||||
func ListCollectionSourcesEndpoint(app *application.Application) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
svc := app.AgentPoolService()
|
||||
|
||||
@@ -80,6 +80,7 @@ func RegisterAgentPoolRoutes(e *echo.Echo, app *application.Application) {
|
||||
g.POST("/collections/:name/upload", localai.UploadToCollectionEndpoint(app))
|
||||
g.GET("/collections/:name/entries", localai.ListCollectionEntriesEndpoint(app))
|
||||
g.GET("/collections/:name/entries/*", localai.GetCollectionEntryContentEndpoint(app))
|
||||
g.GET("/collections/:name/entries-raw/*", localai.GetCollectionEntryRawFileEndpoint(app))
|
||||
g.POST("/collections/:name/search", localai.SearchCollectionEndpoint(app))
|
||||
g.POST("/collections/:name/reset", localai.ResetCollectionEndpoint(app))
|
||||
g.DELETE("/collections/:name/entry/delete", localai.DeleteCollectionEntryEndpoint(app))
|
||||
|
||||
@@ -1053,6 +1053,10 @@ func (s *AgentPoolService) CollectionEntryExists(collection, entry string) bool
|
||||
return s.collectionsBackend.EntryExists(collection, entry)
|
||||
}
|
||||
|
||||
func (s *AgentPoolService) GetCollectionEntryFilePath(collection, entry string) (string, error) {
|
||||
return s.collectionsBackend.GetEntryFilePath(collection, entry)
|
||||
}
|
||||
|
||||
// --- Actions ---
|
||||
|
||||
// ListAvailableActions returns the list of all available action type names.
|
||||
|
||||
4
go.mod
4
go.mod
@@ -128,8 +128,8 @@ require (
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/mschoch/smat v0.2.0 // indirect
|
||||
github.com/mudler/LocalAGI v0.0.0-20260311165347-2d2da7df95e1
|
||||
github.com/mudler/localrecall v0.5.7-0.20260314101322-43426c06c67a // indirect
|
||||
github.com/mudler/LocalAGI v0.0.0-20260314222828-e38f13ab8cec
|
||||
github.com/mudler/localrecall v0.5.9-0.20260314221856-96d63875cc47 // indirect
|
||||
github.com/mudler/skillserver v0.0.5-0.20260221145827-0639a82c8f49
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/oxffaa/gopher-parse-sitemap v0.0.0-20191021113419-005d2eb1def4 // indirect
|
||||
|
||||
8
go.sum
8
go.sum
@@ -654,8 +654,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
|
||||
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
||||
github.com/mudler/LocalAGI v0.0.0-20260311165347-2d2da7df95e1 h1:EvG0FDIDGciO7laxgSTUuFjcpWEwhfUM9zfl/T3TVF0=
|
||||
github.com/mudler/LocalAGI v0.0.0-20260311165347-2d2da7df95e1/go.mod h1:6LQyB+kxvh3LGrv4tXk9FVvBvaFRJ14vn09+4xWwmI8=
|
||||
github.com/mudler/LocalAGI v0.0.0-20260314222828-e38f13ab8cec h1:Y6JYhfJidFktfmQC00SwHtQVh0lr0O52qihgTKddSNU=
|
||||
github.com/mudler/LocalAGI v0.0.0-20260314222828-e38f13ab8cec/go.mod h1:yf+IlZzQCGgKPGFn5yclzA2Dxxhy75K3YDubkjCub04=
|
||||
github.com/mudler/cogito v0.9.5-0.20260313170202-42271c7e1a6b h1:Hs2Byjnukgkwm5Vw7z5aSZEjznPHaxjr2vLc5Uu1fHQ=
|
||||
github.com/mudler/cogito v0.9.5-0.20260313170202-42271c7e1a6b/go.mod h1:6sfja3lcu2nWRzEc0wwqGNu/eCG3EWgij+8s7xyUeQ4=
|
||||
github.com/mudler/edgevpn v0.31.1 h1:7qegiDWd0kAg6ljhNHxqvp8hbo/6BbzSdbb7/2WZfiY=
|
||||
@@ -664,8 +664,8 @@ github.com/mudler/go-piper v0.0.0-20241023091659-2494246fd9fc h1:RxwneJl1VgvikiX
|
||||
github.com/mudler/go-piper v0.0.0-20241023091659-2494246fd9fc/go.mod h1:O7SwdSWMilAWhBZMK9N9Y/oBDyMMzshE3ju8Xkexwig=
|
||||
github.com/mudler/go-processmanager v0.1.0 h1:fcSKgF9U/a1Z7KofAFeZnke5YseadCI5GqL9oT0LS3E=
|
||||
github.com/mudler/go-processmanager v0.1.0/go.mod h1:h6kmHUZeafr+k5hRYpGLMzJFH4hItHffgpRo2QIkP+o=
|
||||
github.com/mudler/localrecall v0.5.7-0.20260314101322-43426c06c67a h1:Ah71V/UgF78i0I7yxu0EUweum6p3KwErz9qVFms9/VI=
|
||||
github.com/mudler/localrecall v0.5.7-0.20260314101322-43426c06c67a/go.mod h1:TZVXQI840MqjDtilBLc7kfmnctK4oNf1IR+cE68zno8=
|
||||
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/memory v0.0.0-20251216220809-d1256471a6c2 h1:+WHsL/j6EWOMUiMVIOJNKOwSKiQt/qDPc9fePCf87fA=
|
||||
github.com/mudler/memory v0.0.0-20251216220809-d1256471a6c2/go.mod h1:EA8Ashhd56o32qN7ouPKFSRUs/Z+LrRCF4v6R2Oarm8=
|
||||
github.com/mudler/skillserver v0.0.5-0.20260221145827-0639a82c8f49 h1:dAF1ALXqqapRZo80x56BIBBcPrPbRNerbd66rdyO8J4=
|
||||
|
||||
Reference in New Issue
Block a user