-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: Add LiteLLM provider with automatic prompt caching support #3380
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
Changes from all commits
65f3fde
8659d40
2258308
a6627b2
535add4
adf1fa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ pub struct ModelInfo { | |
| pub output_token_cost: Option<f64>, | ||
| /// Currency for the costs (default: "$") | ||
| pub currency: Option<String>, | ||
| /// Whether this model supports cache control | ||
| pub supports_cache_control: Option<bool>, | ||
| } | ||
|
|
||
| impl ModelInfo { | ||
|
|
@@ -52,6 +54,7 @@ impl ModelInfo { | |
| input_token_cost: None, | ||
| output_token_cost: None, | ||
| currency: None, | ||
| supports_cache_control: None, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -68,6 +71,7 @@ impl ModelInfo { | |
| input_token_cost: Some(input_cost), | ||
| output_token_cost: Some(output_cost), | ||
| currency: Some("$".to_string()), | ||
| supports_cache_control: None, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -115,6 +119,7 @@ impl ProviderMetadata { | |
| input_token_cost: None, | ||
| output_token_cost: None, | ||
| currency: None, | ||
| supports_cache_control: None, | ||
| }) | ||
| .collect(), | ||
| model_doc_link: model_doc_link.to_string(), | ||
|
|
@@ -290,6 +295,11 @@ pub trait Provider: Send + Sync { | |
| false | ||
| } | ||
|
|
||
| /// Check if this provider supports cache control | ||
| fn supports_cache_control(&self) -> bool { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think we need this comment (I know we have this sort of thing going on everywhere but still)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I included it to maintain consistency with the surrounding functions(ie supports_embeddings). This notation seems common in base.rs, but I agree with your thought.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it is, but I'd like to start pushing back on that. I think a lot of it might be LLM written code - the robots really like extra comments like this |
||
| false | ||
| } | ||
|
|
||
| /// Create embeddings if supported. Default implementation returns an error. | ||
| async fn create_embeddings(&self, _texts: Vec<String>) -> Result<Vec<Vec<f32>>, ProviderError> { | ||
| Err(ProviderError::ExecutionError( | ||
|
|
@@ -435,6 +445,7 @@ mod tests { | |
| input_token_cost: None, | ||
| output_token_cost: None, | ||
| currency: None, | ||
| supports_cache_control: None, | ||
| }; | ||
| assert_eq!(info.context_limit, 1000); | ||
|
|
||
|
|
@@ -445,6 +456,7 @@ mod tests { | |
| input_token_cost: None, | ||
| output_token_cost: None, | ||
| currency: None, | ||
| supports_cache_control: None, | ||
| }; | ||
| assert_eq!(info, info2); | ||
|
|
||
|
|
@@ -455,6 +467,7 @@ mod tests { | |
| input_token_cost: None, | ||
| output_token_cost: None, | ||
| currency: None, | ||
| supports_cache_control: None, | ||
| }; | ||
| assert_ne!(info, info3); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ci failed after #3260