Skip to content

Commit fe93ad0

Browse files
authored
Add tests for audio input (#1946)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Adds `AudioInputOpenai` function for handling audio input with a prompt, including tests and multi-language support. > > - **Behavior**: > - Adds `AudioInputOpenai` function to handle audio input with a prompt in `openai_client.rs`, `client.go`, and `async_client.py`. > - Supports both synchronous and asynchronous operations. > - **Tests**: > - Adds tests for `AudioInputOpenai` in `test_functions.py`. > - **Misc**: > - Updates `openapi.yaml` to include `AudioInputOpenai` endpoint. > - Adds `AudioInputOpenai` to various client files across different languages (e.g., TypeScript, Ruby). > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 8423d3c. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent ef9e8be commit fe93ad0

File tree

41 files changed

+1781
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1781
-505
lines changed

engine/baml-lib/schema-ast/src/parser/parse_expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ pub fn parse_statement(token: Pair<'_>, diagnostics: &mut Diagnostics) -> Option
8080
let maybe_body = match rhs.as_rule() {
8181
Rule::expr_block => {
8282
let block_span = diagnostics.span(rhs.as_span());
83-
eprintln!("parsing expr_block");
83+
// eprintln!("parsing expr_block");
8484
let maybe_expr_block = parse_expr_block(rhs, diagnostics);
8585
maybe_expr_block.map(|expr_block| Expression::ExprBlock(expr_block, block_span))
8686
}
8787
Rule::expression => {
88-
eprintln!("parsing expr");
88+
// eprintln!("parsing expr");
8989
let maybe_expr = parse_expression(rhs, diagnostics);
9090
maybe_expr
9191
}

engine/baml-runtime/src/internal/llm_client/primitive/openai/openai_client.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ impl ToProviderMessage for OpenAIClient {
374374
let format_str = match mime_type_str.as_str() {
375375
"audio/wav" | "wav" => "wav",
376376
"audio/mp3" | "mp3" => "mp3",
377+
"audio/mpeg" | "mpeg" => "mp3",
378+
// "audio/ogg" | "ogg" => "ogg",
379+
// "audio/webm" | "webm" => "webm",
380+
// "audio/flac" | "flac" => "flac",
381+
// "audio/m4a" | "m4a" => "m4a",
382+
// "audio/x-m4a" | "x-m4a" => "x-m4a",
377383
// Add other supported formats here if needed in the future
378384
_ => anyhow::bail!(
379385
"Unsupported audio format for input_audio: '{}'. OpenAI currently supports 'wav' and 'mp3' for this structure.",

integ-tests/baml_src/test-files/functions/input/named-args/single/named-audio.baml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,26 @@ function AudioInput(aud: audio) -> string{
99
"#
1010
}
1111
//
12-
12+
13+
client GPT4Audio {
14+
provider openai
15+
options {
16+
model "gpt-4o-audio-preview"
17+
}
18+
}
19+
20+
function AudioInputOpenai(aud: audio, prompt: string) -> string{
21+
client GPT4Audio
22+
prompt #"
23+
{{ _.role("user") }}
24+
25+
{{ prompt }}
26+
27+
{{ aud }}
28+
"#
29+
}
30+
//
31+
1332

1433

1534
test TestURLAudioInput{

integ-tests/baml_src/test-files/functions/input/named-args/single/named-image.baml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function TestImageInputAnthropic(img: image) -> string{
1717
"#
1818
}
1919

20+
2021
test image_url_with_media_type {
2122
functions [TestImageInput, TestImageInputAnthropic]
2223
args {

integ-tests/go/baml_client/client.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integ-tests/go/baml_client/inlinedbaml.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integ-tests/openapi/baml_client/openapi.yaml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integ-tests/python/baml_client/async_client.py

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integ-tests/python/baml_client/async_request.py

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)