mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
@@ -77,19 +77,13 @@ CREATE TABLE IF NOT EXISTS providers (
|
||||
'github-copilot',
|
||||
'edge-speech',
|
||||
'openai-speech',
|
||||
'openai-transcription',
|
||||
'openrouter-speech',
|
||||
'openrouter-transcription',
|
||||
'elevenlabs-speech',
|
||||
'elevenlabs-transcription',
|
||||
'deepgram-speech',
|
||||
'deepgram-transcription',
|
||||
'minimax-speech',
|
||||
'volcengine-speech',
|
||||
'alibabacloud-speech',
|
||||
'microsoft-speech',
|
||||
'google-speech',
|
||||
'google-transcription'
|
||||
'microsoft-speech'
|
||||
))
|
||||
);
|
||||
|
||||
@@ -114,7 +108,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', 'transcription'))
|
||||
CONSTRAINT models_type_check CHECK (type IN ('chat', 'embedding', 'speech'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS model_variants (
|
||||
@@ -176,7 +170,6 @@ 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,
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
-- 0069_add_transcription_models_and_speech_domain
|
||||
-- Revert transcription model type and speech-domain expansion.
|
||||
|
||||
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'
|
||||
));
|
||||
@@ -1,31 +0,0 @@
|
||||
-- 0069_add_transcription_models_and_speech_domain
|
||||
-- Expand the speech domain to support transcription models and shared 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'));
|
||||
@@ -1,8 +0,0 @@
|
||||
-- 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;
|
||||
@@ -1,5 +0,0 @@
|
||||
-- 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;
|
||||
@@ -1,33 +0,0 @@
|
||||
-- 0071_split_transcription_providers
|
||||
-- Remove dedicated transcription provider client types.
|
||||
|
||||
DELETE FROM providers
|
||||
WHERE client_type IN (
|
||||
'openai-transcription',
|
||||
'openrouter-transcription',
|
||||
'elevenlabs-transcription',
|
||||
'deepgram-transcription',
|
||||
'google-transcription'
|
||||
);
|
||||
|
||||
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'
|
||||
));
|
||||
@@ -1,29 +0,0 @@
|
||||
-- 0071_split_transcription_providers
|
||||
-- Add dedicated transcription provider client types.
|
||||
|
||||
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',
|
||||
'openai-transcription',
|
||||
'openrouter-speech',
|
||||
'openrouter-transcription',
|
||||
'elevenlabs-speech',
|
||||
'elevenlabs-transcription',
|
||||
'deepgram-speech',
|
||||
'deepgram-transcription',
|
||||
'minimax-speech',
|
||||
'volcengine-speech',
|
||||
'alibabacloud-speech',
|
||||
'microsoft-speech',
|
||||
'google-speech',
|
||||
'google-transcription'
|
||||
));
|
||||
+11
-61
@@ -16,27 +16,18 @@ SELECT * FROM providers WHERE id = sqlc.arg(id);
|
||||
-- name: GetProviderByName :one
|
||||
SELECT * FROM providers WHERE name = sqlc.arg(name);
|
||||
|
||||
-- name: GetProviderByClientType :one
|
||||
SELECT * FROM providers WHERE client_type = sqlc.arg(client_type);
|
||||
|
||||
-- name: ListProviders :many
|
||||
SELECT * FROM providers
|
||||
WHERE client_type NOT IN (
|
||||
'edge-speech',
|
||||
'openai-speech',
|
||||
'openai-transcription',
|
||||
'openrouter-speech',
|
||||
'openrouter-transcription',
|
||||
'elevenlabs-speech',
|
||||
'elevenlabs-transcription',
|
||||
'deepgram-speech',
|
||||
'deepgram-transcription',
|
||||
'minimax-speech',
|
||||
'volcengine-speech',
|
||||
'alibabacloud-speech',
|
||||
'microsoft-speech',
|
||||
'google-speech',
|
||||
'google-transcription'
|
||||
'microsoft-speech'
|
||||
)
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
@@ -62,19 +53,13 @@ FROM providers
|
||||
WHERE client_type NOT IN (
|
||||
'edge-speech',
|
||||
'openai-speech',
|
||||
'openai-transcription',
|
||||
'openrouter-speech',
|
||||
'openrouter-transcription',
|
||||
'elevenlabs-speech',
|
||||
'elevenlabs-transcription',
|
||||
'deepgram-speech',
|
||||
'deepgram-transcription',
|
||||
'minimax-speech',
|
||||
'volcengine-speech',
|
||||
'alibabacloud-speech',
|
||||
'microsoft-speech',
|
||||
'google-speech',
|
||||
'google-transcription'
|
||||
'microsoft-speech'
|
||||
);
|
||||
|
||||
-- name: CreateModel :one
|
||||
@@ -101,7 +86,7 @@ ORDER BY created_at DESC;
|
||||
|
||||
-- name: ListModels :many
|
||||
SELECT * FROM models
|
||||
WHERE type NOT IN ('speech', 'transcription')
|
||||
WHERE type != 'speech'
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
-- name: ListModelsByType :many
|
||||
@@ -112,7 +97,7 @@ ORDER BY created_at DESC;
|
||||
-- name: ListModelsByProviderID :many
|
||||
SELECT * FROM models
|
||||
WHERE provider_id = sqlc.arg(provider_id)
|
||||
AND type NOT IN ('speech', 'transcription')
|
||||
AND type != 'speech'
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
-- name: ListModelsByProviderIDAndType :many
|
||||
@@ -151,15 +136,9 @@ 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 NOT IN ('speech', 'transcription');
|
||||
WHERE type != 'speech';
|
||||
|
||||
-- name: CountModelsByType :one
|
||||
SELECT COUNT(*) FROM models WHERE type = sqlc.arg(type);
|
||||
@@ -171,6 +150,11 @@ 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 *;
|
||||
|
||||
@@ -189,7 +173,7 @@ SELECT m.*
|
||||
FROM models m
|
||||
JOIN providers p ON m.provider_id = p.id
|
||||
WHERE p.enable = true
|
||||
AND m.type NOT IN ('speech', 'transcription')
|
||||
AND m.type != 'speech'
|
||||
ORDER BY m.created_at DESC;
|
||||
|
||||
-- name: ListEnabledModelsByType :many
|
||||
@@ -247,17 +231,6 @@ WHERE client_type IN (
|
||||
)
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
-- name: ListTranscriptionProviders :many
|
||||
SELECT * FROM providers
|
||||
WHERE client_type IN (
|
||||
'openai-transcription',
|
||||
'openrouter-transcription',
|
||||
'elevenlabs-transcription',
|
||||
'deepgram-transcription',
|
||||
'google-transcription'
|
||||
)
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
-- name: ListSpeechModels :many
|
||||
SELECT m.*,
|
||||
p.client_type AS provider_type
|
||||
@@ -277,26 +250,3 @@ 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;
|
||||
|
||||
@@ -19,7 +19,6 @@ 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
|
||||
@@ -31,7 +30,6 @@ 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;
|
||||
|
||||
@@ -56,12 +54,11 @@ 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.transcription_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.browser_context_id, bots.persist_full_tool_results
|
||||
)
|
||||
SELECT
|
||||
updated.id AS bot_id,
|
||||
@@ -83,7 +80,6 @@ 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
|
||||
@@ -95,7 +91,6 @@ 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
|
||||
@@ -117,7 +112,6 @@ 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()
|
||||
|
||||
Reference in New Issue
Block a user