use crate::error::Result;
use serde::{Deserialize, Serialize};
pub struct XinferenceProvider {
#[allow(dead_code)]
base_url: String,
}
impl XinferenceProvider {
pub fn new() -> Self {
Self {
base_url: "http://localhost:9997/v1".to_string(),
}
}
pub fn with_base_url(base_url: &str) -> Self {
Self {
base_url: base_url.to_string(),
}
}
pub async fn list_models(&self) -> Result<Vec<String>> {
Ok(vec!["xinference-model".to_string()])
}
pub fn get_model_info(_model: &str) -> Option<XinferenceModelInfo> {
Some(XinferenceModelInfo {
name: "xinference-model".to_string(),
context_window: 8192,
supports_tools: true,
})
}
}
impl Default for XinferenceProvider {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct XinferenceModelInfo {
pub name: String,
pub context_window: u32,
pub supports_tools: bool,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_provider_creation() {
let provider = XinferenceProvider::new();
assert_eq!(provider.base_url, "http://localhost:9997/v1");
}
}