llmprogram 0.1.0

A Rust library that provides a structured and powerful way to create and run programs that use Large Language Models (LLMs). It uses a YAML-based configuration to define the behavior of your LLM programs, making them easy to create, manage, and share.
Documentation
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ModelConfig {
    pub provider: String,
    pub name: String,
    #[serde(default = "default_temperature")]
    pub temperature: f32,
    #[serde(default = "default_max_tokens")]
    pub max_tokens: u32,
    #[serde(default = "default_response_format")]
    pub response_format: String,
}

fn default_temperature() -> f32 {
    0.7
}

fn default_max_tokens() -> u32 {
    1000
}

fn default_response_format() -> String {
    "json_object".to_string()
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ProgramConfig {
    pub name: String,
    pub description: String,
    #[serde(default = "default_version")]
    pub version: String,
    pub model: ModelConfig,
    pub system_prompt: String,
    pub input_schema: serde_json::Value,
    pub output_schema: serde_json::Value,
    pub template: String,
    #[serde(default)]
    pub database: DatabaseConfig,
}

fn default_version() -> String {
    "1.0.0".to_string()
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DatabaseConfig {
    #[serde(default)]
    pub path: Option<String>,
}

impl Default for DatabaseConfig {
    fn default() -> Self {
        DatabaseConfig { path: None }
    }
}