feat: define Rust models and lib exports
This commit is contained in:
@@ -0,0 +1,66 @@
|
|||||||
|
use crate::models::{Config, ProfileSummary};
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn load_config_command() -> Config {
|
||||||
|
Config {
|
||||||
|
default_model: None,
|
||||||
|
providers: indexmap::IndexMap::new(),
|
||||||
|
models: indexmap::IndexMap::new(),
|
||||||
|
raw_other: toml_edit::Table::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_config_command(_config: Config) -> Result<(), String> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn list_profiles() -> Vec<ProfileSummary> {
|
||||||
|
Vec::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn load_profile(_filename: String) -> Config {
|
||||||
|
Config {
|
||||||
|
default_model: None,
|
||||||
|
providers: indexmap::IndexMap::new(),
|
||||||
|
models: indexmap::IndexMap::new(),
|
||||||
|
raw_other: toml_edit::Table::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_profile(_filename: String, _config: Config) -> Result<(), String> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn switch_profile(_filename: String) -> Result<Config, String> {
|
||||||
|
Ok(Config {
|
||||||
|
default_model: None,
|
||||||
|
providers: indexmap::IndexMap::new(),
|
||||||
|
models: indexmap::IndexMap::new(),
|
||||||
|
raw_other: toml_edit::Table::new(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn rename_profile(_old_filename: String, _new_name: String) -> Result<String, String> {
|
||||||
|
Ok(String::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn delete_profile(_filename: String) -> Result<(), String> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn open_config_dir() -> Result<(), String> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_app_version() -> String {
|
||||||
|
env!("CARGO_PKG_VERSION").to_string()
|
||||||
|
}
|
||||||
@@ -1,6 +1,24 @@
|
|||||||
|
pub mod commands;
|
||||||
|
pub mod config_io;
|
||||||
|
pub mod models;
|
||||||
|
pub mod profile_manager;
|
||||||
|
pub mod validators;
|
||||||
|
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
commands::load_config_command,
|
||||||
|
commands::save_config_command,
|
||||||
|
commands::list_profiles,
|
||||||
|
commands::load_profile,
|
||||||
|
commands::save_profile,
|
||||||
|
commands::switch_profile,
|
||||||
|
commands::rename_profile,
|
||||||
|
commands::delete_profile,
|
||||||
|
commands::open_config_dir,
|
||||||
|
commands::get_app_version,
|
||||||
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
use indexmap::IndexMap;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
pub use toml_edit::Table;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum ProviderType {
|
||||||
|
Kimi,
|
||||||
|
Anthropic,
|
||||||
|
Openai,
|
||||||
|
#[serde(rename = "openai_responses")]
|
||||||
|
OpenaiResponses,
|
||||||
|
#[serde(rename = "google-genai")]
|
||||||
|
GoogleGenai,
|
||||||
|
Vertexai,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProviderType {
|
||||||
|
pub fn as_str(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ProviderType::Kimi => "kimi",
|
||||||
|
ProviderType::Anthropic => "anthropic",
|
||||||
|
ProviderType::Openai => "openai",
|
||||||
|
ProviderType::OpenaiResponses => "openai_responses",
|
||||||
|
ProviderType::GoogleGenai => "google-genai",
|
||||||
|
ProviderType::Vertexai => "vertexai",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Provider {
|
||||||
|
pub name: String,
|
||||||
|
pub provider_type: ProviderType,
|
||||||
|
pub base_url: Option<String>,
|
||||||
|
pub api_key: Option<String>,
|
||||||
|
pub env: IndexMap<String, String>,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub raw_other: Table,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Model {
|
||||||
|
pub alias: String,
|
||||||
|
pub provider: String,
|
||||||
|
pub model: String,
|
||||||
|
pub max_context_size: u64,
|
||||||
|
pub display_name: Option<String>,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub raw_other: Table,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub default_model: Option<String>,
|
||||||
|
pub providers: IndexMap<String, Provider>,
|
||||||
|
pub models: IndexMap<String, Model>,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub raw_other: Table,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ProfileSummary {
|
||||||
|
pub name: String,
|
||||||
|
pub filename: String,
|
||||||
|
pub is_active: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Profile {
|
||||||
|
pub name: String,
|
||||||
|
pub filename: String,
|
||||||
|
pub config: Config,
|
||||||
|
pub is_active: bool,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user