"fern/pages/vscode:/vscode.git/clone" did not exist on "4520b8f636c37f22f67512695382e5ded5e78097"
Unverified Commit b6a3b0c6 authored by ishandhanani's avatar ishandhanani Committed by GitHub
Browse files

refactor(2/3): rename dynamo-async-openai to dynamo-protocols (#7565)

parent c84c0934
...@@ -1851,35 +1851,6 @@ version = "1.0.20" ...@@ -1851,35 +1851,6 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]]
name = "dynamo-async-openai"
version = "1.0.0"
dependencies = [
"async-openai-macros",
"backoff",
"base64 0.22.1",
"bytes",
"derive_builder",
"eventsource-stream",
"futures",
"rand 0.9.2",
"reqwest 0.12.28",
"reqwest-eventsource",
"secrecy",
"serde",
"serde_json",
"thiserror 2.0.18",
"tokio",
"tokio-stream",
"tokio-test",
"tokio-tungstenite",
"tokio-util",
"tracing",
"url",
"utoipa",
"uuid",
]
[[package]] [[package]]
name = "dynamo-bench" name = "dynamo-bench"
version = "1.0.0" version = "1.0.0"
...@@ -1983,12 +1954,12 @@ dependencies = [ ...@@ -1983,12 +1954,12 @@ dependencies = [
"derive-getters", "derive-getters",
"derive_builder", "derive_builder",
"dialoguer", "dialoguer",
"dynamo-async-openai",
"dynamo-bench", "dynamo-bench",
"dynamo-kv-router", "dynamo-kv-router",
"dynamo-memory", "dynamo-memory",
"dynamo-mocker", "dynamo-mocker",
"dynamo-parsers", "dynamo-parsers",
"dynamo-protocols",
"dynamo-runtime", "dynamo-runtime",
"dynamo-tokens", "dynamo-tokens",
"either", "either",
...@@ -2106,7 +2077,7 @@ name = "dynamo-parsers" ...@@ -2106,7 +2077,7 @@ name = "dynamo-parsers"
version = "1.0.0" version = "1.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dynamo-async-openai", "dynamo-protocols",
"num-traits", "num-traits",
"openai-harmony", "openai-harmony",
"regex", "regex",
...@@ -2119,6 +2090,35 @@ dependencies = [ ...@@ -2119,6 +2090,35 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "dynamo-protocols"
version = "1.0.0"
dependencies = [
"async-openai-macros",
"backoff",
"base64 0.22.1",
"bytes",
"derive_builder",
"eventsource-stream",
"futures",
"rand 0.9.2",
"reqwest 0.12.28",
"reqwest-eventsource",
"secrecy",
"serde",
"serde_json",
"thiserror 2.0.18",
"tokio",
"tokio-stream",
"tokio-test",
"tokio-tungstenite",
"tokio-util",
"tracing",
"url",
"utoipa",
"uuid",
]
[[package]] [[package]]
name = "dynamo-runtime" name = "dynamo-runtime"
version = "1.0.0" version = "1.0.0"
......
...@@ -14,7 +14,7 @@ members = [ ...@@ -14,7 +14,7 @@ members = [
"lib/kvbm-kernels", "lib/kvbm-kernels",
"lib/kvbm-logical", "lib/kvbm-logical",
"lib/kvbm-physical", "lib/kvbm-physical",
"lib/async-openai", "lib/protocols",
"lib/parsers", "lib/parsers",
"lib/bench", "lib/bench",
"lib/bindings/c", "lib/bindings/c",
...@@ -44,7 +44,7 @@ dynamo-tokens = { path = "lib/tokens", version = "1.0.0" } ...@@ -44,7 +44,7 @@ dynamo-tokens = { path = "lib/tokens", version = "1.0.0" }
dynamo-memory = { path = "lib/memory", version = "1.0.0" } dynamo-memory = { path = "lib/memory", version = "1.0.0" }
dynamo-mocker = { path = "lib/mocker", version = "1.0.0" } dynamo-mocker = { path = "lib/mocker", version = "1.0.0" }
dynamo-kv-router = { path = "lib/kv-router", version = "1.0.0", features = ["metrics", "runtime-protocols"] } dynamo-kv-router = { path = "lib/kv-router", version = "1.0.0", features = ["metrics", "runtime-protocols"] }
dynamo-async-openai = { path = "lib/async-openai", version = "1.0.0", features = ["byot"] } dynamo-protocols = { path = "lib/protocols", version = "1.0.0", features = ["byot"] }
dynamo-parsers = { path = "lib/parsers", version = "1.0.0" } dynamo-parsers = { path = "lib/parsers", version = "1.0.0" }
fastokens = { version = "0.1.0" } fastokens = { version = "0.1.0" }
......
...@@ -61,7 +61,7 @@ We recommend using the TensorRT-LLM NGC container instead of the `ai-dynamo[trtl ...@@ -61,7 +61,7 @@ We recommend using the TensorRT-LLM NGC container instead of the `ai-dynamo[trtl
|-------|-------------|-------------|-----------| |-------|-------------|-------------|-----------|
| `dynamo-runtime@1.0.1` | Core distributed runtime library | `v1.82` | [link](https://crates.io/crates/dynamo-runtime/1.0.1) | | `dynamo-runtime@1.0.1` | Core distributed runtime library | `v1.82` | [link](https://crates.io/crates/dynamo-runtime/1.0.1) |
| `dynamo-llm@1.0.1` | LLM inference engine | `v1.82` | [link](https://crates.io/crates/dynamo-llm/1.0.1) | | `dynamo-llm@1.0.1` | LLM inference engine | `v1.82` | [link](https://crates.io/crates/dynamo-llm/1.0.1) |
| `dynamo-async-openai@1.0.1` | Async OpenAI-compatible API client | `v1.82` | [link](https://crates.io/crates/dynamo-async-openai/1.0.1) | | `dynamo-protocols@1.0.1` | Async OpenAI-compatible API client | `v1.82` | [link](https://crates.io/crates/dynamo-protocols/1.0.1) |
| `dynamo-parsers@1.0.1` | Protocol parsers (SSE, JSON streaming) | `v1.82` | [link](https://crates.io/crates/dynamo-parsers/1.0.1) | | `dynamo-parsers@1.0.1` | Protocol parsers (SSE, JSON streaming) | `v1.82` | [link](https://crates.io/crates/dynamo-parsers/1.0.1) |
| `dynamo-memory@1.0.1` | Memory management utilities | `v1.82` | [link](https://crates.io/crates/dynamo-memory/1.0.1) | | `dynamo-memory@1.0.1` | Memory management utilities | `v1.82` | [link](https://crates.io/crates/dynamo-memory/1.0.1) |
| `dynamo-config@1.0.1` | Configuration management | `v1.82` | [link](https://crates.io/crates/dynamo-config/1.0.1) | | `dynamo-config@1.0.1` | Configuration management | `v1.82` | [link](https://crates.io/crates/dynamo-config/1.0.1) |
...@@ -133,7 +133,7 @@ helm install snapshot oci://helm.ngc.nvidia.com/nvidia/ai-dynamo/charts/snapshot ...@@ -133,7 +133,7 @@ helm install snapshot oci://helm.ngc.nvidia.com/nvidia/ai-dynamo/charts/snapshot
```bash ```bash
cargo add dynamo-runtime@1.0.1 cargo add dynamo-runtime@1.0.1
cargo add dynamo-llm@1.0.1 cargo add dynamo-llm@1.0.1
cargo add dynamo-async-openai@1.0.1 cargo add dynamo-protocols@1.0.1
cargo add dynamo-parsers@1.0.1 cargo add dynamo-parsers@1.0.1
cargo add dynamo-memory@1.0.1 cargo add dynamo-memory@1.0.1
cargo add dynamo-config@1.0.1 cargo add dynamo-config@1.0.1
...@@ -419,7 +419,7 @@ For a complete list of known issues, refer to the release notes for each version ...@@ -419,7 +419,7 @@ For a complete list of known issues, refer to the release notes for each version
### Rust Crates ### Rust Crates
> **crates.io:** [dynamo-runtime](https://crates.io/crates/dynamo-runtime) | [dynamo-llm](https://crates.io/crates/dynamo-llm) | [dynamo-async-openai](https://crates.io/crates/dynamo-async-openai) | [dynamo-parsers](https://crates.io/crates/dynamo-parsers) | [dynamo-memory](https://crates.io/crates/dynamo-memory) | [dynamo-config](https://crates.io/crates/dynamo-config) | [dynamo-tokens](https://crates.io/crates/dynamo-tokens) > **crates.io:** [dynamo-runtime](https://crates.io/crates/dynamo-runtime) | [dynamo-llm](https://crates.io/crates/dynamo-llm) | [dynamo-protocols](https://crates.io/crates/dynamo-protocols) | [dynamo-parsers](https://crates.io/crates/dynamo-parsers) | [dynamo-memory](https://crates.io/crates/dynamo-memory) | [dynamo-config](https://crates.io/crates/dynamo-config) | [dynamo-tokens](https://crates.io/crates/dynamo-tokens)
> >
> To access a specific version: `https://crates.io/crates/{crate}/{version}` > To access a specific version: `https://crates.io/crates/{crate}/{version}`
...@@ -453,20 +453,20 @@ For a complete list of known issues, refer to the release notes for each version ...@@ -453,20 +453,20 @@ For a complete list of known issues, refer to the release notes for each version
| `dynamo-llm@0.6.1` | `v1.82` | | | `dynamo-llm@0.6.1` | `v1.82` | |
| `dynamo-llm@0.6.0` | `v1.82` | | | `dynamo-llm@0.6.0` | `v1.82` | |
#### dynamo-async-openai (crate) #### dynamo-protocols (crate)
| Crate | MSRV (Rust) | Notes | | Crate | MSRV (Rust) | Notes |
|-------|-------------|-------| |-------|-------------|-------|
| `dynamo-async-openai@1.0.1` | `v1.82` | | | `dynamo-protocols@1.0.1` | `v1.82` | |
| `dynamo-async-openai@1.0.0` | `v1.82` | | | `dynamo-protocols@1.0.0` | `v1.82` | |
| `dynamo-async-openai@0.9.1` | `v1.82` | | | `dynamo-protocols@0.9.1` | `v1.82` | |
| `dynamo-async-openai@0.9.0` | `v1.82` | | | `dynamo-protocols@0.9.0` | `v1.82` | |
| `dynamo-async-openai@0.8.1` | `v1.82` | | | `dynamo-protocols@0.8.1` | `v1.82` | |
| `dynamo-async-openai@0.8.0` | `v1.82` | | | `dynamo-protocols@0.8.0` | `v1.82` | |
| `dynamo-async-openai@0.7.1` | `v1.82` | | | `dynamo-protocols@0.7.1` | `v1.82` | |
| `dynamo-async-openai@0.7.0` | `v1.82` | | | `dynamo-protocols@0.7.0` | `v1.82` | |
| `dynamo-async-openai@0.6.1` | `v1.82` | | | `dynamo-protocols@0.6.1` | `v1.82` | |
| `dynamo-async-openai@0.6.0` | `v1.82` | | | `dynamo-protocols@0.6.0` | `v1.82` | |
#### dynamo-parsers (crate) #### dynamo-parsers (crate)
......
...@@ -193,7 +193,7 @@ For version-specific artifact details, installation commands, and release histor ...@@ -193,7 +193,7 @@ For version-specific artifact details, installation commands, and release histor
- **Rust Crates**: - **Rust Crates**:
- [dynamo-runtime](https://crates.io/crates/dynamo-runtime/) - [dynamo-runtime](https://crates.io/crates/dynamo-runtime/)
- [dynamo-llm](https://crates.io/crates/dynamo-llm/) - [dynamo-llm](https://crates.io/crates/dynamo-llm/)
- [dynamo-async-openai](https://crates.io/crates/dynamo-async-openai/) - [dynamo-protocols](https://crates.io/crates/dynamo-protocols/)
- [dynamo-parsers](https://crates.io/crates/dynamo-parsers/) - [dynamo-parsers](https://crates.io/crates/dynamo-parsers/)
- [dynamo-config](https://crates.io/crates/dynamo-config/) *(New in v0.8.0)* - [dynamo-config](https://crates.io/crates/dynamo-config/) *(New in v0.8.0)*
- [dynamo-memory](https://crates.io/crates/dynamo-memory/) *(New in v0.8.0)* - [dynamo-memory](https://crates.io/crates/dynamo-memory/) *(New in v0.8.0)*
......
...@@ -1535,7 +1535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -1535,7 +1535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]] [[package]]
name = "dynamo-async-openai" name = "dynamo-protocols"
version = "1.0.0" version = "1.0.0"
dependencies = [ dependencies = [
"async-openai-macros", "async-openai-macros",
...@@ -1621,7 +1621,7 @@ dependencies = [ ...@@ -1621,7 +1621,7 @@ dependencies = [
"derive-getters", "derive-getters",
"derive_builder", "derive_builder",
"dialoguer", "dialoguer",
"dynamo-async-openai", "dynamo-protocols",
"dynamo-kv-router", "dynamo-kv-router",
"dynamo-memory", "dynamo-memory",
"dynamo-mocker", "dynamo-mocker",
...@@ -1729,7 +1729,7 @@ name = "dynamo-parsers" ...@@ -1729,7 +1729,7 @@ name = "dynamo-parsers"
version = "1.0.0" version = "1.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dynamo-async-openai", "dynamo-protocols",
"num-traits", "num-traits",
"openai-harmony", "openai-harmony",
"regex", "regex",
......
...@@ -1543,7 +1543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -1543,7 +1543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]] [[package]]
name = "dynamo-async-openai" name = "dynamo-protocols"
version = "1.0.0" version = "1.0.0"
dependencies = [ dependencies = [
"async-openai-macros", "async-openai-macros",
...@@ -1634,7 +1634,7 @@ dependencies = [ ...@@ -1634,7 +1634,7 @@ dependencies = [
"derive-getters", "derive-getters",
"derive_builder", "derive_builder",
"dialoguer", "dialoguer",
"dynamo-async-openai", "dynamo-protocols",
"dynamo-kv-router", "dynamo-kv-router",
"dynamo-memory", "dynamo-memory",
"dynamo-mocker", "dynamo-mocker",
...@@ -1745,7 +1745,7 @@ name = "dynamo-parsers" ...@@ -1745,7 +1745,7 @@ name = "dynamo-parsers"
version = "1.0.0" version = "1.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dynamo-async-openai", "dynamo-protocols",
"num-traits", "num-traits",
"openai-harmony", "openai-harmony",
"regex", "regex",
......
...@@ -56,7 +56,7 @@ dynamo-tokens = { workspace = true } ...@@ -56,7 +56,7 @@ dynamo-tokens = { workspace = true }
# workspace # workspace
aho-corasick = "1.1" aho-corasick = "1.1"
anyhow = { workspace = true } anyhow = { workspace = true }
dynamo-async-openai = { workspace = true } dynamo-protocols = { workspace = true }
dynamo-parsers = { workspace = true } dynamo-parsers = { workspace = true }
async-stream = { workspace = true } async-stream = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
......
...@@ -12,7 +12,7 @@ use crate::protocols::openai::chat_completions::{ ...@@ -12,7 +12,7 @@ use crate::protocols::openai::chat_completions::{
}; };
use dynamo_runtime::protocols::annotated::Annotated; use dynamo_runtime::protocols::annotated::Annotated;
use dynamo_async_openai::types::{ChatChoiceStream, ChatCompletionStreamResponseDelta}; use dynamo_protocols::types::{ChatChoiceStream, ChatCompletionStreamResponseDelta};
use futures::StreamExt; use futures::StreamExt;
type AuditStream = type AuditStream =
...@@ -90,7 +90,7 @@ where ...@@ -90,7 +90,7 @@ where
tracing::warn!("audit: aggregation future canceled/failed"); tracing::warn!("audit: aggregation future canceled/failed");
// Return minimal response if aggregation failed // Return minimal response if aggregation failed
NvCreateChatCompletionResponse { NvCreateChatCompletionResponse {
inner: dynamo_async_openai::types::CreateChatCompletionResponse { inner: dynamo_protocols::types::CreateChatCompletionResponse {
id: String::new(), id: String::new(),
created: 0, created: 0,
usage: None, usage: None,
...@@ -127,7 +127,7 @@ where ...@@ -127,7 +127,7 @@ where
Err(e) => { Err(e) => {
tracing::warn!("fold aggregation failed: {e}"); tracing::warn!("fold aggregation failed: {e}");
let fallback = NvCreateChatCompletionResponse { let fallback = NvCreateChatCompletionResponse {
inner: dynamo_async_openai::types::CreateChatCompletionResponse { inner: dynamo_protocols::types::CreateChatCompletionResponse {
id: String::new(), id: String::new(),
created: 0, created: 0,
usage: None, usage: None,
...@@ -149,7 +149,7 @@ where ...@@ -149,7 +149,7 @@ where
rx.await.unwrap_or_else(|_| { rx.await.unwrap_or_else(|_| {
tracing::warn!("fold aggregation future canceled"); tracing::warn!("fold aggregation future canceled");
NvCreateChatCompletionResponse { NvCreateChatCompletionResponse {
inner: dynamo_async_openai::types::CreateChatCompletionResponse { inner: dynamo_protocols::types::CreateChatCompletionResponse {
id: String::new(), id: String::new(),
created: 0, created: 0,
usage: None, usage: None,
...@@ -182,7 +182,7 @@ pub fn final_response_to_one_chunk_stream( ...@@ -182,7 +182,7 @@ pub fn final_response_to_one_chunk_stream(
// Convert FunctionCall to FunctionCallStream if present // Convert FunctionCall to FunctionCallStream if present
#[allow(deprecated)] #[allow(deprecated)]
let function_call = ch.message.function_call.as_ref().map(|fc| { let function_call = ch.message.function_call.as_ref().map(|fc| {
dynamo_async_openai::types::FunctionCallStream { dynamo_protocols::types::FunctionCallStream {
name: Some(fc.name.clone()), name: Some(fc.name.clone()),
arguments: Some(fc.arguments.clone()), arguments: Some(fc.arguments.clone()),
} }
...@@ -194,11 +194,11 @@ pub fn final_response_to_one_chunk_stream( ...@@ -194,11 +194,11 @@ pub fn final_response_to_one_chunk_stream(
.iter() .iter()
.enumerate() .enumerate()
.map( .map(
|(i, call)| dynamo_async_openai::types::ChatCompletionMessageToolCallChunk { |(i, call)| dynamo_protocols::types::ChatCompletionMessageToolCallChunk {
index: i as u32, index: i as u32,
id: Some(call.id.clone()), id: Some(call.id.clone()),
r#type: Some(call.r#type.clone()), r#type: Some(call.r#type.clone()),
function: Some(dynamo_async_openai::types::FunctionCallStream { function: Some(dynamo_protocols::types::FunctionCallStream {
name: Some(call.function.name.clone()), name: Some(call.function.name.clone()),
arguments: Some(call.function.arguments.clone()), arguments: Some(call.function.arguments.clone()),
}), }),
...@@ -228,7 +228,7 @@ pub fn final_response_to_one_chunk_stream( ...@@ -228,7 +228,7 @@ pub fn final_response_to_one_chunk_stream(
} }
let chunk = NvCreateChatCompletionStreamResponse { let chunk = NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: resp.inner.id.clone(), id: resp.inner.id.clone(),
object: "chat.completion.chunk".to_string(), object: "chat.completion.chunk".to_string(),
created: resp.inner.created, created: resp.inner.created,
...@@ -254,7 +254,7 @@ pub fn final_response_to_one_chunk_stream( ...@@ -254,7 +254,7 @@ pub fn final_response_to_one_chunk_stream(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use dynamo_async_openai::types::{ use dynamo_protocols::types::{
ChatChoiceStream, ChatCompletionMessageContent, ChatCompletionStreamResponseDelta, ChatChoiceStream, ChatCompletionMessageContent, ChatCompletionStreamResponseDelta,
FinishReason, Role, FinishReason, Role,
}; };
...@@ -283,7 +283,7 @@ mod tests { ...@@ -283,7 +283,7 @@ mod tests {
}; };
let response = NvCreateChatCompletionStreamResponse { let response = NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test-id".to_string(), id: "test-id".to_string(),
choices: vec![choice], choices: vec![choice],
created: 1234567890, created: 1234567890,
...@@ -324,7 +324,7 @@ mod tests { ...@@ -324,7 +324,7 @@ mod tests {
}; };
let response = NvCreateChatCompletionStreamResponse { let response = NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test-id".to_string(), id: "test-id".to_string(),
choices: vec![choice], choices: vec![choice],
created: 1234567890, created: 1234567890,
...@@ -435,7 +435,7 @@ mod tests { ...@@ -435,7 +435,7 @@ mod tests {
// Test that metadata (id, event, comment) is preserved through passthrough // Test that metadata (id, event, comment) is preserved through passthrough
let chunk_with_metadata = Annotated { let chunk_with_metadata = Annotated {
data: Some(NvCreateChatCompletionStreamResponse { data: Some(NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test-id".to_string(), id: "test-id".to_string(),
choices: vec![{ choices: vec![{
#[allow(deprecated)] #[allow(deprecated)]
......
...@@ -43,7 +43,7 @@ use crate::protocols::{ ...@@ -43,7 +43,7 @@ use crate::protocols::{
}, },
}; };
use crate::tokenizers::{DecodeStream, Tokenizer}; use crate::tokenizers::{DecodeStream, Tokenizer};
use dynamo_async_openai::types::StopReason; use dynamo_protocols::types::StopReason;
/// Represents the output stream from the execution engine /// Represents the output stream from the execution engine
pub type ExecutionOutputStream = Annotated<LLMEngineOutput>; pub type ExecutionOutputStream = Annotated<LLMEngineOutput>;
......
...@@ -143,9 +143,9 @@ impl ...@@ -143,9 +143,9 @@ impl
}; };
let prompt = match req { let prompt = match req {
dynamo_async_openai::types::ChatCompletionRequestMessage::User(user_msg) => { dynamo_protocols::types::ChatCompletionRequestMessage::User(user_msg) => {
match user_msg.content { match user_msg.content {
dynamo_async_openai::types::ChatCompletionRequestUserMessageContent::Text( dynamo_protocols::types::ChatCompletionRequestUserMessageContent::Text(
prompt, prompt,
) => prompt, ) => prompt,
_ => anyhow::bail!("Invalid request content field, expected Content::Text"), _ => anyhow::bail!("Invalid request content field, expected Content::Text"),
...@@ -164,7 +164,7 @@ impl ...@@ -164,7 +164,7 @@ impl
id += 1; id += 1;
} }
let response = deltas.create_choice(0, None, Some(dynamo_async_openai::types::FinishReason::Stop), None, None); let response = deltas.create_choice(0, None, Some(dynamo_protocols::types::FinishReason::Stop), None, None);
yield Annotated { id: Some(id.to_string()), data: Some(response), event: None, comment: None, error: None }; yield Annotated { id: Some(id.to_string()), data: Some(response), event: None, comment: None, error: None };
}; };
...@@ -196,7 +196,7 @@ impl ...@@ -196,7 +196,7 @@ impl
yield Annotated{ id: Some(id.to_string()), data: Some(response), event: None, comment: None, error: None }; yield Annotated{ id: Some(id.to_string()), data: Some(response), event: None, comment: None, error: None };
id += 1; id += 1;
} }
let response = deltas.create_choice(0, None, Some(dynamo_async_openai::types::CompletionFinishReason::Stop), None); let response = deltas.create_choice(0, None, Some(dynamo_protocols::types::CompletionFinishReason::Stop), None);
yield Annotated { id: Some(id.to_string()), data: Some(response), event: None, comment: None, error: None }; yield Annotated { id: Some(id.to_string()), data: Some(response), event: None, comment: None, error: None };
}; };
......
...@@ -7,7 +7,7 @@ use crate::types::openai::chat_completions::{ ...@@ -7,7 +7,7 @@ use crate::types::openai::chat_completions::{
NvCreateChatCompletionRequest, OpenAIChatCompletionsStreamingEngine, NvCreateChatCompletionRequest, OpenAIChatCompletionsStreamingEngine,
}; };
use anyhow::Context as _; use anyhow::Context as _;
use dynamo_async_openai::types::{ChatCompletionMessageContent, FinishReason}; use dynamo_protocols::types::{ChatCompletionMessageContent, FinishReason};
use dynamo_runtime::{DistributedRuntime, pipeline::Context, runtime::CancellationToken}; use dynamo_runtime::{DistributedRuntime, pipeline::Context, runtime::CancellationToken};
use futures::StreamExt; use futures::StreamExt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
...@@ -201,15 +201,15 @@ async fn evaluate( ...@@ -201,15 +201,15 @@ async fn evaluate(
entry: &mut Entry, entry: &mut Entry,
template: Option<Arc<RequestTemplate>>, template: Option<Arc<RequestTemplate>>,
) -> anyhow::Result<String> { ) -> anyhow::Result<String> {
let user_message = dynamo_async_openai::types::ChatCompletionRequestMessage::User( let user_message = dynamo_protocols::types::ChatCompletionRequestMessage::User(
dynamo_async_openai::types::ChatCompletionRequestUserMessage { dynamo_protocols::types::ChatCompletionRequestUserMessage {
content: dynamo_async_openai::types::ChatCompletionRequestUserMessageContent::Text( content: dynamo_protocols::types::ChatCompletionRequestUserMessageContent::Text(
entry.text.clone(), entry.text.clone(),
), ),
name: None, name: None,
}, },
); );
let inner = dynamo_async_openai::types::CreateChatCompletionRequestArgs::default() let inner = dynamo_protocols::types::CreateChatCompletionRequestArgs::default()
.messages(vec![user_message]) .messages(vec![user_message])
.model( .model(
template template
......
...@@ -7,7 +7,7 @@ use crate::request_template::RequestTemplate; ...@@ -7,7 +7,7 @@ use crate::request_template::RequestTemplate;
use crate::types::openai::chat_completions::{ use crate::types::openai::chat_completions::{
NvCreateChatCompletionRequest, OpenAIChatCompletionsStreamingEngine, NvCreateChatCompletionRequest, OpenAIChatCompletionsStreamingEngine,
}; };
use dynamo_async_openai::types::ChatCompletionMessageContent; use dynamo_protocols::types::ChatCompletionMessageContent;
use dynamo_runtime::DistributedRuntime; use dynamo_runtime::DistributedRuntime;
use dynamo_runtime::pipeline::Context; use dynamo_runtime::pipeline::Context;
use futures::StreamExt; use futures::StreamExt;
...@@ -82,9 +82,9 @@ async fn main_loop( ...@@ -82,9 +82,9 @@ async fn main_loop(
}; };
// Construct messages // Construct messages
let user_message = dynamo_async_openai::types::ChatCompletionRequestMessage::User( let user_message = dynamo_protocols::types::ChatCompletionRequestMessage::User(
dynamo_async_openai::types::ChatCompletionRequestUserMessage { dynamo_protocols::types::ChatCompletionRequestUserMessage {
content: dynamo_async_openai::types::ChatCompletionRequestUserMessageContent::Text( content: dynamo_protocols::types::ChatCompletionRequestUserMessageContent::Text(
prompt, prompt,
), ),
name: None, name: None,
...@@ -92,7 +92,7 @@ async fn main_loop( ...@@ -92,7 +92,7 @@ async fn main_loop(
); );
messages.push(user_message); messages.push(user_message);
// Request // Request
let inner = dynamo_async_openai::types::CreateChatCompletionRequestArgs::default() let inner = dynamo_protocols::types::CreateChatCompletionRequestArgs::default()
.messages(messages.clone()) .messages(messages.clone())
.model( .model(
template template
...@@ -181,15 +181,15 @@ async fn main_loop( ...@@ -181,15 +181,15 @@ async fn main_loop(
println!(); println!();
let assistant_content = let assistant_content =
dynamo_async_openai::types::ChatCompletionRequestAssistantMessageContent::Text( dynamo_protocols::types::ChatCompletionRequestAssistantMessageContent::Text(
assistant_message, assistant_message,
); );
let assistant_message = dynamo_async_openai::types::ChatCompletionRequestMessage::Assistant( let assistant_message = dynamo_protocols::types::ChatCompletionRequestMessage::Assistant(
dynamo_async_openai::types::ChatCompletionRequestAssistantMessage { dynamo_protocols::types::ChatCompletionRequestAssistantMessage {
content: Some(assistant_content), content: Some(assistant_content),
reasoning_content: (!assistant_reasoning.is_empty()).then_some( reasoning_content: (!assistant_reasoning.is_empty()).then_some(
dynamo_async_openai::types::ReasoningContent::Text(assistant_reasoning), dynamo_protocols::types::ReasoningContent::Text(assistant_reasoning),
), ),
..Default::default() ..Default::default()
}, },
......
...@@ -23,7 +23,7 @@ use crate::http::service::{ ...@@ -23,7 +23,7 @@ use crate::http::service::{
disconnect::{ConnectionHandle, create_connection_monitor}, disconnect::{ConnectionHandle, create_connection_monitor},
metrics::{CancellationLabels, Endpoint, InflightGuard, process_response_and_observe_metrics}, metrics::{CancellationLabels, Endpoint, InflightGuard, process_response_and_observe_metrics},
}; };
use dynamo_async_openai::types::{CompletionFinishReason, CreateCompletionRequest, Prompt}; use dynamo_protocols::types::{CompletionFinishReason, CreateCompletionRequest, Prompt};
use tonic::Status; use tonic::Status;
......
...@@ -14,7 +14,7 @@ use std::time::Instant; ...@@ -14,7 +14,7 @@ use std::time::Instant;
use async_trait::async_trait; use async_trait::async_trait;
use derive_getters::Dissolve; use derive_getters::Dissolve;
use dynamo_async_openai::{Client, config::OpenAIConfig, error::OpenAIError}; use dynamo_protocols::{Client, config::OpenAIConfig, error::OpenAIError};
use futures::Stream; use futures::Stream;
use serde_json::Value; use serde_json::Value;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
...@@ -285,7 +285,7 @@ pub type ByotResponseStream = DataStream<Result<Value, OpenAIError>>; ...@@ -285,7 +285,7 @@ pub type ByotResponseStream = DataStream<Result<Value, OpenAIError>>;
/// Type alias for pure OpenAI chat response stream /// Type alias for pure OpenAI chat response stream
pub type OpenAIChatResponseStream = pub type OpenAIChatResponseStream =
DataStream<Result<dynamo_async_openai::types::CreateChatCompletionStreamResponse, OpenAIError>>; DataStream<Result<dynamo_protocols::types::CreateChatCompletionStreamResponse, OpenAIError>>;
/// A wrapped HTTP response stream that combines a stream with its context /// A wrapped HTTP response stream that combines a stream with its context
/// This provides a unified interface for HTTP client responses /// This provides a unified interface for HTTP client responses
...@@ -381,7 +381,7 @@ pub type ByotHttpResponseStream = HttpResponseStream<Result<Value, OpenAIError>> ...@@ -381,7 +381,7 @@ pub type ByotHttpResponseStream = HttpResponseStream<Result<Value, OpenAIError>>
/// Type alias for HttpResponseStream with pure OpenAI responses /// Type alias for HttpResponseStream with pure OpenAI responses
pub type OpenAIHttpResponseStream = HttpResponseStream< pub type OpenAIHttpResponseStream = HttpResponseStream<
Result<dynamo_async_openai::types::CreateChatCompletionStreamResponse, OpenAIError>, Result<dynamo_protocols::types::CreateChatCompletionStreamResponse, OpenAIError>,
>; >;
/// Pure OpenAI client using standard async-openai types /// Pure OpenAI client using standard async-openai types
...@@ -401,7 +401,7 @@ impl PureOpenAIClient { ...@@ -401,7 +401,7 @@ impl PureOpenAIClient {
/// Uses a client-managed context /// Uses a client-managed context
pub async fn chat_stream( pub async fn chat_stream(
&self, &self,
request: dynamo_async_openai::types::CreateChatCompletionRequest, request: dynamo_protocols::types::CreateChatCompletionRequest,
) -> Result<OpenAIHttpResponseStream, HttpClientError> { ) -> Result<OpenAIHttpResponseStream, HttpClientError> {
let ctx = self.base.create_context(); let ctx = self.base.create_context();
self.chat_stream_with_context(request, ctx).await self.chat_stream_with_context(request, ctx).await
...@@ -410,7 +410,7 @@ impl PureOpenAIClient { ...@@ -410,7 +410,7 @@ impl PureOpenAIClient {
/// Create streaming chat completions with a custom context /// Create streaming chat completions with a custom context
pub async fn chat_stream_with_context( pub async fn chat_stream_with_context(
&self, &self,
request: dynamo_async_openai::types::CreateChatCompletionRequest, request: dynamo_protocols::types::CreateChatCompletionRequest,
context: HttpRequestContext, context: HttpRequestContext,
) -> Result<OpenAIHttpResponseStream, HttpClientError> { ) -> Result<OpenAIHttpResponseStream, HttpClientError> {
let ctx_arc: Arc<dyn AsyncEngineContext> = Arc::new(context.clone()); let ctx_arc: Arc<dyn AsyncEngineContext> = Arc::new(context.clone());
......
...@@ -1538,7 +1538,7 @@ async fn responses( ...@@ -1538,7 +1538,7 @@ async fn responses(
// Set stream_options.include_usage so the backend sends token counts in the final chunk. // Set stream_options.include_usage so the backend sends token counts in the final chunk.
chat_request.inner.stream = Some(true); chat_request.inner.stream = Some(true);
chat_request.inner.stream_options = chat_request.inner.stream_options =
Some(dynamo_async_openai::types::ChatCompletionStreamOptions { Some(dynamo_protocols::types::ChatCompletionStreamOptions {
include_usage: true, include_usage: true,
continuous_usage_stats: false, continuous_usage_stats: false,
}); });
...@@ -1915,9 +1915,9 @@ async fn images( ...@@ -1915,9 +1915,9 @@ async fn images(
.model .model
.as_ref() .as_ref()
.map(|m| match m { .map(|m| match m {
dynamo_async_openai::types::ImageModel::DallE2 => "dall-e-2".to_string(), dynamo_protocols::types::ImageModel::DallE2 => "dall-e-2".to_string(),
dynamo_async_openai::types::ImageModel::DallE3 => "dall-e-3".to_string(), dynamo_protocols::types::ImageModel::DallE3 => "dall-e-3".to_string(),
dynamo_async_openai::types::ImageModel::Other(s) => s.clone(), dynamo_protocols::types::ImageModel::Other(s) => s.clone(),
}) })
.unwrap_or_else(|| "diffusion".to_string()); .unwrap_or_else(|| "diffusion".to_string());
...@@ -2327,8 +2327,8 @@ mod tests { ...@@ -2327,8 +2327,8 @@ mod tests {
use crate::protocols::openai::common_ext::CommonExt; use crate::protocols::openai::common_ext::CommonExt;
use crate::protocols::openai::completions::NvCreateCompletionRequest; use crate::protocols::openai::completions::NvCreateCompletionRequest;
use crate::protocols::openai::responses::NvCreateResponse; use crate::protocols::openai::responses::NvCreateResponse;
use dynamo_async_openai::types::responses::{CreateResponse, Input, PromptConfig}; use dynamo_protocols::types::responses::{CreateResponse, Input, PromptConfig};
use dynamo_async_openai::types::{ use dynamo_protocols::types::{
ChatCompletionRequestMessage, ChatCompletionRequestUserMessage, ChatCompletionRequestMessage, ChatCompletionRequestUserMessage,
ChatCompletionRequestUserMessageContent, CreateChatCompletionRequest, ChatCompletionRequestUserMessageContent, CreateChatCompletionRequest,
CreateCompletionRequest, CreateCompletionRequest,
...@@ -3004,7 +3004,7 @@ mod tests { ...@@ -3004,7 +3004,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn test_check_for_backend_error_with_normal_event() { async fn test_check_for_backend_error_with_normal_event() {
use crate::types::openai::chat_completions::NvCreateChatCompletionStreamResponse; use crate::types::openai::chat_completions::NvCreateChatCompletionStreamResponse;
use dynamo_async_openai::types::CreateChatCompletionStreamResponse; use dynamo_protocols::types::CreateChatCompletionStreamResponse;
use futures::stream::{self, StreamExt}; use futures::stream::{self, StreamExt};
// Create a normal data event // Create a normal data event
...@@ -3178,7 +3178,7 @@ mod tests { ...@@ -3178,7 +3178,7 @@ mod tests {
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use dynamo_async_openai::types::{ use dynamo_protocols::types::{
ChatChoiceStream, ChatCompletionMessageToolCallChunk, ChatCompletionStreamResponseDelta, ChatChoiceStream, ChatCompletionMessageToolCallChunk, ChatCompletionStreamResponseDelta,
ChatCompletionToolType, CreateChatCompletionStreamResponse, FinishReason, ChatCompletionToolType, CreateChatCompletionStreamResponse, FinishReason,
FunctionCallStream, FunctionCallStream,
......
...@@ -572,7 +572,7 @@ mod tests { ...@@ -572,7 +572,7 @@ mod tests {
use crate::protocols::codec::create_message_stream; use crate::protocols::codec::create_message_stream;
use crate::protocols::convert_sse_stream; use crate::protocols::convert_sse_stream;
use approx::assert_abs_diff_eq; use approx::assert_abs_diff_eq;
use dynamo_async_openai::types::{ use dynamo_protocols::types::{
ChatChoiceLogprobs, ChatChoiceStream, ChatCompletionStreamResponseDelta, ChatChoiceLogprobs, ChatChoiceStream, ChatCompletionStreamResponseDelta,
ChatCompletionTokenLogprob, FinishReason, Role, TopLogprobs, ChatCompletionTokenLogprob, FinishReason, Role, TopLogprobs,
}; };
...@@ -949,16 +949,14 @@ mod tests { ...@@ -949,16 +949,14 @@ mod tests {
) -> NvCreateChatCompletionStreamResponse { ) -> NvCreateChatCompletionStreamResponse {
#[expect(deprecated)] #[expect(deprecated)]
NvCreateChatCompletionStreamResponse { NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test_id".to_string(), id: "test_id".to_string(),
choices: vec![ChatChoiceStream { choices: vec![ChatChoiceStream {
index: 0, index: 0,
delta: ChatCompletionStreamResponseDelta { delta: ChatCompletionStreamResponseDelta {
content: Some( content: Some(dynamo_protocols::types::ChatCompletionMessageContent::Text(
dynamo_async_openai::types::ChatCompletionMessageContent::Text(
"test".to_string(), "test".to_string(),
), )),
),
function_call: None, function_call: None,
tool_calls: None, tool_calls: None,
role: Some(Role::Assistant), role: Some(Role::Assistant),
...@@ -993,11 +991,9 @@ mod tests { ...@@ -993,11 +991,9 @@ mod tests {
.map(|(i, token_logprobs)| ChatChoiceStream { .map(|(i, token_logprobs)| ChatChoiceStream {
index: i as u32, index: i as u32,
delta: ChatCompletionStreamResponseDelta { delta: ChatCompletionStreamResponseDelta {
content: Some( content: Some(dynamo_protocols::types::ChatCompletionMessageContent::Text(
dynamo_async_openai::types::ChatCompletionMessageContent::Text(
"test".to_string(), "test".to_string(),
), )),
),
function_call: None, function_call: None,
tool_calls: None, tool_calls: None,
role: Some(Role::Assistant), role: Some(Role::Assistant),
...@@ -1014,7 +1010,7 @@ mod tests { ...@@ -1014,7 +1010,7 @@ mod tests {
.collect(); .collect();
NvCreateChatCompletionStreamResponse { NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test_id".to_string(), id: "test_id".to_string(),
choices, choices,
created: 1234567890, created: 1234567890,
...@@ -1345,16 +1341,14 @@ mod tests { ...@@ -1345,16 +1341,14 @@ mod tests {
// Test with choice that has no logprobs // Test with choice that has no logprobs
#[expect(deprecated)] #[expect(deprecated)]
let response = NvCreateChatCompletionStreamResponse { let response = NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test_id".to_string(), id: "test_id".to_string(),
choices: vec![ChatChoiceStream { choices: vec![ChatChoiceStream {
index: 0, index: 0,
delta: ChatCompletionStreamResponseDelta { delta: ChatCompletionStreamResponseDelta {
content: Some( content: Some(dynamo_protocols::types::ChatCompletionMessageContent::Text(
dynamo_async_openai::types::ChatCompletionMessageContent::Text(
"test".to_string(), "test".to_string(),
), )),
),
function_call: None, function_call: None,
tool_calls: None, tool_calls: None,
role: Some(Role::Assistant), role: Some(Role::Assistant),
...@@ -1579,7 +1573,7 @@ mod tests { ...@@ -1579,7 +1573,7 @@ mod tests {
// In practice, this would have real logprobs data // In practice, this would have real logprobs data
NvCreateChatCompletionStreamResponse { NvCreateChatCompletionStreamResponse {
inner: dynamo_async_openai::types::CreateChatCompletionStreamResponse { inner: dynamo_protocols::types::CreateChatCompletionStreamResponse {
id: "test_id".to_string(), id: "test_id".to_string(),
choices: vec![], choices: vec![],
created: 1234567890, created: 1234567890,
......
...@@ -18,7 +18,7 @@ pub mod tools; ...@@ -18,7 +18,7 @@ pub mod tools;
use anyhow::Context; use anyhow::Context;
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use dynamo_async_openai::types::{ use dynamo_protocols::types::{
ChatCompletionRequestMessage, ChatCompletionRequestUserMessageContent, ChatCompletionRequestMessage, ChatCompletionRequestUserMessageContent,
ChatCompletionRequestUserMessageContentPart, ChatCompletionToolChoiceOption, EncodingFormat, ChatCompletionRequestUserMessageContentPart, ChatCompletionToolChoiceOption, EncodingFormat,
}; };
...@@ -649,11 +649,11 @@ impl OpenAIPreprocessor { ...@@ -649,11 +649,11 @@ impl OpenAIPreprocessor {
let mut builder = PreprocessedEmbeddingRequest::builder(); let mut builder = PreprocessedEmbeddingRequest::builder();
let all_token_ids = match &request.inner.input { let all_token_ids = match &request.inner.input {
dynamo_async_openai::types::EmbeddingInput::String(s) => { dynamo_protocols::types::EmbeddingInput::String(s) => {
let encoding = self.tokenizer.encode(s)?; let encoding = self.tokenizer.encode(s)?;
vec![encoding.token_ids().to_vec()] vec![encoding.token_ids().to_vec()]
} }
dynamo_async_openai::types::EmbeddingInput::StringArray(arr) => { dynamo_protocols::types::EmbeddingInput::StringArray(arr) => {
let input_strs: Vec<String> = arr.to_vec(); let input_strs: Vec<String> = arr.to_vec();
let encodings = tokio::task::spawn_blocking({ let encodings = tokio::task::spawn_blocking({
let tokenizer = self.tokenizer.clone(); let tokenizer = self.tokenizer.clone();
...@@ -669,10 +669,10 @@ impl OpenAIPreprocessor { ...@@ -669,10 +669,10 @@ impl OpenAIPreprocessor {
.collect(); .collect();
token_arrays token_arrays
} }
dynamo_async_openai::types::EmbeddingInput::IntegerArray(token_ids) => { dynamo_protocols::types::EmbeddingInput::IntegerArray(token_ids) => {
vec![token_ids.clone()] vec![token_ids.clone()]
} }
dynamo_async_openai::types::EmbeddingInput::ArrayOfIntegerArray(token_arrays) => { dynamo_protocols::types::EmbeddingInput::ArrayOfIntegerArray(token_arrays) => {
token_arrays.clone() token_arrays.clone()
} }
}; };
...@@ -1032,11 +1032,11 @@ impl OpenAIPreprocessor { ...@@ -1032,11 +1032,11 @@ impl OpenAIPreprocessor {
stream.map(move |output| { stream.map(move |output| {
output.map_data(|engine_output| { output.map_data(|engine_output| {
// Convert engine output to OpenAI response format // Convert engine output to OpenAI response format
let embeddings: Vec<dynamo_async_openai::types::Embedding> = engine_output let embeddings: Vec<dynamo_protocols::types::Embedding> = engine_output
.embeddings .embeddings
.into_iter() .into_iter()
.enumerate() .enumerate()
.map(|(index, embedding)| dynamo_async_openai::types::Embedding { .map(|(index, embedding)| dynamo_protocols::types::Embedding {
index: index as u32, index: index as u32,
object: "embedding".to_string(), object: "embedding".to_string(),
embedding: embedding.into_iter().map(|f| f as f32).collect(), embedding: embedding.into_iter().map(|f| f as f32).collect(),
...@@ -1044,11 +1044,11 @@ impl OpenAIPreprocessor { ...@@ -1044,11 +1044,11 @@ impl OpenAIPreprocessor {
.collect(); .collect();
let response = NvCreateEmbeddingResponse { let response = NvCreateEmbeddingResponse {
inner: dynamo_async_openai::types::CreateEmbeddingResponse { inner: dynamo_protocols::types::CreateEmbeddingResponse {
object: "list".to_string(), object: "list".to_string(),
model: original_request.inner.model.clone(), model: original_request.inner.model.clone(),
data: embeddings, data: embeddings,
usage: dynamo_async_openai::types::EmbeddingUsage { usage: dynamo_protocols::types::EmbeddingUsage {
prompt_tokens: engine_output.prompt_tokens, prompt_tokens: engine_output.prompt_tokens,
total_tokens: engine_output.total_tokens, total_tokens: engine_output.total_tokens,
}, },
...@@ -1095,14 +1095,14 @@ impl OpenAIPreprocessor { ...@@ -1095,14 +1095,14 @@ impl OpenAIPreprocessor {
/// Apply tool calling jail to the stream if needed /// Apply tool calling jail to the stream if needed
pub fn apply_tool_calling_jail<S>( pub fn apply_tool_calling_jail<S>(
tool_call_parser: Option<String>, tool_call_parser: Option<String>,
tool_choice: Option<dynamo_async_openai::types::ChatCompletionToolChoiceOption>, tool_choice: Option<dynamo_protocols::types::ChatCompletionToolChoiceOption>,
tool_definitions: Option<Vec<dynamo_parsers::tool_calling::ToolDefinition>>, tool_definitions: Option<Vec<dynamo_parsers::tool_calling::ToolDefinition>>,
stream: S, stream: S,
) -> impl Stream<Item = Annotated<NvCreateChatCompletionStreamResponse>> + Send ) -> impl Stream<Item = Annotated<NvCreateChatCompletionStreamResponse>> + Send
where where
S: Stream<Item = Annotated<NvCreateChatCompletionStreamResponse>> + Send + 'static, S: Stream<Item = Annotated<NvCreateChatCompletionStreamResponse>> + Send + 'static,
{ {
use dynamo_async_openai::types::ChatCompletionToolChoiceOption; use dynamo_protocols::types::ChatCompletionToolChoiceOption;
let mut builder = JailedStream::builder(); let mut builder = JailedStream::builder();
...@@ -1227,9 +1227,7 @@ impl OpenAIPreprocessor { ...@@ -1227,9 +1227,7 @@ impl OpenAIPreprocessor {
for choice in data.inner.choices.iter_mut() { for choice in data.inner.choices.iter_mut() {
// Reasoning parsing only applies to text content // Reasoning parsing only applies to text content
if let Some( if let Some(
dynamo_async_openai::types::ChatCompletionMessageContent::Text( dynamo_protocols::types::ChatCompletionMessageContent::Text(text),
text,
),
) = choice.delta.content.as_ref() ) = choice.delta.content.as_ref()
{ {
let parser_result = let parser_result =
...@@ -1237,7 +1235,7 @@ impl OpenAIPreprocessor { ...@@ -1237,7 +1235,7 @@ impl OpenAIPreprocessor {
// Update this specific choice with parsed content // Update this specific choice with parsed content
choice.delta.content = parser_result.get_some_normal_text().map( choice.delta.content = parser_result.get_some_normal_text().map(
dynamo_async_openai::types::ChatCompletionMessageContent::Text, dynamo_protocols::types::ChatCompletionMessageContent::Text,
); );
choice.delta.reasoning_content = parser_result.get_some_reasoning(); choice.delta.reasoning_content = parser_result.get_some_reasoning();
} }
......
...@@ -6,8 +6,8 @@ use std::time::Duration; ...@@ -6,8 +6,8 @@ use std::time::Duration;
use anyhow::Result; use anyhow::Result;
use dynamo_async_openai::types::ChatCompletionRequestUserMessageContentPart;
use dynamo_memory::nixl::NixlAgent; use dynamo_memory::nixl::NixlAgent;
use dynamo_protocols::types::ChatCompletionRequestUserMessageContentPart;
use super::common::EncodedMediaData; use super::common::EncodedMediaData;
use super::decoders::{Decoder, MediaDecoder}; use super::decoders::{Decoder, MediaDecoder};
...@@ -157,7 +157,7 @@ mod tests { ...@@ -157,7 +157,7 @@ mod tests {
use super::super::decoders::ImageDecoder; use super::super::decoders::ImageDecoder;
use super::super::rdma::DataType; use super::super::rdma::DataType;
use super::*; use super::*;
use dynamo_async_openai::types::{ChatCompletionRequestMessageContentPartImage, ImageUrl}; use dynamo_protocols::types::{ChatCompletionRequestMessageContentPartImage, ImageUrl};
#[tokio::test] #[tokio::test]
async fn test_fetch_and_decode() { async fn test_fetch_and_decode() {
......
...@@ -52,9 +52,7 @@ pub enum PromptInput { ...@@ -52,9 +52,7 @@ pub enum PromptInput {
pub trait OAIChatLikeRequest { pub trait OAIChatLikeRequest {
fn model(&self) -> String; fn model(&self) -> String;
fn messages(&self) -> Value; fn messages(&self) -> Value;
fn typed_messages( fn typed_messages(&self) -> Option<&[dynamo_protocols::types::ChatCompletionRequestMessage]> {
&self,
) -> Option<&[dynamo_async_openai::types::ChatCompletionRequestMessage]> {
None None
} }
fn tools(&self) -> Option<Value> { fn tools(&self) -> Option<Value> {
......
...@@ -289,9 +289,7 @@ impl OAIChatLikeRequest for NvCreateChatCompletionRequest { ...@@ -289,9 +289,7 @@ impl OAIChatLikeRequest for NvCreateChatCompletionRequest {
Value::from_serialize(&messages_json) Value::from_serialize(&messages_json)
} }
fn typed_messages( fn typed_messages(&self) -> Option<&[dynamo_protocols::types::ChatCompletionRequestMessage]> {
&self,
) -> Option<&[dynamo_async_openai::types::ChatCompletionRequestMessage]> {
Some(self.inner.messages.as_slice()) Some(self.inner.messages.as_slice())
} }
...@@ -331,7 +329,7 @@ impl OAIChatLikeRequest for NvCreateChatCompletionRequest { ...@@ -331,7 +329,7 @@ impl OAIChatLikeRequest for NvCreateChatCompletionRequest {
// .map(|last| { // .map(|last| {
// !matches!( // !matches!(
// last, // last,
// dynamo_async_openai::types::ChatCompletionRequestMessage::Assistant(_) // dynamo_protocols::types::ChatCompletionRequestMessage::Assistant(_)
// ) // )
// }) // })
// .unwrap_or(true) // .unwrap_or(true)
...@@ -355,9 +353,9 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest { ...@@ -355,9 +353,9 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest {
self.inner.model.clone() self.inner.model.clone()
} }
fn messages(&self) -> minijinja::value::Value { fn messages(&self) -> minijinja::value::Value {
let message = dynamo_async_openai::types::ChatCompletionRequestMessage::User( let message = dynamo_protocols::types::ChatCompletionRequestMessage::User(
dynamo_async_openai::types::ChatCompletionRequestUserMessage { dynamo_protocols::types::ChatCompletionRequestUserMessage {
content: dynamo_async_openai::types::ChatCompletionRequestUserMessageContent::Text( content: dynamo_protocols::types::ChatCompletionRequestUserMessageContent::Text(
crate::protocols::openai::completions::prompt_to_string(&self.inner.prompt), crate::protocols::openai::completions::prompt_to_string(&self.inner.prompt),
), ),
name: None, name: None,
...@@ -373,16 +371,16 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest { ...@@ -373,16 +371,16 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest {
fn prompt_input_type(&self) -> PromptInput { fn prompt_input_type(&self) -> PromptInput {
match &self.inner.prompt { match &self.inner.prompt {
dynamo_async_openai::types::Prompt::IntegerArray(_) => { dynamo_protocols::types::Prompt::IntegerArray(_) => {
PromptInput::Tokens(TokenInput::Single(vec![])) PromptInput::Tokens(TokenInput::Single(vec![]))
} }
dynamo_async_openai::types::Prompt::ArrayOfIntegerArray(_) => { dynamo_protocols::types::Prompt::ArrayOfIntegerArray(_) => {
PromptInput::Tokens(TokenInput::Batch(vec![])) PromptInput::Tokens(TokenInput::Batch(vec![]))
} }
dynamo_async_openai::types::Prompt::String(_) => { dynamo_protocols::types::Prompt::String(_) => {
PromptInput::Text(TextInput::Single(String::new())) PromptInput::Text(TextInput::Single(String::new()))
} }
dynamo_async_openai::types::Prompt::StringArray(_) => { dynamo_protocols::types::Prompt::StringArray(_) => {
PromptInput::Text(TextInput::Batch(vec![])) PromptInput::Text(TextInput::Batch(vec![]))
} }
} }
...@@ -390,10 +388,10 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest { ...@@ -390,10 +388,10 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest {
fn extract_tokens(&self) -> Option<TokenInput> { fn extract_tokens(&self) -> Option<TokenInput> {
match &self.inner.prompt { match &self.inner.prompt {
dynamo_async_openai::types::Prompt::IntegerArray(tokens) => { dynamo_protocols::types::Prompt::IntegerArray(tokens) => {
Some(TokenInput::Single(tokens.clone())) Some(TokenInput::Single(tokens.clone()))
} }
dynamo_async_openai::types::Prompt::ArrayOfIntegerArray(arrays) => { dynamo_protocols::types::Prompt::ArrayOfIntegerArray(arrays) => {
Some(TokenInput::Batch(arrays.clone())) Some(TokenInput::Batch(arrays.clone()))
} }
_ => None, _ => None,
...@@ -402,10 +400,10 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest { ...@@ -402,10 +400,10 @@ impl OAIChatLikeRequest for NvCreateCompletionRequest {
fn extract_text(&self) -> Option<TextInput> { fn extract_text(&self) -> Option<TextInput> {
match &self.inner.prompt { match &self.inner.prompt {
dynamo_async_openai::types::Prompt::String(text) => { dynamo_protocols::types::Prompt::String(text) => {
Some(TextInput::Single(text.to_string())) Some(TextInput::Single(text.to_string()))
} }
dynamo_async_openai::types::Prompt::StringArray(texts) => { dynamo_protocols::types::Prompt::StringArray(texts) => {
Some(TextInput::Batch(texts.to_vec())) Some(TextInput::Batch(texts.to_vec()))
} }
_ => None, _ => None,
...@@ -492,7 +490,7 @@ impl OAIPromptFormatter for HfTokenizerConfigJsonFormatter { ...@@ -492,7 +490,7 @@ impl OAIPromptFormatter for HfTokenizerConfigJsonFormatter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use dynamo_async_openai::types::ChatCompletionRequestMessage as Msg; use dynamo_protocols::types::ChatCompletionRequestMessage as Msg;
use minijinja::{Environment, context}; use minijinja::{Environment, context};
/// Tests that media URL content parts are converted to empty placeholders. /// Tests that media URL content parts are converted to empty placeholders.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment