Skip to content

Commit

Permalink
Merge pull request #100 from edgenai/fix/issue97
Browse files Browse the repository at this point in the history
Fix/issue97
  • Loading branch information
pedro-devv committed Feb 29, 2024
2 parents 66ee740 + 8c93c14 commit bd78af6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
7 changes: 6 additions & 1 deletion crates/edgen_core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ pub struct SettingsParams {
pub audio_transcriptions_model_repo: String,

/// The policy used to decided if models/session should be allocated and run on acceleration
/// hardware
/// hardware.
pub gpu_policy: DevicePolicy,

/// The maximum size, in bytes, any request can have. This is most relevant in requests with files, such as audio
/// transcriptions.
pub max_request_size: usize,
}

impl SettingsParams {
Expand Down Expand Up @@ -234,6 +238,7 @@ impl Default for SettingsParams {
gpu_policy: DevicePolicy::AlwaysDevice {
overflow_to_cpu: true,
},
max_request_size: 1024 * 1014 * 100, // 100 MB
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions crates/edgen_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use std::process::exit;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

use tower_http::cors::CorsLayer;

use axum::extract::DefaultBodyLimit;
use futures::executor::block_on;
use tokio::select;
use tokio::sync::oneshot;
use tokio::task::JoinSet;
use tower_http::cors::CorsLayer;
use tracing::{error, info};
use utoipa::OpenApi;

Expand Down Expand Up @@ -158,7 +158,7 @@ async fn start_server(args: &cli::Serve) -> EdgenResult {
.await
.init()
.await
.expect("Failed to initialise settings");
.expect("Failed to initialise settings. Please make sure the configuration file valid, or reset it via the system tray and restart Edgen.\nThe following error occurred");

settings::create_project_dirs().await.unwrap();

Expand Down Expand Up @@ -190,7 +190,11 @@ async fn run_server(args: &cli::Serve) -> Result<bool, error::EdgenError> {
)
.await;

let http_app = routes::routes().layer(CorsLayer::permissive());
let http_app = routes::routes()
.layer(CorsLayer::permissive())
.layer(DefaultBodyLimit::max(
SETTINGS.read().await.read().await.max_request_size,
));

let uri_vector = if !args.uri.is_empty() {
info!("Overriding default URI");
Expand Down Expand Up @@ -299,15 +303,17 @@ async fn run_server(args: &cli::Serve) -> Result<bool, error::EdgenError> {

#[cfg(test)]
mod tests {
use super::*;
use crate::openai_shim::TranscriptionResponse;
use axum::routing::post;
use axum::Router;
use axum_test::multipart;
use axum_test::TestServer;
use levenshtein;
use serde_json::from_str;

use crate::openai_shim::TranscriptionResponse;

use super::*;

fn completion_streaming_request() -> String {
r#"
{
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/documentation/configuration/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The Edgen configuration. It is read from a file where you can define your models
| `audio_transcriptions_model_name` | Name of audio transcriptions model | ggml-distil-small.en.bin |
| `audio_transcriptions_model_repo` | HuggingFace repo for audio transcriptions | distil-whisper/distil-small.en |
| `gpu_policy` | Policy to choose how a model gets loaded | !always_device |
| `max_request_size` | Maximum size a request can have | 100 Megabytes |

## Configuration Paths for DATA_DIR

Expand Down

0 comments on commit bd78af6

Please sign in to comment.