Remove runtime scheme compatibility
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import create_engine, text
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -14,32 +14,6 @@ class Base(DeclarativeBase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def ensure_schema_compatibility() -> None:
|
|
||||||
"""Best-effort lightweight migrations for SQLite deployments."""
|
|
||||||
if engine.dialect.name != "sqlite":
|
|
||||||
return
|
|
||||||
|
|
||||||
with engine.begin() as conn:
|
|
||||||
columns = {
|
|
||||||
row[1]
|
|
||||||
for row in conn.execute(text("PRAGMA table_info(assistants)"))
|
|
||||||
}
|
|
||||||
if "voice_output_enabled" not in columns:
|
|
||||||
conn.execute(
|
|
||||||
text(
|
|
||||||
"ALTER TABLE assistants "
|
|
||||||
"ADD COLUMN voice_output_enabled BOOLEAN DEFAULT 1"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
conn.execute(
|
|
||||||
text(
|
|
||||||
"UPDATE assistants "
|
|
||||||
"SET voice_output_enabled = 1 "
|
|
||||||
"WHERE voice_output_enabled IS NULL"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_db():
|
def get_db():
|
||||||
db = SessionLocal()
|
db = SessionLocal()
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from .db import Base, engine, ensure_schema_compatibility
|
from .db import Base, engine
|
||||||
from .routers import assistants, voices, workflows, history, knowledge, llm, asr, tools
|
from .routers import assistants, voices, workflows, history, knowledge, llm, asr, tools
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,6 @@ from .routers import assistants, voices, workflows, history, knowledge, llm, asr
|
|||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
# 启动时创建表
|
# 启动时创建表
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
ensure_schema_compatibility()
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ def init_default_assistants():
|
|||||||
opener="你好!我是AI助手,有什么可以帮你的吗?",
|
opener="你好!我是AI助手,有什么可以帮你的吗?",
|
||||||
prompt="你是一个友好的AI助手,请用简洁清晰的语言回答用户的问题。",
|
prompt="你是一个友好的AI助手,请用简洁清晰的语言回答用户的问题。",
|
||||||
language="zh",
|
language="zh",
|
||||||
|
voice_output_enabled=True,
|
||||||
voice="anna",
|
voice="anna",
|
||||||
speed=1.0,
|
speed=1.0,
|
||||||
hotwords=[],
|
hotwords=[],
|
||||||
@@ -134,6 +135,7 @@ def init_default_assistants():
|
|||||||
opener="您好,欢迎致电客服中心,请问有什么可以帮您?",
|
opener="您好,欢迎致电客服中心,请问有什么可以帮您?",
|
||||||
prompt="你是一个专业的客服人员,耐心解答客户问题,提供优质的服务体验。",
|
prompt="你是一个专业的客服人员,耐心解答客户问题,提供优质的服务体验。",
|
||||||
language="zh",
|
language="zh",
|
||||||
|
voice_output_enabled=True,
|
||||||
voice="bella",
|
voice="bella",
|
||||||
speed=1.0,
|
speed=1.0,
|
||||||
hotwords=["客服", "投诉", "咨询"],
|
hotwords=["客服", "投诉", "咨询"],
|
||||||
@@ -149,6 +151,7 @@ def init_default_assistants():
|
|||||||
opener="Hello! I'm your English learning companion. How can I help you today?",
|
opener="Hello! I'm your English learning companion. How can I help you today?",
|
||||||
prompt="You are a friendly English tutor. Help users practice English conversation and explain grammar points clearly.",
|
prompt="You are a friendly English tutor. Help users practice English conversation and explain grammar points clearly.",
|
||||||
language="en",
|
language="en",
|
||||||
|
voice_output_enabled=True,
|
||||||
voice="alex",
|
voice="alex",
|
||||||
speed=1.0,
|
speed=1.0,
|
||||||
hotwords=["grammar", "vocabulary", "practice"],
|
hotwords=["grammar", "vocabulary", "practice"],
|
||||||
|
|||||||
Reference in New Issue
Block a user