feat: configure OpenAI-compatible AI services and discover models
douyin-release-gate / verify (push) Failing after 19m29s
douyin-release-gate / verify (push) Failing after 19m29s
This commit is contained in:
@@ -59,6 +59,9 @@ func registerCreator(app *fiber.App, store *creator.Store, phaseAStore *accountd
|
||||
}
|
||||
|
||||
func registerCreatorWithServices(app *fiber.App, store *creator.Store, phaseAStore *accountdomain.Store, hubStore *hub.Store, analyzer creator.ThemeAnalyzer) {
|
||||
if analyzer == nil && store != nil {
|
||||
analyzer = &creator.ConfiguredOpenAI{Store: store}
|
||||
}
|
||||
registerEnvironmentLoginRoutes(app, store, hubStore)
|
||||
registerAccountEventRoutes(app, store)
|
||||
registerPrivateMessageRoutes(app, store, gatewayPrivateMessageSender(hubStore, store))
|
||||
@@ -75,6 +78,21 @@ func registerCreatorWithServices(app *fiber.App, store *creator.Store, phaseASto
|
||||
app.Post(path, func(c fiber.Ctx) error { return creatorError(c, creator.ErrConflict) })
|
||||
}
|
||||
|
||||
app.Post("/api/creator/settings/models", func(c fiber.Ctx) error {
|
||||
var connection creator.AIConnection
|
||||
if err := decodeCreator(c, &connection); err != nil {
|
||||
return creatorError(c, err)
|
||||
}
|
||||
models, err := creator.ListOpenAIModels(c.Context(), connection, nil)
|
||||
if err != nil {
|
||||
if errors.Is(err, creator.ErrInvalid) {
|
||||
return creatorError(c, err)
|
||||
}
|
||||
return c.Status(fiber.StatusBadGateway).JSON(fiber.Map{"message": err.Error()})
|
||||
}
|
||||
return c.JSON(fiber.Map{"models": models})
|
||||
})
|
||||
|
||||
app.Get("/api/creator/settings", func(c fiber.Ctx) error {
|
||||
settings, err := store.GetSettings(c.Context())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user