Skip to content

Commit 5af330e

Browse files
committed
debug
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent e1fb0a8 commit 5af330e

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

core/http/app.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,26 @@ func App(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfig *confi
181181
Browse: true,
182182
}))
183183

184-
app.Use("/ws", func(c *fiber.Ctx) error {
185-
// IsWebSocketUpgrade returns true if the client
186-
// requested upgrade to the WebSocket protocol.
184+
app.Use(func(c *fiber.Ctx) error {
187185
if websocket.IsWebSocketUpgrade(c) {
188-
c.Locals("allowed", true)
189-
return c.Next()
186+
// Returns true if the client requested upgrade to the WebSocket protocol
187+
c.Next()
190188
}
191-
return fiber.ErrUpgradeRequired
189+
190+
return nil
192191
})
193192

193+
// app.Use("/v1/realtime", func(c *fiber.Ctx) error {
194+
// fmt.Println("Hit upgrade from http")
195+
// // IsWebSocketUpgrade returns true if the client
196+
// // requested upgrade to the WebSocket protocol.
197+
// if websocket.IsWebSocketUpgrade(c) {
198+
// c.Locals("allowed", true)
199+
// return c.Next()
200+
// }
201+
// return fiber.ErrUpgradeRequired
202+
// })
203+
194204
// Define a custom 404 handler
195205
// Note: keep this at the bottom!
196206
app.Use(notFoundHandler)

core/http/endpoints/openai/realtime.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,16 @@ var sessionLock sync.Mutex
106106

107107
func RegisterRealtime(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfig *config.ApplicationConfig) func(c *websocket.Conn) {
108108
return func(c *websocket.Conn) {
109+
110+
log.Debug().Msgf("WebSocket connection established with '%s'", c.RemoteAddr().String())
111+
109112
// Generate a unique session ID
110113
sessionID := generateSessionID()
111114

112-
modelFile, input, err := readWSRequest(c, cl, ml, appConfig, true)
113-
if err != nil {
114-
return fmt.Errorf("failed reading parameters from request:%w", err)
115-
}
115+
// modelFile, input, err := readWSRequest(c, cl, ml, appConfig, true)
116+
// if err != nil {
117+
// return fmt.Errorf("failed reading parameters from request:%w", err)
118+
// }
116119

117120
session := &Session{
118121
ID: sessionID,

core/http/endpoints/openai/request.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77

88
"github.com/gofiber/fiber/v2"
9-
"github.com/gofiber/websocket/v2"
109
"github.com/google/uuid"
1110
"github.com/mudler/LocalAI/core/config"
1211
fiberContext "github.com/mudler/LocalAI/core/http/ctx"
@@ -49,24 +48,24 @@ func readRequest(c *fiber.Ctx, cl *config.BackendConfigLoader, ml *model.ModelLo
4948
return modelFile, input, err
5049
}
5150

52-
func readWSRequest(c *websocket.Conn, cl *config.BackendConfigLoader, ml *model.ModelLoader, o *config.ApplicationConfig, firstModel bool) (string, *schema.OpenAIRequest, error) {
53-
input := new(schema.OpenAIRequest)
51+
// func readWSRequest(c *websocket.Conn, cl *config.BackendConfigLoader, ml *model.ModelLoader, o *config.ApplicationConfig, firstModel bool) (string, *schema.OpenAIRequest, error) {
52+
// input := new(schema.OpenAIRequest)
5453

55-
input.Model = c.Query("name")
54+
// input.Model = c.Query("name")
5655

57-
received, _ := json.Marshal(input)
56+
// received, _ := json.Marshal(input)
5857

59-
ctx, cancel := context.WithCancel(o.Context)
58+
// ctx, cancel := context.WithCancel(o.Context)
6059

61-
input.Context = ctx
62-
input.Cancel = cancel
60+
// input.Context = ctx
61+
// input.Cancel = cancel
6362

64-
log.Debug().Msgf("Request received: %s", string(received))
63+
// log.Debug().Msgf("Request received: %s", string(received))
6564

66-
modelFile, err := fiberContext.ModelFromContext(c, cl, ml, input.Model, firstModel)
65+
// modelFile, err := fiberContext.ModelFromContext(c, cl, ml, input.Model, firstModel)
6766

68-
return modelFile, input, err
69-
}
67+
// return modelFile, input, err
68+
// }
7069

7170
func updateRequestConfig(config *config.BackendConfig, input *schema.OpenAIRequest) {
7271
if input.Echo {

0 commit comments

Comments
 (0)