fix: detect NVIDIA API as GLM provider, handle full URL path
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
This commit is contained in:
parent
32fbdb4b17
commit
8ddcde4830
3 changed files with 8 additions and 10 deletions
|
|
@ -113,6 +113,7 @@ impl DriveMonitor {
|
||||||
/// Load file states from disk to avoid reprocessing unchanged files
|
/// Load file states from disk to avoid reprocessing unchanged files
|
||||||
async fn load_file_states(&self) -> Result<(), Box<dyn Error + Send + Sync>> {
|
async fn load_file_states(&self) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
let path = self.file_state_path();
|
let path = self.file_state_path();
|
||||||
|
debug!("[DRIVE_MONITOR] Loading file states from {} for bot {}", path.display(), self.bot_id);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
match tokio_fs::read_to_string(&path).await {
|
match tokio_fs::read_to_string(&path).await {
|
||||||
Ok(content) => {
|
Ok(content) => {
|
||||||
|
|
@ -121,7 +122,7 @@ impl DriveMonitor {
|
||||||
let mut file_states = self.file_states.write().await;
|
let mut file_states = self.file_states.write().await;
|
||||||
let count = states.len();
|
let count = states.len();
|
||||||
*file_states = states;
|
*file_states = states;
|
||||||
trace!(
|
info!(
|
||||||
"[DRIVE_MONITOR] Loaded {} file states from disk for bot {}",
|
"[DRIVE_MONITOR] Loaded {} file states from disk for bot {}",
|
||||||
count,
|
count,
|
||||||
self.bot_id
|
self.bot_id
|
||||||
|
|
|
||||||
|
|
@ -98,12 +98,6 @@ pub struct GLMClient {
|
||||||
|
|
||||||
impl GLMClient {
|
impl GLMClient {
|
||||||
pub fn new(base_url: String) -> Self {
|
pub fn new(base_url: String) -> Self {
|
||||||
// For z.ai GLM API:
|
|
||||||
// - Base URL typically is: https://api.z.ai/api/coding/paas/v4
|
|
||||||
// - Endpoint path is: /chat/completions
|
|
||||||
// - Full URL becomes: https://api.z.ai/api/coding/paas/v4/chat/completions
|
|
||||||
|
|
||||||
// Remove trailing slash from base_url if present
|
|
||||||
let base = base_url.trim_end_matches('/').to_string();
|
let base = base_url.trim_end_matches('/').to_string();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -113,9 +107,12 @@ impl GLMClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_url(&self) -> String {
|
fn build_url(&self) -> String {
|
||||||
// GLM/z.ai uses /chat/completions (not /v1/chat/completions)
|
if self.base_url.contains("/chat/completions") {
|
||||||
|
self.base_url.clone()
|
||||||
|
} else {
|
||||||
format!("{}/chat/completions", self.base_url)
|
format!("{}/chat/completions", self.base_url)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Sanitizes a string by removing invalid UTF-8 surrogate characters
|
/// Sanitizes a string by removing invalid UTF-8 surrogate characters
|
||||||
fn sanitize_utf8(input: &str) -> String {
|
fn sanitize_utf8(input: &str) -> String {
|
||||||
|
|
|
||||||
|
|
@ -595,7 +595,7 @@ impl From<&str> for LLMProviderType {
|
||||||
} else {
|
} else {
|
||||||
Self::Claude
|
Self::Claude
|
||||||
}
|
}
|
||||||
} else if lower.contains("z.ai") || lower.contains("glm") {
|
} else if lower.contains("z.ai") || lower.contains("glm") || lower.contains("nvidia") {
|
||||||
Self::GLM
|
Self::GLM
|
||||||
} else if lower.contains("bedrock") {
|
} else if lower.contains("bedrock") {
|
||||||
Self::Bedrock
|
Self::Bedrock
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue