feat: Ear and Mouth

This commit is contained in:
aki
2026-04-20 17:57:27 +09:00
parent bb6dbc6313
commit 66c529e4b1
34 changed files with 1863 additions and 135 deletions
+4 -2
View File
@@ -83,7 +83,8 @@ CREATE TABLE IF NOT EXISTS providers (
'minimax-speech',
'volcengine-speech',
'alibabacloud-speech',
'microsoft-speech'
'microsoft-speech',
'google-speech'
))
);
@@ -108,7 +109,7 @@ CREATE TABLE IF NOT EXISTS models (
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT models_provider_id_model_id_unique UNIQUE (provider_id, model_id),
CONSTRAINT models_type_check CHECK (type IN ('chat', 'embedding', 'speech'))
CONSTRAINT models_type_check CHECK (type IN ('chat', 'embedding', 'speech', 'transcription'))
);
CREATE TABLE IF NOT EXISTS model_variants (
@@ -170,6 +171,7 @@ CREATE TABLE IF NOT EXISTS bots (
image_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
discuss_probe_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
tts_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
transcription_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
browser_context_id UUID REFERENCES browser_contexts(id) ON DELETE SET NULL,
persist_full_tool_results BOOLEAN NOT NULL DEFAULT false,
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
@@ -0,0 +1,33 @@
-- 0069_add_transcription_models_and_google_speech
-- Revert transcription model type and Google speech provider support.
DELETE FROM models WHERE type = 'transcription';
DELETE FROM providers WHERE client_type = 'google-speech';
ALTER TABLE models
DROP CONSTRAINT IF EXISTS models_type_check;
ALTER TABLE models
ADD CONSTRAINT models_type_check CHECK (type IN ('chat', 'embedding', 'speech'));
ALTER TABLE providers
DROP CONSTRAINT IF EXISTS providers_client_type_check;
ALTER TABLE providers
ADD CONSTRAINT providers_client_type_check CHECK (client_type IN (
'openai-responses',
'openai-completions',
'anthropic-messages',
'google-generative-ai',
'openai-codex',
'github-copilot',
'edge-speech',
'openai-speech',
'openrouter-speech',
'elevenlabs-speech',
'deepgram-speech',
'minimax-speech',
'volcengine-speech',
'alibabacloud-speech',
'microsoft-speech'
));
@@ -0,0 +1,31 @@
-- 0069_add_transcription_models_and_google_speech
-- Expand unified speech domain to support transcription models and Google speech providers.
ALTER TABLE providers
DROP CONSTRAINT IF EXISTS providers_client_type_check;
ALTER TABLE providers
ADD CONSTRAINT providers_client_type_check CHECK (client_type IN (
'openai-responses',
'openai-completions',
'anthropic-messages',
'google-generative-ai',
'openai-codex',
'github-copilot',
'edge-speech',
'openai-speech',
'openrouter-speech',
'elevenlabs-speech',
'deepgram-speech',
'minimax-speech',
'volcengine-speech',
'alibabacloud-speech',
'microsoft-speech',
'google-speech'
));
ALTER TABLE models
DROP CONSTRAINT IF EXISTS models_type_check;
ALTER TABLE models
ADD CONSTRAINT models_type_check CHECK (type IN ('chat', 'embedding', 'speech', 'transcription'));
@@ -0,0 +1,8 @@
-- 0070_add_bot_transcription_model
-- Remove bots.transcription_model_id.
ALTER TABLE bots
DROP CONSTRAINT IF EXISTS bots_transcription_model_id_fkey;
ALTER TABLE bots
DROP COLUMN IF EXISTS transcription_model_id;
@@ -0,0 +1,5 @@
-- 0070_add_bot_transcription_model
-- Add bots.transcription_model_id for bot-level speech-to-text defaults.
ALTER TABLE bots
ADD COLUMN IF NOT EXISTS transcription_model_id UUID REFERENCES models(id) ON DELETE SET NULL;
+39 -12
View File
@@ -27,7 +27,8 @@ WHERE client_type NOT IN (
'minimax-speech',
'volcengine-speech',
'alibabacloud-speech',
'microsoft-speech'
'microsoft-speech',
'google-speech'
)
ORDER BY created_at DESC;
@@ -59,7 +60,8 @@ WHERE client_type NOT IN (
'minimax-speech',
'volcengine-speech',
'alibabacloud-speech',
'microsoft-speech'
'microsoft-speech',
'google-speech'
);
-- name: CreateModel :one
@@ -86,7 +88,7 @@ ORDER BY created_at DESC;
-- name: ListModels :many
SELECT * FROM models
WHERE type != 'speech'
WHERE type NOT IN ('speech', 'transcription')
ORDER BY created_at DESC;
-- name: ListModelsByType :many
@@ -97,7 +99,7 @@ ORDER BY created_at DESC;
-- name: ListModelsByProviderID :many
SELECT * FROM models
WHERE provider_id = sqlc.arg(provider_id)
AND type != 'speech'
AND type NOT IN ('speech', 'transcription')
ORDER BY created_at DESC;
-- name: ListModelsByProviderIDAndType :many
@@ -136,9 +138,15 @@ DELETE FROM models
WHERE provider_id = sqlc.arg(provider_id)
AND model_id = sqlc.arg(model_id);
-- name: DeleteModelByProviderAndType :exec
DELETE FROM models
WHERE provider_id = sqlc.arg(provider_id)
AND model_id = sqlc.arg(model_id)
AND type = sqlc.arg(type);
-- name: CountModels :one
SELECT COUNT(*) FROM models
WHERE type != 'speech';
WHERE type NOT IN ('speech', 'transcription');
-- name: CountModelsByType :one
SELECT COUNT(*) FROM models WHERE type = sqlc.arg(type);
@@ -150,11 +158,6 @@ VALUES (sqlc.arg(name), sqlc.arg(client_type), sqlc.arg(icon), false, sqlc.arg(c
ON CONFLICT (name) DO UPDATE SET
icon = EXCLUDED.icon,
client_type = EXCLUDED.client_type,
config = CASE
WHEN providers.config->>'api_key' IS NOT NULL AND providers.config->>'api_key' != ''
THEN jsonb_set(EXCLUDED.config, '{api_key}', providers.config->'api_key')
ELSE EXCLUDED.config
END,
updated_at = now()
RETURNING *;
@@ -173,7 +176,7 @@ SELECT m.*
FROM models m
JOIN providers p ON m.provider_id = p.id
WHERE p.enable = true
AND m.type != 'speech'
AND m.type NOT IN ('speech', 'transcription')
ORDER BY m.created_at DESC;
-- name: ListEnabledModelsByType :many
@@ -227,7 +230,8 @@ WHERE client_type IN (
'minimax-speech',
'volcengine-speech',
'alibabacloud-speech',
'microsoft-speech'
'microsoft-speech',
'google-speech'
)
ORDER BY created_at DESC;
@@ -250,3 +254,26 @@ SELECT * FROM models
WHERE provider_id = sqlc.arg(provider_id)
AND model_id = sqlc.arg(model_id)
LIMIT 1;
-- name: GetTranscriptionModelWithProvider :one
SELECT
m.*,
p.client_type AS provider_type
FROM models m
JOIN providers p ON p.id = m.provider_id
WHERE m.id = sqlc.arg(id)
AND m.type = 'transcription';
-- name: ListTranscriptionModels :many
SELECT m.*,
p.client_type AS provider_type
FROM models m
JOIN providers p ON p.id = m.provider_id
WHERE m.type = 'transcription'
ORDER BY m.created_at DESC;
-- name: ListTranscriptionModelsByProviderID :many
SELECT * FROM models
WHERE provider_id = sqlc.arg(provider_id)
AND type = 'transcription'
ORDER BY created_at DESC;
+7 -1
View File
@@ -19,6 +19,7 @@ SELECT
memory_providers.id AS memory_provider_id,
image_models.id AS image_model_id,
tts_models.id AS tts_model_id,
transcription_models.id AS transcription_model_id,
browser_contexts.id AS browser_context_id,
bots.persist_full_tool_results
FROM bots
@@ -30,6 +31,7 @@ LEFT JOIN models AS image_models ON image_models.id = bots.image_model_id
LEFT JOIN search_providers ON search_providers.id = bots.search_provider_id
LEFT JOIN memory_providers ON memory_providers.id = bots.memory_provider_id
LEFT JOIN models AS tts_models ON tts_models.id = bots.tts_model_id
LEFT JOIN models AS transcription_models ON transcription_models.id = bots.transcription_model_id
LEFT JOIN browser_contexts ON browser_contexts.id = bots.browser_context_id
WHERE bots.id = $1;
@@ -54,11 +56,12 @@ WITH updated AS (
memory_provider_id = COALESCE(sqlc.narg(memory_provider_id)::uuid, bots.memory_provider_id),
image_model_id = COALESCE(sqlc.narg(image_model_id)::uuid, bots.image_model_id),
tts_model_id = COALESCE(sqlc.narg(tts_model_id)::uuid, bots.tts_model_id),
transcription_model_id = COALESCE(sqlc.narg(transcription_model_id)::uuid, bots.transcription_model_id),
browser_context_id = COALESCE(sqlc.narg(browser_context_id)::uuid, bots.browser_context_id),
persist_full_tool_results = sqlc.arg(persist_full_tool_results),
updated_at = now()
WHERE bots.id = sqlc.arg(id)
RETURNING bots.id, bots.language, bots.reasoning_enabled, bots.reasoning_effort, bots.heartbeat_enabled, bots.heartbeat_interval, bots.heartbeat_prompt, bots.compaction_enabled, bots.compaction_threshold, bots.compaction_ratio, bots.timezone, bots.chat_model_id, bots.heartbeat_model_id, bots.compaction_model_id, bots.title_model_id, bots.image_model_id, bots.search_provider_id, bots.memory_provider_id, bots.tts_model_id, bots.browser_context_id, bots.persist_full_tool_results
RETURNING bots.id, bots.language, bots.reasoning_enabled, bots.reasoning_effort, bots.heartbeat_enabled, bots.heartbeat_interval, bots.heartbeat_prompt, bots.compaction_enabled, bots.compaction_threshold, bots.compaction_ratio, bots.timezone, bots.chat_model_id, bots.heartbeat_model_id, bots.compaction_model_id, bots.title_model_id, bots.image_model_id, bots.search_provider_id, bots.memory_provider_id, bots.tts_model_id, bots.transcription_model_id, bots.browser_context_id, bots.persist_full_tool_results
)
SELECT
updated.id AS bot_id,
@@ -80,6 +83,7 @@ SELECT
memory_providers.id AS memory_provider_id,
image_models.id AS image_model_id,
tts_models.id AS tts_model_id,
transcription_models.id AS transcription_model_id,
browser_contexts.id AS browser_context_id,
updated.persist_full_tool_results
FROM updated
@@ -91,6 +95,7 @@ LEFT JOIN models AS image_models ON image_models.id = updated.image_model_id
LEFT JOIN search_providers ON search_providers.id = updated.search_provider_id
LEFT JOIN memory_providers ON memory_providers.id = updated.memory_provider_id
LEFT JOIN models AS tts_models ON tts_models.id = updated.tts_model_id
LEFT JOIN models AS transcription_models ON transcription_models.id = updated.transcription_model_id
LEFT JOIN browser_contexts ON browser_contexts.id = updated.browser_context_id;
-- name: DeleteSettingsByBotID :exec
@@ -112,6 +117,7 @@ SET language = 'auto',
search_provider_id = NULL,
memory_provider_id = NULL,
tts_model_id = NULL,
transcription_model_id = NULL,
browser_context_id = NULL,
persist_full_tool_results = false,
updated_at = now()