llmproxy 0.2.2

A simple HTTP proxy server for llm api requests
Documentation
use serde::{Deserialize, Serialize};

/// Represents the payload for registering or unregistering a model server.
/// Used by both the client and the server.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RegisterRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model_name: Option<String>,
    pub addr: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum ResponseStatus {
    Success,
    Warning,
    Error,
}

/// Represents the generic JSON response from the server.
/// Used by the client to parse both success and error messages.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ServerResponse {
    pub status: ResponseStatus,
    pub message: String,
}

/// Used by the server to extract the model name from the request body.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ModelExtractPayload {
    pub model: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ProxyServerInfo {
    pub model_name: String,
    pub addr: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avg_response_time_ms: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_requests: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recent_failures: Option<u64>,
}

/// Represents the payload for testing a model server.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TestRequest {
    pub addr: String,
}

/// OpenAI /v1/models API response format
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ModelsListResponse {
    pub object: String,
    pub data: Vec<ModelInfo>,
}

/// Information about a model from /v1/models endpoint
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ModelInfo {
    pub id: String,
    pub object: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub owned_by: Option<String>,
}