Skip to content

Commit 5277f7f

Browse files
committed
fmt fix
1 parent 6eb2db2 commit 5277f7f

File tree

1 file changed

+92
-91
lines changed

1 file changed

+92
-91
lines changed

core/http/endpoints/localai/stores.go

Lines changed: 92 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -6,115 +6,116 @@ import (
66
"github.com/go-skynet/LocalAI/core/schema"
77
"github.com/go-skynet/LocalAI/pkg/store"
88
"github.com/gofiber/fiber/v2"
9+
"github.com/rs/zerolog/log"
910
)
1011

11-
func StoresSetEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func (c *fiber.Ctx) error {
12-
return func(c *fiber.Ctx) error {
13-
input := new(schema.StoresSet)
14-
15-
if err := c.BodyParser(input); err != nil {
16-
return err
17-
}
18-
19-
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
20-
if err != nil {
21-
return err
22-
}
23-
24-
vals := make([][]byte, len(input.Values))
25-
for i, v := range input.Values {
26-
vals[i] = []byte(v)
27-
}
28-
29-
err = store.SetCols(c.Context(), sb, input.Keys, vals)
30-
if err != nil {
31-
return err
32-
}
33-
34-
return c.Send(nil)
35-
}
12+
func StoresSetEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error {
13+
return func(c *fiber.Ctx) error {
14+
input := new(schema.StoresSet)
15+
16+
if err := c.BodyParser(input); err != nil {
17+
return err
18+
}
19+
20+
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
21+
if err != nil {
22+
return err
23+
}
24+
25+
vals := make([][]byte, len(input.Values))
26+
for i, v := range input.Values {
27+
vals[i] = []byte(v)
28+
}
29+
30+
err = store.SetCols(c.Context(), sb, input.Keys, vals)
31+
if err != nil {
32+
return err
33+
}
34+
35+
return c.Send(nil)
36+
}
3637
}
3738

38-
func StoresDeleteEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func (c *fiber.Ctx) error {
39-
return func(c *fiber.Ctx) error {
40-
input := new(schema.StoresDelete)
41-
42-
if err := c.BodyParser(input); err != nil {
43-
return err
44-
}
45-
46-
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
47-
if err != nil {
48-
return err
49-
}
50-
51-
if err := store.DeleteCols(c.Context(), sb, input.Keys); err != nil {
52-
return err
53-
}
54-
55-
return c.Send(nil)
56-
}
39+
func StoresDeleteEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error {
40+
return func(c *fiber.Ctx) error {
41+
input := new(schema.StoresDelete)
42+
43+
if err := c.BodyParser(input); err != nil {
44+
return err
45+
}
46+
47+
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
48+
if err != nil {
49+
return err
50+
}
51+
52+
if err := store.DeleteCols(c.Context(), sb, input.Keys); err != nil {
53+
return err
54+
}
55+
56+
return c.Send(nil)
57+
}
5758
}
5859

59-
func StoresGetEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func (c *fiber.Ctx) error {
60-
return func(c *fiber.Ctx) error {
61-
input := new(schema.StoresGet)
60+
func StoresGetEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error {
61+
return func(c *fiber.Ctx) error {
62+
input := new(schema.StoresGet)
6263

63-
if err := c.BodyParser(input); err != nil {
64-
return err
65-
}
64+
if err := c.BodyParser(input); err != nil {
65+
return err
66+
}
6667

67-
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
68-
if err != nil {
69-
return err
70-
}
68+
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
69+
if err != nil {
70+
return err
71+
}
7172

72-
keys, vals, err := store.GetCols(c.Context(), sb, input.Keys)
73-
if err != nil {
74-
return err
75-
}
73+
keys, vals, err := store.GetCols(c.Context(), sb, input.Keys)
74+
if err != nil {
75+
return err
76+
}
7677

77-
res := schema.StoresGetResponse{
78-
Keys: keys,
79-
Values: make([]string, len(vals)),
80-
}
78+
res := schema.StoresGetResponse{
79+
Keys: keys,
80+
Values: make([]string, len(vals)),
81+
}
8182

82-
for i, v := range vals {
83-
res.Values[i] = string(v)
84-
}
83+
for i, v := range vals {
84+
res.Values[i] = string(v)
85+
}
8586

86-
return c.JSON(res)
87-
}
87+
return c.JSON(res)
88+
}
8889
}
8990

90-
func StoresFindEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func (c *fiber.Ctx) error {
91-
return func(c *fiber.Ctx) error {
92-
input := new(schema.StoresFind)
91+
func StoresFindEndpoint(sl *store.StoreLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error {
92+
return func(c *fiber.Ctx) error {
93+
input := new(schema.StoresFind)
9394

94-
if err := c.BodyParser(input); err != nil {
95-
return err
96-
}
95+
if err := c.BodyParser(input); err != nil {
96+
return err
97+
}
9798

98-
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
99-
if err != nil {
100-
return err
101-
}
99+
sb, err := backend.StoreBackend(sl, appConfig, input.Store)
100+
if err != nil {
101+
return err
102+
}
102103

103-
keys, vals, similarities, err := store.Find(c.Context(), sb, input.Key, input.Topk)
104-
if err != nil {
105-
return err
106-
}
104+
keys, vals, similarities, err := store.Find(c.Context(), sb, input.Key, input.Topk)
105+
if err != nil {
106+
return err
107+
}
107108

108-
res := schema.StoresFindResponse{
109-
Keys: keys,
110-
Values: make([]string, len(vals)),
111-
Similarities: similarities,
112-
}
109+
res := schema.StoresFindResponse{
110+
Keys: keys,
111+
Values: make([]string, len(vals)),
112+
Similarities: similarities,
113+
}
113114

114-
for i, v := range vals {
115-
res.Values[i] = string(v)
116-
}
115+
for i, v := range vals {
116+
res.Values[i] = string(v)
117+
}
117118

118-
return c.JSON(res)
119-
}
119+
return c.JSON(res)
120+
}
120121
}

0 commit comments

Comments
 (0)