Compare commits
2 commits
628e5e63fb
...
47525c3682
Author | SHA1 | Date | |
---|---|---|---|
47525c3682 | |||
98b4f45706 |
3 changed files with 133 additions and 589 deletions
697
Cargo.lock
generated
697
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -41,7 +41,8 @@ version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
iced = { git = "https://github.com/iced-rs/iced.git", branch = "master" }
|
# iced = { git = "https://github.com/iced-rs/iced.git", branch = "master" }
|
||||||
|
iced = { version = "0.13" }
|
||||||
leptos = { version = "0.6", features = ["serde"] }
|
leptos = { version = "0.6", features = ["serde"] }
|
||||||
leptos_axum = { version = "0.6" }
|
leptos_axum = { version = "0.6" }
|
||||||
leptos_meta = { version = "0.6" }
|
leptos_meta = { version = "0.6" }
|
||||||
|
|
|
@ -107,7 +107,9 @@ async fn main() {
|
||||||
initialize_logger();
|
initialize_logger();
|
||||||
// Read and parse the YAML configuration
|
// Read and parse the YAML configuration
|
||||||
let config_str = std::fs::read_to_string("config.yaml").expect("Failed to read config.yaml");
|
let config_str = std::fs::read_to_string("config.yaml").expect("Failed to read config.yaml");
|
||||||
let config: Config = serde_yaml::from_str::<Config>(&config_str).expect("Failed to parse config.yaml").pick_open_ports();
|
let config: Config = serde_yaml::from_str::<Config>(&config_str)
|
||||||
|
.expect("Failed to parse config.yaml")
|
||||||
|
.pick_open_ports();
|
||||||
|
|
||||||
// Parse hardware resources
|
// Parse hardware resources
|
||||||
let total_ram = parse_size(&config.hardware.ram).expect("Invalid RAM size in config");
|
let total_ram = parse_size(&config.hardware.ram).expect("Invalid RAM size in config");
|
||||||
|
@ -286,7 +288,12 @@ async fn handle_request(
|
||||||
cmd.args(&args);
|
cmd.args(&args);
|
||||||
// TODO use openport crate via pick_random_unused_port for determining these
|
// TODO use openport crate via pick_random_unused_port for determining these
|
||||||
cmd.arg("--port");
|
cmd.arg("--port");
|
||||||
cmd.arg(format!("{}", model_config.internal_port.expect("Unexpected empty port, should've been picked")));
|
cmd.arg(format!(
|
||||||
|
"{}",
|
||||||
|
model_config
|
||||||
|
.internal_port
|
||||||
|
.expect("Unexpected empty port, should've been picked")
|
||||||
|
));
|
||||||
cmd.stdout(Stdio::null()).stderr(Stdio::null()); // TODO save output and allow retrieval via api
|
cmd.stdout(Stdio::null()).stderr(Stdio::null()); // TODO save output and allow retrieval via api
|
||||||
|
|
||||||
tracing::info!("Starting llama-server with {:?}", cmd);
|
tracing::info!("Starting llama-server with {:?}", cmd);
|
||||||
|
@ -311,7 +318,12 @@ async fn handle_request(
|
||||||
|
|
||||||
// Wait for the instance to be ready
|
// Wait for the instance to be ready
|
||||||
is_llama_instance_running(&instance).await?;
|
is_llama_instance_running(&instance).await?;
|
||||||
wait_for_port(model_config.internal_port.expect("Unexpected empty port, should've been picked")).await?;
|
wait_for_port(
|
||||||
|
model_config
|
||||||
|
.internal_port
|
||||||
|
.expect("Unexpected empty port, should've been picked"),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
// Proxy the request
|
// Proxy the request
|
||||||
let retry_policy = reqwest_retry::policies::ExponentialBackoff::builder()
|
let retry_policy = reqwest_retry::policies::ExponentialBackoff::builder()
|
||||||
|
@ -328,7 +340,9 @@ async fn handle_request(
|
||||||
|
|
||||||
let uri = format!(
|
let uri = format!(
|
||||||
"http://127.0.0.1:{}{}",
|
"http://127.0.0.1:{}{}",
|
||||||
model_config.internal_port.expect("Unexpected empty port, should've been picked"),
|
model_config
|
||||||
|
.internal_port
|
||||||
|
.expect("Unexpected empty port, should've been picked"),
|
||||||
req.uri().path_and_query().map(|x| x.as_str()).unwrap_or("")
|
req.uri().path_and_query().map(|x| x.as_str()).unwrap_or("")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue