feat(ai): agent loop Phase 2 — SQL execution tools, risk classification, and streaming tool calls
feat(ai): agent loop Phase 2 — SQL execution tools, risk classification, and streaming tool calls
This commit is contained in:
19 files changed
+526
-44
No files matched your search
@@ -7,9 +7,12 @@ use futures::stream::Stream;
|
||||
use serde::Deserialize;
|
||||
|
||||
use dbx_core::agent_events::AgentEvent;
|
||||
use dbx_core::agent_events::AgentEvent;
|
||||
use dbx_core::agent_loop::{run_agent_loop, AgentLoopContext};
|
||||
use dbx_core::agent_loop::{run_agent_loop, AgentLoopContext};
|
||||
use dbx_core::ai::{AiCompletionRequest, AiConfig, AiConversation, AiModelInfo, AiStreamChunk, AiTestConnectionResult};
|
||||
use dbx_core::models::connection::DatabaseType;
|
||||
use dbx_core::models::connection::DatabaseType;
|
||||
|
||||
use crate::error::AppError;
|
||||
use crate::state::WebState;
|
||||
@@ -69,6 +72,14 @@ pub struct AiAgentStreamRequest {
|
||||
pub connection_id: String,
|
||||
pub database: String,
|
||||
pub db_type: String,
|
||||
/// Agent mode: "ask" (read-only tools) or "agent" (all tools including execute_query).
|
||||
/// Defaults to "ask" if not provided.
|
||||
#[serde(default = "default_agent_mode")]
|
||||
pub mode: String,
|
||||
}
|
||||
|
||||
fn default_agent_mode() -> String {
|
||||
"ask".to_string()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -217,6 +228,7 @@ pub async fn ai_agent_stream(
|
||||
let req_messages = request.messages;
|
||||
let req_max_tokens = request.max_tokens;
|
||||
let req_temperature = request.temperature;
|
||||
let is_agent_mode = body.mode == "agent";
|
||||
let tx2 = tx.clone();
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let rt =
|
||||
@@ -234,6 +246,7 @@ pub async fn ai_agent_stream(
|
||||
&cancelled,
|
||||
req_max_tokens,
|
||||
req_temperature,
|
||||
is_agent_mode,
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
Reference in new issue
Block a user