File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,13 @@ use async_openai::Client as OpenAIClient;
44pub use super :: openai:: Client ;
55
66impl Client {
7- pub async fn new ( spec : super :: LlmSpec ) -> anyhow:: Result < Self > {
7+ pub async fn new_litellm ( spec : super :: LlmSpec ) -> anyhow:: Result < Self > {
88 let address = spec. address . clone ( ) . unwrap_or_else ( || "http://127.0.0.1:4000" . to_string ( ) ) ;
99 let api_key = std:: env:: var ( "LITELLM_API_KEY" ) . ok ( ) ;
1010 let mut config = OpenAIConfig :: new ( ) . with_api_base ( address) ;
1111 if let Some ( api_key) = api_key {
1212 config = config. with_api_key ( api_key) ;
1313 }
14- Ok ( Self {
15- client : OpenAIClient :: with_config ( config) ,
16- model : spec. model ,
17- } )
14+ Ok ( Client :: from_parts ( OpenAIClient :: with_config ( config) , spec. model ) )
1815 }
1916}
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ pub async fn new_llm_generation_client(spec: LlmSpec) -> Result<Box<dyn LlmGener
7474 Box :: new ( anthropic:: Client :: new ( spec) . await ?) as Box < dyn LlmGenerationClient >
7575 }
7676 LlmApiType :: LiteLlm => {
77- Box :: new ( litellm:: Client :: new ( spec) . await ?) as Box < dyn LlmGenerationClient >
77+ Box :: new ( litellm:: Client :: new_litellm ( spec) . await ?) as Box < dyn LlmGenerationClient >
7878 }
7979 } ;
8080 Ok ( client)
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ pub struct Client {
2020}
2121
2222impl Client {
23+ pub ( crate ) fn from_parts ( client : async_openai:: Client < OpenAIConfig > , model : String ) -> Self {
24+ Self { client, model }
25+ }
26+
2327 pub async fn new ( spec : super :: LlmSpec ) -> Result < Self > {
2428 if let Some ( address) = spec. address {
2529 api_bail ! ( "OpenAI doesn't support custom API address: {address}" ) ;
You can’t perform that action at this time.
0 commit comments