- Add LiteLLM provider with LLM_PROVIDER env var support - Add Fake LLM provider for testing - Add action registry with 17 AI actions - Add permission checker with role verification - Add UI events in chat responses (fill_form, open_preview, etc) - Add versioned prompt files system - Add confirm action endpoint - Add 80 unit tests New endpoints: - POST /api/ai/actions/confirm New files: - src/handlers/actions.rs - src/handlers/confirm_action.rs - src/services/action_confirmation.rs - src/prompts.rs - src/tests.rs - prompts/v1/*.txt
30 lines
844 B
Rust
30 lines
844 B
Rust
use axum::{extract::State, Json};
|
|
|
|
use crate::{
|
|
error::AppError,
|
|
handlers::actions::{ConfirmActionRequest, ConfirmActionResponse},
|
|
services::action_confirmation::ActionConfirmationService,
|
|
state::AppState,
|
|
};
|
|
|
|
pub async fn confirm_action(
|
|
State(state): State<AppState>,
|
|
Json(request): Json<ConfirmActionRequest>,
|
|
) -> Result<Json<ConfirmActionResponse>, AppError> {
|
|
if request.conversation_id.is_empty() {
|
|
return Err(AppError::BadRequest("conversation_id is required".to_string()));
|
|
}
|
|
|
|
if request.action.is_empty() {
|
|
return Err(AppError::BadRequest("action is required".to_string()));
|
|
}
|
|
|
|
let user_id = request.conversation_id.clone();
|
|
|
|
let response = state
|
|
.action_confirmation_service
|
|
.confirm_action(request, &user_id)
|
|
.await?;
|
|
|
|
Ok(Json(response))
|
|
}
|