create table if not exists room_ai
(
    room          uuid                     not null,
    model         uuid                     not null,
    version       uuid,
    call_count    bigint  default 0        not null,
    last_call_at  timestamp with time zone,
    history_limit bigint,
    system_prompt text,
    temperature   double precision,
    max_tokens    bigint,
    use_exact     boolean default false    not null,
    think         boolean default false    not null,
    min_score     real,
    created_at    timestamp with time zone not null,
    updated_at    timestamp with time zone not null,
    stream        boolean default true     not null,
    agent_type    varchar(50),
    primary key (room, model)
);

create index if not exists idx_room_ai_agent_type
    on room_ai (agent_type)
    where (agent_type IS NOT NULL);
