Skip to content

Commit

Permalink
vscode: add link to tracing, show token counts (#703)
Browse files Browse the repository at this point in the history
* vscode + fiddle: add Boundary Studio link to traced tests
* vscode + fiddle: show input and output token counts
* runtime: surface token stats for openai streams, now that they support
it
  • Loading branch information
sxlijin authored Jun 22, 2024
1 parent 21b1209 commit 64aa18a
Show file tree
Hide file tree
Showing 19 changed files with 8,536 additions and 6,980 deletions.
5 changes: 0 additions & 5 deletions engine/.vscode/settings.json

This file was deleted.

53 changes: 53 additions & 0 deletions engine/Cargo.lock

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

1 change: 1 addition & 0 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ serde = { version = "1", features = ["derive"] }
static_assertions = "1.1.0"
strum = { version = "0.26.2", features = ["derive"] }
strum_macros = "0.26.2"
time = { version = "0.3.36", features = ["formatting"] }
walkdir = "2.5.0"
web-time = "1.1.0"
baml-types = { path = "baml-lib/baml-types" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ impl RequestBuilder for OpenAIClient {
}

if stream {
body_obj.insert("stream".into(), true.into());
body_obj.insert("stream".into(), json!(true));
body_obj.insert(
"stream_options".into(),
json!({
"include_usage": true,
}),
);
}

req.json(&body)
Expand Down Expand Up @@ -366,6 +372,11 @@ impl SseResponseTrait for OpenAIClient {
}
}
inner.latency = instant_start.elapsed();
if let Some(usage) = event.usage.as_ref() {
inner.metadata.prompt_tokens = Some(usage.prompt_tokens);
inner.metadata.output_tokens = Some(usage.completion_tokens);
inner.metadata.total_tokens = Some(usage.total_tokens);
}

std::future::ready(Some(LLMResponse::Success(inner.clone())))
},
Expand Down
1 change: 1 addition & 0 deletions engine/baml-schema-wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/src/*
nodejs/src/*
web/src/*
1 change: 1 addition & 0 deletions engine/baml-schema-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ log.workspace = true
serde.workspace = true
serde_json.workspace = true
serde-wasm-bindgen = "0.4"
time.workspace = true
uuid = { version = "1.8", features = ["v4", "js"] }
wasm-bindgen = "=0.2.92"
wasm-bindgen-futures = "0.4.42"
Expand Down
26 changes: 0 additions & 26 deletions engine/baml-schema-wasm/dist/src/baml_schema_build.d.ts

This file was deleted.

191 changes: 0 additions & 191 deletions engine/baml-schema-wasm/dist/src/baml_schema_build.js

This file was deleted.

Binary file not shown.
10 changes: 0 additions & 10 deletions engine/baml-schema-wasm/dist/src/baml_schema_build_bg.wasm.d.ts

This file was deleted.

Loading

0 comments on commit 64aa18a

Please sign in to comment.