Upgrade to Axum 0.7 and Hyper 1.0 (Breaking change: disabled ngrok tunneling). (#1959)
- Axum upgraded to hyper 1.0 and most of the ecosystem switched so it's our time now - [ngrok-rust](https://github.com/ngrok/ngrok-rust/pull/137/files) hasn't yet, and hasn't for several months now, so let's disabled the feature for the time being. # What does this PR do? <!-- Congratulations! You've made it this far! You're not quite done yet though. Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution. Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change. Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost. --> <!-- Remove if not applicable --> Fixes # (issue) ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section? - [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link to it if that's the case. - [ ] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation). - [ ] Did you write any new necessary tests? ## Who can review? Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR. <!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @ @OlivierDehaene OR @Narsil -->
This commit is contained in:
parent
b7ffa287f2
commit
e76b9824ae
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
## What is Guidance?
|
## What is Guidance?
|
||||||
|
|
||||||
Guidance is a feature that allows users to constrain the generation of a large language model with a specified grammar. This feature is particularly useful when you want to generate text that follows a specific structure or uses a specific set of words or produce output in a specific format. A prominent example is JSON grammar, where the model is forced to output valid JSON.
|
|
||||||
|
Guidance is a feature that allows users to constrain the generation of a large language model with a specified grammar. This feature is particularly useful when you want to generate text that follows a specific structure or uses a specific set of words or produce output in a specific format. A prominent example is JSON grammar, where the model is forced to output valid JSON.
|
||||||
|
|
||||||
## How is it used?
|
## How is it used?
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-stream = "0.3.5"
|
async-stream = "0.3.5"
|
||||||
axum = { version = "0.6.20", features = ["json"] }
|
axum = { version = "0.7", features = ["json"] }
|
||||||
axum-tracing-opentelemetry = "0.14.1"
|
axum-tracing-opentelemetry = "0.16"
|
||||||
text-generation-client = { path = "client" }
|
text-generation-client = { path = "client" }
|
||||||
clap = { version = "4.4.5", features = ["derive", "env"] }
|
clap = { version = "4.4.5", features = ["derive", "env"] }
|
||||||
futures = "0.3.28"
|
futures = "0.3.28"
|
||||||
|
@ -36,12 +36,12 @@ thiserror = "1.0.48"
|
||||||
tokenizers = { workspace = true}
|
tokenizers = { workspace = true}
|
||||||
tokio = { version = "1.32.0", features = ["rt", "rt-multi-thread", "parking_lot", "signal", "sync"] }
|
tokio = { version = "1.32.0", features = ["rt", "rt-multi-thread", "parking_lot", "signal", "sync"] }
|
||||||
tokio-stream = "0.1.14"
|
tokio-stream = "0.1.14"
|
||||||
tower-http = { version = "0.4.4", features = ["cors"] }
|
tower-http = { version = "0.5.1", features = ["cors"] }
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-opentelemetry = "0.21.0"
|
tracing-opentelemetry = "0.21.0"
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] }
|
tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] }
|
||||||
utoipa = { version = "3.5.0", features = ["axum_extras"] }
|
utoipa = { version = "4.2.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "3.1.5", features = ["axum"] }
|
utoipa-swagger-ui = { version = "6.0.0", features = ["axum"] }
|
||||||
ngrok = { version = "0.13.1", features = ["axum"], optional = true }
|
ngrok = { version = "0.13.1", features = ["axum"], optional = true }
|
||||||
init-tracing-opentelemetry = { version = "0.14.1", features = ["opentelemetry-otlp"] }
|
init-tracing-opentelemetry = { version = "0.14.1", features = ["opentelemetry-otlp"] }
|
||||||
minijinja = { git = "https://github.com/mitsuhiko/minijinja.git", rev = "5cd4efb" }
|
minijinja = { git = "https://github.com/mitsuhiko/minijinja.git", rev = "5cd4efb" }
|
||||||
|
|
|
@ -1392,8 +1392,8 @@ pub async fn run(
|
||||||
addr: SocketAddr,
|
addr: SocketAddr,
|
||||||
allow_origin: Option<AllowOrigin>,
|
allow_origin: Option<AllowOrigin>,
|
||||||
ngrok: bool,
|
ngrok: bool,
|
||||||
ngrok_authtoken: Option<String>,
|
_ngrok_authtoken: Option<String>,
|
||||||
ngrok_edge: Option<String>,
|
_ngrok_edge: Option<String>,
|
||||||
tokenizer_config: HubTokenizerConfig,
|
tokenizer_config: HubTokenizerConfig,
|
||||||
processor_config: HubProcessorConfig,
|
processor_config: HubProcessorConfig,
|
||||||
messages_api_enabled: bool,
|
messages_api_enabled: bool,
|
||||||
|
@ -1666,46 +1666,9 @@ pub async fn run(
|
||||||
if ngrok {
|
if ngrok {
|
||||||
#[cfg(feature = "ngrok")]
|
#[cfg(feature = "ngrok")]
|
||||||
{
|
{
|
||||||
use ngrok::config::TunnelBuilder;
|
panic!("ngrok feature is not functional with axum=0.7 and hyper=1, waiting on https://github.com/ngrok/ngrok-rust/pull/137/files to re-enable.");
|
||||||
|
|
||||||
let _ = addr;
|
|
||||||
|
|
||||||
let authtoken =
|
|
||||||
ngrok_authtoken.expect("`ngrok-authtoken` must be set when using ngrok tunneling");
|
|
||||||
|
|
||||||
let edge = ngrok_edge.expect("`ngrok-edge` must be set when using ngrok tunneling");
|
|
||||||
|
|
||||||
let tunnel = ngrok::Session::builder()
|
|
||||||
.authtoken(authtoken)
|
|
||||||
.connect()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.labeled_tunnel()
|
|
||||||
.label("edge", edge);
|
|
||||||
|
|
||||||
let listener = tunnel.listen().await.unwrap();
|
|
||||||
|
|
||||||
// Run prom metrics and health locally too
|
|
||||||
tokio::spawn(
|
|
||||||
axum::Server::bind(&addr)
|
|
||||||
.serve(
|
|
||||||
Router::new()
|
|
||||||
.route("/health", get(health))
|
|
||||||
.route("/metrics", get(metrics))
|
|
||||||
.layer(Extension(health_ext))
|
|
||||||
.layer(Extension(prom_handle))
|
|
||||||
.into_make_service(),
|
|
||||||
)
|
|
||||||
//Wait until all requests are finished to shut down
|
|
||||||
.with_graceful_shutdown(shutdown_signal()),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Run server
|
// Run server
|
||||||
axum::Server::builder(listener)
|
|
||||||
.serve(app.into_make_service())
|
|
||||||
//Wait until all requests are finished to shut down
|
|
||||||
.with_graceful_shutdown(shutdown_signal())
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "ngrok"))]
|
#[cfg(not(feature = "ngrok"))]
|
||||||
{
|
{
|
||||||
|
@ -1718,9 +1681,9 @@ pub async fn run(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Run server
|
// Run server
|
||||||
axum::Server::bind(&addr)
|
|
||||||
.serve(app.into_make_service())
|
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||||
// Wait until all requests are finished to shut down
|
axum::serve(listener, app)
|
||||||
.with_graceful_shutdown(shutdown_signal())
|
.with_graceful_shutdown(shutdown_signal())
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue