Skip to content

Commit e2fbe70

Browse files
committed
feat(db): 新增数据库相关结构体和枚举类型
1 parent 104f214 commit e2fbe70

19 files changed

Lines changed: 232 additions & 2 deletions

src/db/enum/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pub enum PromptRole {
2+
User,
3+
Assistant,
4+
System,
5+
Tool,
6+
}

src/db/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mod models;
2-
mod store;
2+
mod store;
3+
mod r#enum;

src/db/models/agent_arena.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use chrono::{DateTime, Utc};
2+
pub struct AgentArena {
3+
pub id: i32,
4+
pub chat_uuid: String,
5+
pub round_uuid: String,
6+
pub agent_id: i32,
7+
pub vote_type: i8,
8+
pub comment: String,
9+
pub status: i8,
10+
pub created_at: DateTime<Utc>,
11+
pub updated_at: DateTime<Utc>,
12+
pub remark: String,
13+
}

src/db/models/agent_info.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use chrono::{DateTime, Utc};
2+
pub struct AgentInfo {
3+
pub id: i32,
4+
pub llm_id: i32,
5+
pub name: String,
6+
pub description: String,
7+
pub prompt_id: i32,
8+
pub avatar: String,
9+
pub params: String,
10+
pub call_count: i64,
11+
pub avg_score: f32,
12+
pub status: i8,
13+
pub created_at: DateTime<Utc>,
14+
pub updated_at: DateTime<Utc>,
15+
pub remark: String,
16+
}

src/db/models/agent_mcp_rel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use chrono::{DateTime, Utc};
2+
pub struct AgentMCPRel {
3+
pub id: i32,
4+
pub agent_id: i32,
5+
pub mcp_tool_id: i32,
6+
pub status: i8,
7+
pub created_at: DateTime<Utc>,
8+
pub updated_at: DateTime<Utc>,
9+
pub remark: String,
10+
}

src/db/models/ai_provider.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use chrono::{DateTime, Utc};
2+
pub struct AiProvider {
3+
pub id: i32,
4+
pub name: String,
5+
pub avatar: String,
6+
pub api: String,
7+
pub key: String,
8+
pub timeout: i32,
9+
pub status: i8,
10+
pub created_at: DateTime<Utc>,
11+
pub updated_at: DateTime<Utc>,
12+
pub remark: String,
13+
}

src/db/models/chat_message.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use chrono::{DateTime, Utc};
2+
use crate::db::r#enum::PromptRole;
3+
pub struct ChatMessage {
4+
pub id: i32,
5+
pub chat_uuid: String,
6+
pub round_uuid: String,
7+
pub role: PromptRole,
8+
pub content: String,
9+
pub input_tokens: i32,
10+
pub output_tokens: i32,
11+
pub duration: i32,
12+
pub model_config: String,
13+
pub status: i8,
14+
pub created_at: DateTime<Utc>,
15+
pub updated_at: DateTime<Utc>,
16+
pub remark: String,
17+
}

src/db/models/chat_session.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use chrono::{DateTime, Utc};
2+
pub struct ChatSession {
3+
pub id: i32,
4+
pub chat_uuid: String,
5+
pub title: String,
6+
pub llm_id: i32,
7+
pub status: i8,
8+
pub created_at: DateTime<Utc>,
9+
pub updated_at: DateTime<Utc>,
10+
pub remark: String,
11+
}

src/db/models/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
use chrono::{DateTime, Utc};
12
pub struct Config {
23
pub key: String,
34
pub value: String,
45
pub description: String,
56
pub type_: String,
67
pub tag: String,
78
pub sort: i32,
9+
pub created_at: DateTime<Utc>,
10+
pub updated_at: DateTime<Utc>,
11+
pub remark: String,
812
}

src/db/models/llm_model.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use chrono::{DateTime, Utc};
2+
pub struct LLMModel {
3+
pub id: i32,
4+
pub provider_id: i32,
5+
pub name: String,
6+
pub avatar: String,
7+
pub model_code: String,
8+
pub max_tokens: i32,
9+
pub max_response_tokens: i32,
10+
pub temperature: f32,
11+
pub weight: i32,
12+
pub call_count: i64,
13+
pub status: i8,
14+
pub created_at: DateTime<Utc>,
15+
pub updated_at: DateTime<Utc>,
16+
pub remark: String,
17+
}

0 commit comments

Comments
 (0)