feat(room): 修改 AI use_exact 默认值为 true
- room/src/ai.rs: use_exact 默认值从 false 改为 true - 新增 migration: m20260428_000002_default_use_exact_true
This commit is contained in:
parent
aab9f0dbf1
commit
18917b6de1
@ -4,6 +4,7 @@ mod m20260420_000003_add_model_id_to_room_message;
|
|||||||
pub mod m20260421_000001_add_agent_type_to_room_ai;
|
pub mod m20260421_000001_add_agent_type_to_room_ai;
|
||||||
pub mod m20260426_000001_add_thinking_content_to_room_message;
|
pub mod m20260426_000001_add_thinking_content_to_room_message;
|
||||||
pub mod m20260428_000001_backfill_content_tsv;
|
pub mod m20260428_000001_backfill_content_tsv;
|
||||||
|
pub mod m20260428_000002_default_use_exact_true;
|
||||||
|
|
||||||
pub async fn execute_sql(manager: &SchemaManager<'_>, sql: &str) -> Result<(), DbErr> {
|
pub async fn execute_sql(manager: &SchemaManager<'_>, sql: &str) -> Result<(), DbErr> {
|
||||||
for stmt in split_sql_statements(sql) {
|
for stmt in split_sql_statements(sql) {
|
||||||
@ -93,6 +94,7 @@ impl MigratorTrait for Migrator {
|
|||||||
Box::new(m20260421_000001_add_agent_type_to_room_ai::Migration),
|
Box::new(m20260421_000001_add_agent_type_to_room_ai::Migration),
|
||||||
Box::new(m20260426_000001_add_thinking_content_to_room_message::Migration),
|
Box::new(m20260426_000001_add_thinking_content_to_room_message::Migration),
|
||||||
Box::new(m20260428_000001_backfill_content_tsv::Migration),
|
Box::new(m20260428_000001_backfill_content_tsv::Migration),
|
||||||
|
Box::new(m20260428_000002_default_use_exact_true::Migration),
|
||||||
// Repo tables
|
// Repo tables
|
||||||
Box::new(m20250628_000028_create_repo::Migration),
|
Box::new(m20250628_000028_create_repo::Migration),
|
||||||
Box::new(m20250628_000029_create_repo_branch::Migration),
|
Box::new(m20250628_000029_create_repo_branch::Migration),
|
||||||
|
|||||||
17
libs/migrate/m20260428_000002_default_use_exact_true.rs
Normal file
17
libs/migrate/m20260428_000002_default_use_exact_true.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
let sql = include_str!("sql/m20260428_000002_default_use_exact_true.sql");
|
||||||
|
super::execute_sql(manager, sql).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
// No-op: data migration is non-reversible
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
-- Fix: set use_exact = true for all existing room_ai records
|
||||||
|
-- This changes the default behavior so AI only responds when explicitly @mentioned.
|
||||||
|
-- Previously use_exact defaulted to false, causing AI to reply to every message.
|
||||||
|
UPDATE room_ai SET use_exact = true WHERE use_exact = false;
|
||||||
@ -70,7 +70,7 @@ impl RoomService {
|
|||||||
active.max_tokens = Set(request.max_tokens);
|
active.max_tokens = Set(request.max_tokens);
|
||||||
}
|
}
|
||||||
if request.use_exact.is_some() {
|
if request.use_exact.is_some() {
|
||||||
active.use_exact = Set(request.use_exact.unwrap_or(false));
|
active.use_exact = Set(request.use_exact.unwrap_or(true));
|
||||||
}
|
}
|
||||||
if request.think.is_some() {
|
if request.think.is_some() {
|
||||||
active.think = Set(request.think.unwrap_or(false));
|
active.think = Set(request.think.unwrap_or(false));
|
||||||
@ -97,7 +97,7 @@ impl RoomService {
|
|||||||
system_prompt: Set(request.system_prompt),
|
system_prompt: Set(request.system_prompt),
|
||||||
temperature: Set(request.temperature),
|
temperature: Set(request.temperature),
|
||||||
max_tokens: Set(request.max_tokens),
|
max_tokens: Set(request.max_tokens),
|
||||||
use_exact: Set(request.use_exact.unwrap_or(false)),
|
use_exact: Set(request.use_exact.unwrap_or(true)),
|
||||||
think: Set(request.think.unwrap_or(false)),
|
think: Set(request.think.unwrap_or(false)),
|
||||||
stream: Set(request.stream.unwrap_or(false)),
|
stream: Set(request.stream.unwrap_or(false)),
|
||||||
min_score: Set(request.min_score),
|
min_score: Set(request.min_score),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user