Skip to content

Commit

Permalink
Merge pull request #69 from edgenai/feat/modelmanager
Browse files Browse the repository at this point in the history
Feat/modelmanager
  • Loading branch information
toschoo authored Feb 19, 2024
2 parents bd0bb81 + 3ebba17 commit 2c77d17
Show file tree
Hide file tree
Showing 11 changed files with 1,072 additions and 166 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions crates/edgen_core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ fn build_config_file_path() -> PathBuf {
config_dir.join(Path::new(&filename))
}

/// Helper to get the chat completions model directory.
pub async fn chat_completions_dir() -> String {
SETTINGS
.read()
.await
.read()
.await
.chat_completions_models_dir
.trim()
.to_string()
}

/// Helper to get the audio transcriptions model directory.
pub async fn audio_transcriptions_dir() -> String {
SETTINGS
.read()
.await
.read()
.await
.audio_transcriptions_models_dir
.trim()
.to_string()
}

#[derive(Error, Debug, Serialize)]
pub enum SettingsError {
#[error("failed to read the settings file: {0}")]
Expand Down
1 change: 1 addition & 0 deletions crates/edgen_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ testcontainers = "0.15.0"

[dev-dependencies]
levenshtein = "1.0.5"
tempfile = { workspace = true }
30 changes: 3 additions & 27 deletions crates/edgen_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::process::exit;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

use axum::Router;
use tower_http::cors::CorsLayer;

use futures::executor::block_on;
Expand All @@ -43,7 +42,9 @@ pub mod error;
pub mod graceful_shutdown;
mod llm;
mod model;
pub mod model_man;
pub mod openai_shim;
mod routes;
pub mod status;
pub mod util;
mod whisper;
Expand Down Expand Up @@ -189,32 +190,7 @@ async fn run_server(args: &cli::Serve) -> Result<bool, error::EdgenError> {
)
.await;

let http_app = Router::new()
// -- AI endpoints -----------------------------------------------------
// ---- Chat -----------------------------------------------------------
.route(
"/v1/chat/completions",
axum::routing::post(openai_shim::chat_completions),
)
// ---- Audio ----------------------------------------------------------
.route(
"/v1/audio/transcriptions",
axum::routing::post(openai_shim::create_transcription),
)
// -- AI status endpoints ----------------------------------------------
// ---- Chat -----------------------------------------------------------
.route(
"/v1/chat/completions/status",
axum::routing::get(status::chat_completions_status),
)
// ---- Audio ----------------------------------------------------------
.route(
"/v1/audio/transcriptions/status",
axum::routing::get(status::audio_transcriptions_status),
)
// -- Miscellaneous services -------------------------------------------
.route("/v1/misc/version", axum::routing::get(misc::edgen_version))
.layer(CorsLayer::permissive());
let http_app = routes::routes().layer(CorsLayer::permissive());

let uri_vector = if !args.uri.is_empty() {
info!("Overriding default URI");
Expand Down
2 changes: 1 addition & 1 deletion crates/edgen_server/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Version {
build: String,
}

/// GET `/v1/version`: returns the current version of edgend.
/// GET `/v1/misc/version`: returns the current version of edgend.
///
/// The version is returned as json value with major, minor and patch as integer
/// and build as string (which may be empty).
Expand Down
Loading

0 comments on commit 2c77d17

Please sign in to comment.