Skip to content

Commit 20ff6a5

Browse files
committed
fix: trim trailing slash from base_url, use format! for Anthropic URL
1 parent ec6f7a3 commit 20ff6a5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎crates/contribai-rs/src/llm/provider.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,9 @@ impl OpenAIProvider {
594594
let base_url = config
595595
.base_url
596596
.clone()
597-
.unwrap_or_else(|| "https://api.openai.com/v1".to_string());
597+
.unwrap_or_else(|| "https://api.openai.com/v1".to_string())
598+
.trim_end_matches('/')
599+
.to_string();
598600

599601
info!(model = %config.model, base_url = %base_url, "OpenAI provider");
600602

@@ -711,7 +713,9 @@ impl AnthropicProvider {
711713
let base_url = config
712714
.base_url
713715
.clone()
714-
.unwrap_or_else(|| "https://api.anthropic.com/v1".to_string());
716+
.unwrap_or_else(|| "https://api.anthropic.com/v1".to_string())
717+
.trim_end_matches('/')
718+
.to_string();
715719

716720
info!(model = %config.model, base_url = %base_url, "Anthropic provider");
717721

@@ -768,7 +772,7 @@ impl LlmProvider for AnthropicProvider {
768772

769773
let response = self
770774
.client
771-
.post(self.base_url.to_string() + "/messages")
775+
.post(format!("{}/messages", self.base_url))
772776
.header("x-api-key", &self.api_key)
773777
.header("anthropic-version", "2023-06-01")
774778
.header("content-type", "application/json")

0 commit comments

Comments
 (0)