mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-12 03:33:48 +00:00
Added tool calling support (#731)
Co-authored-by: krut_ni <nils.kruthoff@dlr.de> Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
266 files changed
+11186
-740
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use log::info;
|
||||
use once_cell::sync::Lazy;
|
||||
use axum::extract::DefaultBodyLimit;
|
||||
use axum::routing::{delete, get, post};
|
||||
use axum::Router;
|
||||
use axum_server::tls_rustls::RustlsConfig;
|
||||
@@ -11,6 +12,10 @@ use crate::network::get_available_port;
|
||||
|
||||
static RUSTLS_CRYPTO_PROVIDER_INIT: Once = Once::new();
|
||||
|
||||
/// The request body limit for one batch of prompt injection filtering. The app caps the text
|
||||
/// it returns to a model well below this, so the limit is headroom, not a working constraint.
|
||||
const PROMPT_INJECTION_BATCH_BODY_LIMIT_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
/// The port used for the runtime API server. In the development environment, we use a fixed
|
||||
/// port, in the production environment we use the next available port. This differentiation
|
||||
/// is necessary because we cannot communicate the port to the .NET server in the development
|
||||
@@ -62,6 +67,14 @@ pub fn start_runtime_api() {
|
||||
.route("/system/enterprise/configs", get(crate::environment::read_enterprise_configs))
|
||||
.route("/retrieval/fs/extract", get(crate::file_data::extract_data))
|
||||
.route("/security/prompt-injection/sanitize", post(crate::prompt_injection::api::sanitize))
|
||||
//
|
||||
// A batch carries every text of one tool call, which is far more than Axum's 2 MB
|
||||
// default allows. Exceeding that limit would answer 413, and the app treats a failed
|
||||
// filter call as "cannot filter" and uses the text unfiltered — the protection would
|
||||
// drop out silently on exactly the largest results. Hence the explicit limit.
|
||||
//
|
||||
.route("/security/prompt-injection/sanitize-batch", post(crate::prompt_injection::api::sanitize_batch)
|
||||
.layer(DefaultBodyLimit::max(PROMPT_INJECTION_BATCH_BODY_LIMIT_BYTES)))
|
||||
.route("/media/jobs", post(crate::media::create_job))
|
||||
.route("/media/jobs/{id}/events", get(crate::media::get_job_events))
|
||||
.route("/media/jobs/{id}", delete(crate::media::cancel_job))
|
||||
|
||||
Reference in new issue
Block a user