feat: heartbeat (#108)

* feat: heartbeat

* feat: independent heartbeat model
This commit is contained in:
Acbox Liu
2026-02-24 19:25:02 +08:00
committed by Ran
parent a9680587c6
commit 2f38662d4d
47 changed files with 2276 additions and 43 deletions
+82 -6
View File
@@ -14,7 +14,7 @@ import (
const createBot = `-- name: CreateBot :one
INSERT INTO bots (owner_user_id, type, display_name, avatar_url, is_active, metadata, status)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, metadata, created_at, updated_at
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
`
type CreateBotParams struct {
@@ -46,6 +46,9 @@ type CreateBotRow struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -81,6 +84,9 @@ func (q *Queries) CreateBot(ctx context.Context, arg CreateBotParams) (CreateBot
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.SearchProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
@@ -112,7 +118,7 @@ func (q *Queries) DeleteBotMember(ctx context.Context, arg DeleteBotMemberParams
}
const getBotByID = `-- name: GetBotByID :one
SELECT id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, metadata, created_at, updated_at
SELECT id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
FROM bots
WHERE id = $1
`
@@ -136,6 +142,9 @@ type GetBotByIDRow struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -163,6 +172,9 @@ func (q *Queries) GetBotByID(ctx context.Context, id pgtype.UUID) (GetBotByIDRow
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.SearchProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
@@ -227,7 +239,7 @@ func (q *Queries) ListBotMembers(ctx context.Context, botID pgtype.UUID) ([]BotM
}
const listBotsByMember = `-- name: ListBotsByMember :many
SELECT b.id, b.owner_user_id, b.type, b.display_name, b.avatar_url, b.is_active, b.status, b.max_context_load_time, b.max_context_tokens, b.max_inbox_items, b.language, b.allow_guest, b.reasoning_enabled, b.reasoning_effort, b.chat_model_id, b.memory_model_id, b.embedding_model_id, b.search_provider_id, b.metadata, b.created_at, b.updated_at
SELECT b.id, b.owner_user_id, b.type, b.display_name, b.avatar_url, b.is_active, b.status, b.max_context_load_time, b.max_context_tokens, b.max_inbox_items, b.language, b.allow_guest, b.reasoning_enabled, b.reasoning_effort, b.chat_model_id, b.memory_model_id, b.embedding_model_id, b.search_provider_id, b.heartbeat_enabled, b.heartbeat_interval, b.heartbeat_prompt, b.metadata, b.created_at, b.updated_at
FROM bots b
JOIN bot_members m ON m.bot_id = b.id
WHERE m.user_id = $1
@@ -253,6 +265,9 @@ type ListBotsByMemberRow struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -286,6 +301,9 @@ func (q *Queries) ListBotsByMember(ctx context.Context, userID pgtype.UUID) ([]L
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.SearchProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
@@ -301,7 +319,7 @@ func (q *Queries) ListBotsByMember(ctx context.Context, userID pgtype.UUID) ([]L
}
const listBotsByOwner = `-- name: ListBotsByOwner :many
SELECT id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, metadata, created_at, updated_at
SELECT id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
FROM bots
WHERE owner_user_id = $1
ORDER BY created_at DESC
@@ -326,6 +344,9 @@ type ListBotsByOwnerRow struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -359,6 +380,9 @@ func (q *Queries) ListBotsByOwner(ctx context.Context, ownerUserID pgtype.UUID)
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.SearchProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
@@ -373,12 +397,52 @@ func (q *Queries) ListBotsByOwner(ctx context.Context, ownerUserID pgtype.UUID)
return items, nil
}
const listHeartbeatEnabledBots = `-- name: ListHeartbeatEnabledBots :many
SELECT id, owner_user_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt
FROM bots
WHERE heartbeat_enabled = true AND status = 'ready'
`
type ListHeartbeatEnabledBotsRow struct {
ID pgtype.UUID `json:"id"`
OwnerUserID pgtype.UUID `json:"owner_user_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
}
func (q *Queries) ListHeartbeatEnabledBots(ctx context.Context) ([]ListHeartbeatEnabledBotsRow, error) {
rows, err := q.db.Query(ctx, listHeartbeatEnabledBots)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListHeartbeatEnabledBotsRow
for rows.Next() {
var i ListHeartbeatEnabledBotsRow
if err := rows.Scan(
&i.ID,
&i.OwnerUserID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateBotOwner = `-- name: UpdateBotOwner :one
UPDATE bots
SET owner_user_id = $2,
updated_at = now()
WHERE id = $1
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, metadata, created_at, updated_at
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
`
type UpdateBotOwnerParams struct {
@@ -405,6 +469,9 @@ type UpdateBotOwnerRow struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -432,6 +499,9 @@ func (q *Queries) UpdateBotOwner(ctx context.Context, arg UpdateBotOwnerParams)
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.SearchProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
@@ -447,7 +517,7 @@ SET display_name = $2,
metadata = $5,
updated_at = now()
WHERE id = $1
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, metadata, created_at, updated_at
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, max_inbox_items, language, allow_guest, reasoning_enabled, reasoning_effort, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
`
type UpdateBotProfileParams struct {
@@ -477,6 +547,9 @@ type UpdateBotProfileRow struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -510,6 +583,9 @@ func (q *Queries) UpdateBotProfile(ctx context.Context, arg UpdateBotProfilePara
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.SearchProviderID,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.Metadata,
&i.CreatedAt,
&i.UpdatedAt,
+1 -1
View File
@@ -590,7 +590,7 @@ WITH updated AS (
SET display_name = $1,
updated_at = now()
WHERE bots.id = $2
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, allow_guest, reasoning_enabled, reasoning_effort, max_inbox_items, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, metadata, created_at, updated_at
RETURNING id, owner_user_id, type, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, allow_guest, reasoning_enabled, reasoning_effort, max_inbox_items, chat_model_id, memory_model_id, embedding_model_id, search_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, heartbeat_model_id, metadata, created_at, updated_at
)
SELECT
updated.id AS id,
+128
View File
@@ -0,0 +1,128 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: heartbeat_logs.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const completeHeartbeatLog = `-- name: CompleteHeartbeatLog :one
UPDATE bot_heartbeat_logs
SET status = $2,
result_text = $3,
error_message = $4,
usage = $5,
completed_at = now()
WHERE id = $1
RETURNING id, bot_id, status, result_text, error_message, usage, started_at, completed_at
`
type CompleteHeartbeatLogParams struct {
ID pgtype.UUID `json:"id"`
Status string `json:"status"`
ResultText string `json:"result_text"`
ErrorMessage string `json:"error_message"`
Usage []byte `json:"usage"`
}
func (q *Queries) CompleteHeartbeatLog(ctx context.Context, arg CompleteHeartbeatLogParams) (BotHeartbeatLog, error) {
row := q.db.QueryRow(ctx, completeHeartbeatLog,
arg.ID,
arg.Status,
arg.ResultText,
arg.ErrorMessage,
arg.Usage,
)
var i BotHeartbeatLog
err := row.Scan(
&i.ID,
&i.BotID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
)
return i, err
}
const createHeartbeatLog = `-- name: CreateHeartbeatLog :one
INSERT INTO bot_heartbeat_logs (bot_id, started_at)
VALUES ($1, now())
RETURNING id, bot_id, status, result_text, error_message, usage, started_at, completed_at
`
func (q *Queries) CreateHeartbeatLog(ctx context.Context, botID pgtype.UUID) (BotHeartbeatLog, error) {
row := q.db.QueryRow(ctx, createHeartbeatLog, botID)
var i BotHeartbeatLog
err := row.Scan(
&i.ID,
&i.BotID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
)
return i, err
}
const deleteHeartbeatLogsByBot = `-- name: DeleteHeartbeatLogsByBot :exec
DELETE FROM bot_heartbeat_logs WHERE bot_id = $1
`
func (q *Queries) DeleteHeartbeatLogsByBot(ctx context.Context, botID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteHeartbeatLogsByBot, botID)
return err
}
const listHeartbeatLogsByBot = `-- name: ListHeartbeatLogsByBot :many
SELECT id, bot_id, status, result_text, error_message, usage, started_at, completed_at
FROM bot_heartbeat_logs
WHERE bot_id = $1
AND ($2::timestamptz IS NULL OR started_at < $2::timestamptz)
ORDER BY started_at DESC
LIMIT $3
`
type ListHeartbeatLogsByBotParams struct {
BotID pgtype.UUID `json:"bot_id"`
Column2 pgtype.Timestamptz `json:"column_2"`
Limit int32 `json:"limit"`
}
func (q *Queries) ListHeartbeatLogsByBot(ctx context.Context, arg ListHeartbeatLogsByBotParams) ([]BotHeartbeatLog, error) {
rows, err := q.db.Query(ctx, listHeartbeatLogsByBot, arg.BotID, arg.Column2, arg.Limit)
if err != nil {
return nil, err
}
defer rows.Close()
var items []BotHeartbeatLog
for rows.Next() {
var i BotHeartbeatLog
if err := rows.Scan(
&i.ID,
&i.BotID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
+15
View File
@@ -27,6 +27,10 @@ type Bot struct {
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
HeartbeatModelID pgtype.UUID `json:"heartbeat_model_id"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
@@ -61,6 +65,17 @@ type BotChannelRoute struct {
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type BotHeartbeatLog struct {
ID pgtype.UUID `json:"id"`
BotID pgtype.UUID `json:"bot_id"`
Status string `json:"status"`
ResultText string `json:"result_text"`
ErrorMessage string `json:"error_message"`
Usage []byte `json:"usage"`
StartedAt pgtype.Timestamptz `json:"started_at"`
CompletedAt pgtype.Timestamptz `json:"completed_at"`
}
type BotHistoryMessage struct {
ID pgtype.UUID `json:"id"`
BotID pgtype.UUID `json:"bot_id"`
+48 -6
View File
@@ -20,9 +20,13 @@ SET max_context_load_time = 1440,
allow_guest = false,
reasoning_enabled = false,
reasoning_effort = 'medium',
heartbeat_enabled = false,
heartbeat_interval = 30,
heartbeat_prompt = '',
chat_model_id = NULL,
memory_model_id = NULL,
embedding_model_id = NULL,
heartbeat_model_id = NULL,
search_provider_id = NULL,
updated_at = now()
WHERE id = $1
@@ -43,14 +47,19 @@ SELECT
bots.allow_guest,
bots.reasoning_enabled,
bots.reasoning_effort,
bots.heartbeat_enabled,
bots.heartbeat_interval,
bots.heartbeat_prompt,
chat_models.id AS chat_model_id,
memory_models.id AS memory_model_id,
embedding_models.id AS embedding_model_id,
heartbeat_models.id AS heartbeat_model_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
LEFT JOIN models AS embedding_models ON embedding_models.id = bots.embedding_model_id
LEFT JOIN models AS heartbeat_models ON heartbeat_models.id = bots.heartbeat_model_id
LEFT JOIN search_providers ON search_providers.id = bots.search_provider_id
WHERE bots.id = $1
`
@@ -64,9 +73,13 @@ type GetSettingsByBotIDRow struct {
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
HeartbeatModelID pgtype.UUID `json:"heartbeat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
}
@@ -82,9 +95,13 @@ func (q *Queries) GetSettingsByBotID(ctx context.Context, id pgtype.UUID) (GetSe
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.ChatModelID,
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.HeartbeatModelID,
&i.SearchProviderID,
)
return i, err
@@ -100,13 +117,17 @@ WITH updated AS (
allow_guest = $5,
reasoning_enabled = $6,
reasoning_effort = $7,
chat_model_id = COALESCE($8::uuid, bots.chat_model_id),
memory_model_id = COALESCE($9::uuid, bots.memory_model_id),
embedding_model_id = COALESCE($10::uuid, bots.embedding_model_id),
search_provider_id = COALESCE($11::uuid, bots.search_provider_id),
heartbeat_enabled = $8,
heartbeat_interval = $9,
heartbeat_prompt = $10,
chat_model_id = COALESCE($11::uuid, bots.chat_model_id),
memory_model_id = COALESCE($12::uuid, bots.memory_model_id),
embedding_model_id = COALESCE($13::uuid, bots.embedding_model_id),
heartbeat_model_id = COALESCE($14::uuid, bots.heartbeat_model_id),
search_provider_id = COALESCE($15::uuid, bots.search_provider_id),
updated_at = now()
WHERE bots.id = $12
RETURNING bots.id, bots.max_context_load_time, bots.max_context_tokens, bots.max_inbox_items, bots.language, bots.allow_guest, bots.reasoning_enabled, bots.reasoning_effort, bots.chat_model_id, bots.memory_model_id, bots.embedding_model_id, bots.search_provider_id
WHERE bots.id = $16
RETURNING bots.id, bots.max_context_load_time, bots.max_context_tokens, bots.max_inbox_items, bots.language, bots.allow_guest, bots.reasoning_enabled, bots.reasoning_effort, bots.heartbeat_enabled, bots.heartbeat_interval, bots.heartbeat_prompt, bots.chat_model_id, bots.memory_model_id, bots.embedding_model_id, bots.heartbeat_model_id, bots.search_provider_id
)
SELECT
updated.id AS bot_id,
@@ -117,14 +138,19 @@ SELECT
updated.allow_guest,
updated.reasoning_enabled,
updated.reasoning_effort,
updated.heartbeat_enabled,
updated.heartbeat_interval,
updated.heartbeat_prompt,
chat_models.id AS chat_model_id,
memory_models.id AS memory_model_id,
embedding_models.id AS embedding_model_id,
heartbeat_models.id AS heartbeat_model_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
LEFT JOIN models AS embedding_models ON embedding_models.id = updated.embedding_model_id
LEFT JOIN models AS heartbeat_models ON heartbeat_models.id = updated.heartbeat_model_id
LEFT JOIN search_providers ON search_providers.id = updated.search_provider_id
`
@@ -136,9 +162,13 @@ type UpsertBotSettingsParams struct {
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
HeartbeatModelID pgtype.UUID `json:"heartbeat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
ID pgtype.UUID `json:"id"`
}
@@ -152,9 +182,13 @@ type UpsertBotSettingsRow struct {
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int32 `json:"heartbeat_interval"`
HeartbeatPrompt string `json:"heartbeat_prompt"`
ChatModelID pgtype.UUID `json:"chat_model_id"`
MemoryModelID pgtype.UUID `json:"memory_model_id"`
EmbeddingModelID pgtype.UUID `json:"embedding_model_id"`
HeartbeatModelID pgtype.UUID `json:"heartbeat_model_id"`
SearchProviderID pgtype.UUID `json:"search_provider_id"`
}
@@ -167,9 +201,13 @@ func (q *Queries) UpsertBotSettings(ctx context.Context, arg UpsertBotSettingsPa
arg.AllowGuest,
arg.ReasoningEnabled,
arg.ReasoningEffort,
arg.HeartbeatEnabled,
arg.HeartbeatInterval,
arg.HeartbeatPrompt,
arg.ChatModelID,
arg.MemoryModelID,
arg.EmbeddingModelID,
arg.HeartbeatModelID,
arg.SearchProviderID,
arg.ID,
)
@@ -183,9 +221,13 @@ func (q *Queries) UpsertBotSettings(ctx context.Context, arg UpsertBotSettingsPa
&i.AllowGuest,
&i.ReasoningEnabled,
&i.ReasoningEffort,
&i.HeartbeatEnabled,
&i.HeartbeatInterval,
&i.HeartbeatPrompt,
&i.ChatModelID,
&i.MemoryModelID,
&i.EmbeddingModelID,
&i.HeartbeatModelID,
&i.SearchProviderID,
)
return i, err