diff --git a/db/queries/settings.sql b/db/queries/settings.sql index 33651ecf..31b386e7 100644 --- a/db/queries/settings.sql +++ b/db/queries/settings.sql @@ -7,7 +7,7 @@ SELECT chat_models.model_id AS chat_model_id, memory_models.model_id AS memory_model_id, embedding_models.model_id AS embedding_model_id, - search_providers.id::text AS search_provider_id + search_providers.id AS search_provider_id FROM bots LEFT JOIN models AS chat_models ON chat_models.id = bots.chat_model_id LEFT JOIN models AS memory_models ON memory_models.id = bots.memory_model_id @@ -37,7 +37,7 @@ SELECT chat_models.model_id AS chat_model_id, memory_models.model_id AS memory_model_id, embedding_models.model_id AS embedding_model_id, - search_providers.id::text AS search_provider_id + search_providers.id AS search_provider_id FROM updated LEFT JOIN models AS chat_models ON chat_models.id = updated.chat_model_id LEFT JOIN models AS memory_models ON memory_models.id = updated.memory_model_id diff --git a/internal/db/sqlc/settings.sql.go b/internal/db/sqlc/settings.sql.go index 9caec573..958b5443 100644 --- a/internal/db/sqlc/settings.sql.go +++ b/internal/db/sqlc/settings.sql.go @@ -38,7 +38,7 @@ SELECT chat_models.model_id AS chat_model_id, memory_models.model_id AS memory_model_id, embedding_models.model_id AS embedding_model_id, - search_providers.id::text AS search_provider_id + search_providers.id AS search_provider_id FROM bots LEFT JOIN models AS chat_models ON chat_models.id = bots.chat_model_id LEFT JOIN models AS memory_models ON memory_models.id = bots.memory_model_id @@ -55,7 +55,7 @@ type GetSettingsByBotIDRow struct { ChatModelID pgtype.Text `json:"chat_model_id"` MemoryModelID pgtype.Text `json:"memory_model_id"` EmbeddingModelID pgtype.Text `json:"embedding_model_id"` - SearchProviderID string `json:"search_provider_id"` + SearchProviderID pgtype.UUID `json:"search_provider_id"` } func (q *Queries) GetSettingsByBotID(ctx context.Context, id pgtype.UUID) (GetSettingsByBotIDRow, error) { @@ -96,7 +96,7 @@ SELECT chat_models.model_id AS chat_model_id, memory_models.model_id AS memory_model_id, embedding_models.model_id AS embedding_model_id, - search_providers.id::text AS search_provider_id + search_providers.id AS search_provider_id FROM updated LEFT JOIN models AS chat_models ON chat_models.id = updated.chat_model_id LEFT JOIN models AS memory_models ON memory_models.id = updated.memory_model_id @@ -123,7 +123,7 @@ type UpsertBotSettingsRow struct { ChatModelID pgtype.Text `json:"chat_model_id"` MemoryModelID pgtype.Text `json:"memory_model_id"` EmbeddingModelID pgtype.Text `json:"embedding_model_id"` - SearchProviderID string `json:"search_provider_id"` + SearchProviderID pgtype.UUID `json:"search_provider_id"` } func (q *Queries) UpsertBotSettings(ctx context.Context, arg UpsertBotSettingsParams) (UpsertBotSettingsRow, error) { diff --git a/internal/settings/service.go b/internal/settings/service.go index 751db3da..838ac03c 100644 --- a/internal/settings/service.go +++ b/internal/settings/service.go @@ -7,6 +7,7 @@ import ( "log/slog" "strings" + "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" "github.com/memohai/memoh/internal/db" @@ -175,13 +176,15 @@ func normalizeBotSettingsFields( chatModelID pgtype.Text, memoryModelID pgtype.Text, embeddingModelID pgtype.Text, - searchProviderID string, + searchProviderID pgtype.UUID, ) Settings { settings := normalizeBotSetting(maxContextLoadTime, language, allowGuest) settings.ChatModelID = strings.TrimSpace(chatModelID.String) settings.MemoryModelID = strings.TrimSpace(memoryModelID.String) settings.EmbeddingModelID = strings.TrimSpace(embeddingModelID.String) - settings.SearchProviderID = strings.TrimSpace(searchProviderID) + if searchProviderID.Valid { + settings.SearchProviderID = uuid.UUID(searchProviderID.Bytes).String() + } return settings }