Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edgee"
version = "2.0.5"
version = "2.0.6"
edition = "2021"
authors = ["Edgee <opensource@edgee.ai>"]
license = "Apache-2.0"
Expand Down
10 changes: 3 additions & 7 deletions examples/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! This example includes a large context in the user message to demonstrate meaningful
//! compression savings.

use edgee::{CompressionConfiguration, Edgee, InputObject, Message};
use edgee::{Edgee, InputObject, Message};

// Large context document to demonstrate input compression
const LARGE_CONTEXT: &str = r#"
Expand Down Expand Up @@ -81,12 +81,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
);

// Create input with compression settings using builder pattern
let input = InputObject::new(vec![Message::user(user_message)])
.with_compression_model("agentic")
.with_compression_configuration(CompressionConfiguration {
rate: Some(0.5),
semantic_preservation_threshold: None,
});
let input =
InputObject::new(vec![Message::user(user_message)]).with_compression_model("claude");

let response = client.send("anthropic/claude-haiku-4-5", input).await?;

Expand Down
9 changes: 0 additions & 9 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct ParsedInput {
tool_choice: Option<serde_json::Value>,
tags: Option<Vec<String>>,
compression_model: Option<String>,
compression_configuration: Option<CompressionConfiguration>,
}

/// Main client for interacting with the Edgee AI Gateway
Expand Down Expand Up @@ -122,9 +121,6 @@ impl Edgee {
if let Some(compression_model) = &parsed.compression_model {
body["compression_model"] = json!(compression_model);
}
if let Some(config) = &parsed.compression_configuration {
body["compression_configuration"] = json!(config);
}

let response = self
.client
Expand Down Expand Up @@ -201,9 +197,6 @@ impl Edgee {
if let Some(compression_model) = &parsed.compression_model {
body["compression_model"] = json!(compression_model);
}
if let Some(config) = &parsed.compression_configuration {
body["compression_configuration"] = json!(config);
}

let response = self
.client
Expand Down Expand Up @@ -285,15 +278,13 @@ impl Edgee {
tool_choice: None,
tags: None,
compression_model: None,
compression_configuration: None,
},
Input::Object(obj) => ParsedInput {
messages: obj.messages,
tools: obj.tools,
tool_choice: obj.tool_choice,
tags: obj.tags,
compression_model: obj.compression_model,
compression_configuration: obj.compression_configuration,
},
}
}
Expand Down
42 changes: 5 additions & 37 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,6 @@ pub enum ToolChoice {
},
}

/// Configuration for the compression model.
/// Only relevant for the `agentic` compression model.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompressionConfiguration {
/// Compression rate (0.0-1.0). Defaults to 0.8 when not specified.
#[serde(skip_serializing_if = "Option::is_none")]
pub rate: Option<f64>,
/// Semantic preservation threshold (0-100).
#[serde(skip_serializing_if = "Option::is_none")]
pub semantic_preservation_threshold: Option<i32>,
}

/// Input for the chat completion request
#[derive(Debug, Clone, Serialize)]
pub struct InputObject {
Expand All @@ -205,16 +193,11 @@ pub struct InputObject {
pub tool_choice: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
/// Compression model for this request (agentic, claude, opencode, cursor, or customer).
/// Compression model for this request (claude, opencode, cursor, or customer).
/// Only one compression model per request. Each model is a bundle of strategies.
/// This is a gateway-internal field and is never sent to providers.
#[serde(default, skip_serializing)]
pub compression_model: Option<String>,
/// Configuration for the compression model (rate, semantic preservation threshold).
/// Only relevant for the `agentic` compression model.
/// This is a gateway-internal field and is never sent to providers.
#[serde(default, skip_serializing)]
pub compression_configuration: Option<CompressionConfiguration>,
}

impl InputObject {
Expand All @@ -226,7 +209,6 @@ impl InputObject {
tool_choice: None,
tags: None,
compression_model: None,
compression_configuration: None,
}
}

Expand All @@ -248,17 +230,11 @@ impl InputObject {
self
}

/// Set the compression model for this request (agentic, claude, opencode, cursor, customer)
/// Set the compression model for this request (claude, opencode, cursor, customer)
pub fn with_compression_model(mut self, model: impl Into<String>) -> Self {
self.compression_model = Some(model.into());
self
}

/// Set the compression configuration (only relevant for agentic model)
pub fn with_compression_configuration(mut self, config: CompressionConfiguration) -> Self {
self.compression_configuration = Some(config);
self
}
}

/// Token usage information
Expand Down Expand Up @@ -437,16 +413,8 @@ mod tests {

#[test]
fn test_input_object_with_compression_builder() {
let input = InputObject::new(vec![Message::user("Hello")])
.with_compression_model("agentic")
.with_compression_configuration(CompressionConfiguration {
rate: Some(0.5),
semantic_preservation_threshold: Some(60),
});

assert_eq!(input.compression_model, Some("agentic".to_string()));
let config = input.compression_configuration.unwrap();
assert_eq!(config.rate, Some(0.5));
assert_eq!(config.semantic_preservation_threshold, Some(60));
let input = InputObject::new(vec![Message::user("Hello")]).with_compression_model("claude");

assert_eq!(input.compression_model, Some("claude".to_string()));
}
}
Loading