Skip to content

Commit

Permalink
add rest api embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
qooba committed Jan 15, 2024
1 parent ac8f368 commit 324465e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yummy-rs/yummy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yummy"
version = "0.0.8"
version.workspace = true
edition = "2021"
repository = "https://github.com/yummyml/yummy"
description = "The yummy library"
Expand All @@ -17,8 +17,10 @@ rustflags = ["-C", "target-cpu=native"]
clap = "4.2.1"
yummy-delta = { version = "0.0.9", path = "../yummy-delta", optional = true }
yummy-ml = { version = "0.0.9", path = "../yummy-ml", optional = true }
yummy-llm = { version = "0.0.9", path = "../yummy-llm", optional = true }
tokio = { version = "1.20.0", features = ["full"] }

[features]
yummy-delta = ["dep:yummy-delta"]
yummy-ml = ["dep:yummy-ml"]
yummy-llm = ["dep:yummy-llm"]
5 changes: 5 additions & 0 deletions yummy-rs/yummy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ test-delta:
run-ml-serve:
cargo run --features yummy-ml ml serve --model /home/jovyan/yummy/yummy-rs/tests/mlflow/lightgbm_model/lightgbm_my_model/ --port 8080 --host 0.0.0.0 --loglevel debug

run-llm-serve-embeddings-e5:
cargo run --features yummy-llm llm serve --config /home/jovyan/yummy/yummy-rs/tests/llm/config.yaml --port 8080 --host 0.0.0.0 --loglevel debug


run-delta-serve:
cargo run --features yummy-delta delta serve --config /home/jovyan/yummy/yummy-rs/tests/delta/apply.yaml --port 8080 --host 0.0.0.0 --loglevel debug


#curl -d '{"input":["Elixir of Eternal Twilight: Grants visions of realms beyond the veil."]}' -H "Content-Type: application/json" -X POST http://localhost:8080/embeddings | python3 -mjson.tool
56 changes: 56 additions & 0 deletions yummy-rs/yummy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ fn cli() -> Command {
.arg_required_else_help(true),
),
)
.subcommand(
Command::new("llm")
.about("yummy llm")
.subcommand_required(true)
.subcommand(
Command::new("serve")
.about("yummy llm serve")
.args(vec![
arg!(--config <FILE> "config path"),
arg!(--host <HOST> "host"),
arg!(--port <PORT> "port"),
arg!(--loglevel <LOGLEVEL> "log level"),
])
.arg_required_else_help(true),
),
)
}

#[tokio::main]
Expand Down Expand Up @@ -95,6 +111,26 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
_ => unreachable!(),
},
Some(("llm", sub_matches)) => match sub_matches.subcommand() {
Some(("serve", sub_sub_matches)) => {
let config = sub_sub_matches
.get_one::<String>("config")
.expect("required");
let host = sub_sub_matches.get_one::<String>("host").expect("required");
let port = sub_sub_matches
.get_one::<String>("port")
.expect("required")
.parse::<u16>()?;

let log_level = sub_sub_matches
.get_one::<String>("loglevel")
.expect("required");

llm_serve(config.clone(), host.clone(), port, log_level.clone()).await?
}
_ => unreachable!(),
},

_ => unreachable!(),
}

Expand Down Expand Up @@ -150,3 +186,23 @@ async fn ml_serve(
) -> std::io::Result<()> {
unreachable!()
}

#[cfg(feature = "yummy-llm")]
async fn llm_serve(
config: String,
host: String,
port: u16,
log_level: String,
) -> std::io::Result<()> {
yummy_llm::serve_llm(config, host, port, log_level).await
}

#[cfg(not(feature = "yummy-llm"))]
async fn llm_serve(
_config: String,
_host: String,
_port: u16,
_log_level: String,
) -> std::io::Result<()> {
unreachable!()
}

0 comments on commit 324465e

Please sign in to comment.