Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ALPN feature in reqwest crate #1318

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:24.04
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \
build-essential \
clang \
pkg-config \
zlib1g \
zlib1g-dev \
libssl-dev \
Expand All @@ -29,7 +30,7 @@ RUN curl https://mise.run | sh \
&& ~/.local/bin/mise --verbose use -g --yes [email protected] [email protected] [email protected] \
&& echo 'export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"' >> ~/.bash_profile \
&& echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.local/share/mise/installs/ruby/3.1/lib' >> ~/.bash_profile

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

Expand Down
100 changes: 69 additions & 31 deletions engine/Cargo.lock

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

3 changes: 2 additions & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ minijinja = { version = "1.0.16", default-features = false, features = [
pretty_assertions = "1.4.1"
rand = "0.8.5"
regex = "1.10.4"
reqwest = { version = "0.12.5", features = [
reqwest = { version = "0.12.12", features = [
"json",
"native-tls-vendored",
"native-tls-alpn",
"stream",
] }
scopeguard = "1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion engine/baml-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ colored = { version = "2.1.0", default-features = false, features = [
] }
futures-timer = { version = "3.0.3", features = ["wasm-bindgen"] }
js-sys = "0.3.69"
reqwest = { version = "0.12.5", features = ["stream", "json"] }
reqwest = { version = "0.12.12", features = ["stream", "json", "native-tls-vendored", "native-tls-alpn"] }
#
send_wrapper = { version = "0.6.0", features = ["futures"] }
serde-wasm-bindgen = "0.6.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ impl SseResponseTrait for GoogleAIClient {

if let Some(choice) = event.candidates.get(0) {
let part_index = content_part(&model_id);
if let Some(content) = choice.content.as_ref().and_then(|c| c.parts.get(part_index)) {
if let Some(content) = choice
.content
.as_ref()
.and_then(|c| c.parts.get(part_index))
{
inner.content += &content.text;
}
if let Some(FinishReason::Stop) = choice.finish_reason.as_ref() {
Expand Down Expand Up @@ -458,11 +462,11 @@ impl ToProviderMessage for GoogleAIClient {
/// The Google Gemini 2 model has an experimental feature
/// called Flash Thinking Mode, which is turned on in a particular
/// named model: gemini-2.0-flash-thinking-exp-1219
///
///
/// When run in this mode, Gemini returns `candidates` with 2 parts each.
/// Part 0 is the chain of thought, part 1 is the actual output.
/// Other Gemini models put the output data in part 0.
///
///
/// TODO: Explicitly represent Flash Thinking Mode response and
/// do more thorough checking for the content part.
/// For examples of how to introspect the response more safely, see:
Expand All @@ -473,4 +477,4 @@ fn content_part(model_name: &str) -> usize {
} else {
0
}
}
}
15 changes: 5 additions & 10 deletions engine/baml-runtime/src/internal/llm_client/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ where
{
#[allow(async_fn_in_trait)]
async fn single_call(&self, ctx: &RuntimeContext, prompt: &RenderedPrompt) -> LLMResponse {
if let RenderedPrompt::Chat(chat) = &prompt {
match process_media_urls(
match prompt {
RenderedPrompt::Chat(chat) => match process_media_urls(
self.model_features().resolve_media_urls,
true,
None,
Expand All @@ -160,15 +160,10 @@ where
)
.await
{
Ok(messages) => return self.chat(ctx, &messages).await,
Err(e) => {
return LLMResponse::InternalFailure(format!("Error occurred:\n\n{:?}", e))
}
}
}
Ok(messages) => self.chat(ctx, &messages).await,
Err(e) => LLMResponse::InternalFailure(format!("Error occurred:\n\n{:?}", e)),
},

match prompt {
RenderedPrompt::Chat(p) => self.chat(ctx, p).await,
RenderedPrompt::Completion(p) => self.completion(ctx, p).await,
}
}
Expand Down
Loading