diff --git a/src/db/enum/mod.rs b/src/db/enum/mod.rs new file mode 100644 index 0000000..943cc56 --- /dev/null +++ b/src/db/enum/mod.rs @@ -0,0 +1,6 @@ +pub enum PromptRole { + User, + Assistant, + System, + Tool, +} \ No newline at end of file diff --git a/src/db/mod.rs b/src/db/mod.rs index e4a9b25..8002c18 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,2 +1,3 @@ mod models; -mod store; \ No newline at end of file +mod store; +mod r#enum; \ No newline at end of file diff --git a/src/db/models/agent_arena.rs b/src/db/models/agent_arena.rs new file mode 100644 index 0000000..a13a175 --- /dev/null +++ b/src/db/models/agent_arena.rs @@ -0,0 +1,13 @@ +use chrono::{DateTime, Utc}; +pub struct AgentArena { + pub id: i32, + pub chat_uuid: String, + pub round_uuid: String, + pub agent_id: i32, + pub vote_type: i8, + pub comment: String, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/agent_info.rs b/src/db/models/agent_info.rs new file mode 100644 index 0000000..e3d79fd --- /dev/null +++ b/src/db/models/agent_info.rs @@ -0,0 +1,16 @@ +use chrono::{DateTime, Utc}; +pub struct AgentInfo { + pub id: i32, + pub llm_id: i32, + pub name: String, + pub description: String, + pub prompt_id: i32, + pub avatar: String, + pub params: String, + pub call_count: i64, + pub avg_score: f32, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/agent_mcp_rel.rs b/src/db/models/agent_mcp_rel.rs new file mode 100644 index 0000000..0e7bb80 --- /dev/null +++ b/src/db/models/agent_mcp_rel.rs @@ -0,0 +1,10 @@ +use chrono::{DateTime, Utc}; +pub struct AgentMCPRel { + pub id: i32, + pub agent_id: i32, + pub mcp_tool_id: i32, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/ai_provider.rs b/src/db/models/ai_provider.rs new file mode 100644 index 0000000..52350d9 --- /dev/null +++ b/src/db/models/ai_provider.rs @@ -0,0 +1,13 @@ +use chrono::{DateTime, Utc}; +pub struct AiProvider { + pub id: i32, + pub name: String, + pub avatar: String, + pub api: String, + pub key: String, + pub timeout: i32, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/chat_message.rs b/src/db/models/chat_message.rs new file mode 100644 index 0000000..0ab706e --- /dev/null +++ b/src/db/models/chat_message.rs @@ -0,0 +1,17 @@ +use chrono::{DateTime, Utc}; +use crate::db::r#enum::PromptRole; +pub struct ChatMessage { + pub id: i32, + pub chat_uuid: String, + pub round_uuid: String, + pub role: PromptRole, + pub content: String, + pub input_tokens: i32, + pub output_tokens: i32, + pub duration: i32, + pub model_config: String, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/chat_session.rs b/src/db/models/chat_session.rs new file mode 100644 index 0000000..8e5591e --- /dev/null +++ b/src/db/models/chat_session.rs @@ -0,0 +1,11 @@ +use chrono::{DateTime, Utc}; +pub struct ChatSession { + pub id: i32, + pub chat_uuid: String, + pub title: String, + pub llm_id: i32, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/config.rs b/src/db/models/config.rs index 766d622..ee468bd 100644 --- a/src/db/models/config.rs +++ b/src/db/models/config.rs @@ -1,3 +1,4 @@ +use chrono::{DateTime, Utc}; pub struct Config { pub key: String, pub value: String, @@ -5,4 +6,7 @@ pub struct Config { pub type_: String, pub tag: String, pub sort: i32, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, } diff --git a/src/db/models/llm_model.rs b/src/db/models/llm_model.rs new file mode 100644 index 0000000..07b659c --- /dev/null +++ b/src/db/models/llm_model.rs @@ -0,0 +1,17 @@ +use chrono::{DateTime, Utc}; +pub struct LLMModel { + pub id: i32, + pub provider_id: i32, + pub name: String, + pub avatar: String, + pub model_code: String, + pub max_tokens: i32, + pub max_response_tokens: i32, + pub temperature: f32, + pub weight: i32, + pub call_count: i64, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/mcp_provider.rs b/src/db/models/mcp_provider.rs new file mode 100644 index 0000000..0d9ba95 --- /dev/null +++ b/src/db/models/mcp_provider.rs @@ -0,0 +1,13 @@ +use chrono::{DateTime, Utc}; +pub struct MCPProvider { + pub id: i32, + pub name: String, + pub url: String, + pub auth_key: String, + pub timeout: i32, + pub health_api: String, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/mcp_tool.rs b/src/db/models/mcp_tool.rs new file mode 100644 index 0000000..726d7ac --- /dev/null +++ b/src/db/models/mcp_tool.rs @@ -0,0 +1,15 @@ +use chrono::{DateTime, Utc}; +pub struct MCPTool { + pub id: i32, + pub provider_id: i32, + pub name: String, + pub tool_code: String, + pub description: String, + pub tag: String, + pub parameters: String, + pub response_format: String, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/memory_info.rs b/src/db/models/memory_info.rs new file mode 100644 index 0000000..35db859 --- /dev/null +++ b/src/db/models/memory_info.rs @@ -0,0 +1,14 @@ +use chrono::{DateTime, Utc}; +pub struct MemoryInfo { + pub id: i32, + pub memory_uuid: String, + pub name: String, + pub memory_type: i8, + pub is_vector: i8, + pub vector_id: String, + pub keywords: String, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/mod.rs b/src/db/models/mod.rs index 77e0b7f..f7e25cf 100644 --- a/src/db/models/mod.rs +++ b/src/db/models/mod.rs @@ -1 +1,16 @@ -mod config; \ No newline at end of file +mod config; +mod ai_provider; +mod llm_model; +mod agent_info; +mod prompt_info; +mod prompt_placeholder; +mod agent_arena; +mod chat_session; +mod chat_message; +mod memory_info; +mod mcp_provider; +mod mcp_tool; +mod agent_mcp_rel; +mod project_info; +mod system_api_log; +mod system_config; \ No newline at end of file diff --git a/src/db/models/project_info.rs b/src/db/models/project_info.rs new file mode 100644 index 0000000..32ee0f5 --- /dev/null +++ b/src/db/models/project_info.rs @@ -0,0 +1,10 @@ +use chrono::{DateTime, Utc}; +pub struct ProjectInfo { + pub id: i32, + pub name: String, + pub path: String, + pub is_deleted: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/prompt_info.rs b/src/db/models/prompt_info.rs new file mode 100644 index 0000000..06ad221 --- /dev/null +++ b/src/db/models/prompt_info.rs @@ -0,0 +1,15 @@ +use chrono::{DateTime, Utc}; +use crate::db::r#enum::PromptRole; +pub struct PromptInfo { + pub id: i32, + pub name: String, + pub content: String, + pub category: String, + pub role: PromptRole, + pub version: String, + pub version_desc: String, + pub tag: String, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/prompt_placeholder.rs b/src/db/models/prompt_placeholder.rs new file mode 100644 index 0000000..ca66fdd --- /dev/null +++ b/src/db/models/prompt_placeholder.rs @@ -0,0 +1,15 @@ +use chrono::{DateTime, Utc}; +pub struct PromptPlaceholder { + pub id: i32, + pub prompt_id: i32, + pub key: String, + pub label: String, + pub value: String, + pub default: String, + pub input_type: String, + pub required: i8, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/system_api_log.rs b/src/db/models/system_api_log.rs new file mode 100644 index 0000000..3da1978 --- /dev/null +++ b/src/db/models/system_api_log.rs @@ -0,0 +1,12 @@ +use chrono::{DateTime, Utc}; +pub struct SystemAPILog { + pub id: i32, + pub rel_uuid: String, + pub token_cost: i32, + pub duration: i32, + pub content: String, + pub status: i8, // 0: success, 1: failed + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/db/models/system_config.rs b/src/db/models/system_config.rs new file mode 100644 index 0000000..191911e --- /dev/null +++ b/src/db/models/system_config.rs @@ -0,0 +1,13 @@ +use chrono::{DateTime, Utc}; +pub struct SystemConfig { + pub key: i32, + pub value: String, + pub key_type: String, + pub description: String, + pub tag: String, + pub sort: i32, + pub status: i8, + pub created_at: DateTime, + pub updated_at: DateTime, + pub remark: String, +} \ No newline at end of file diff --git a/src/logger/mod.rs b/src/logger/mod.rs deleted file mode 100644 index ad1b5e3..0000000 --- a/src/logger/mod.rs +++ /dev/null @@ -1,36 +0,0 @@ -use flexi_logger::{ - Cleanup, Criterion, Duplicate, FileSpec, Logger, LogSpecification, Naming, WriteMode, -}; -use log::LevelFilter; - -/// 初始化全局日志 -/// 同时输出到:控制台(彩色) + 文件(滚动) -pub fn init_logger() -> Result<(), Box> { - let log_spec = LogSpecification::builder() - .default(LevelFilter::Debug) - .build(); - - // 2. 文件配置:每天一个文件,保留 7 天 - let file_spec = FileSpec::default() - .directory("logs") - .basename("omega") - .suppress_timestamp() - .append_suffix(false); - - // 3. 启动日志器 - Logger::from(log_spec) - .write_mode(WriteMode::Async) - .duplicate_to_stdout(Duplicate::Info) - .log_to_file(file_spec) - .rotate( - Criterion::Age(chrono::Days(1)), - Naming::Timestamps, - Cleanup::KeepLogFiles(7), - ) - .color(flexi_logger::ColorOpt::Auto) - .format(flexi_logger::detailed_format) - .start()?; - - log::info!("日志模块初始化成功"); - Ok(()) -} \ No newline at end of file