feat(server): deliver major backend expansion with v2 APIs, AI integration, and realtime infrastructure (#36)

This commit is contained in:
小袁
2026-04-29 18:49:54 +08:00
committed by GitHub
parent f0fa33cd67
commit d7ae8564c1
148 changed files with 5903 additions and 770 deletions
+118
View File
@@ -0,0 +1,118 @@
/*
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
SPDX-License-Identifier: MIT
*/
package xiaozhi
import "time"
type XiaoZhiResponse[T any] struct {
Success bool `json:"success"`
Data *T `json:"data"`
Message string `json:"message"`
Pagination Pagination `json:"pagination"`
Token string `json:"token"`
Code string `json:"code"`
}
type Pagination struct {
Total int `json:"total"`
Current int `json:"current"`
PageSize int `json:"pageSize"`
HasMore bool `json:"hasMore"`
Page int `json:"page"`
Limit int `json:"limit"`
TotaPages int `json:"totaPages"`
}
type ListData[T any] struct {
List []T `json:"list"`
Pagination Pagination `json:"pagination"`
}
type AgentTemplate struct {
Id int `json:"id"`
DeveloperId int `json:"developer_id"`
AgentName string `json:"agent_name"`
TtsVoices []string `json:"tts_voices"`
DefaultTtsVoice string `json:"default_tts_voice"`
LlmModel string `json:"llm_model"`
AssistantName string `json:"assistant_name"`
UserName string `json:"user_name"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Character string `json:"character"`
TtsSpeechSpeed string `json:"tts_speech_speed"`
AsrSpeed string `json:"asr_speed"`
TtsPitch int `json:"tts_pitch"`
KnowledgeBaseIds []int `json:"knowledge_base_ids"`
XiaoZhiVersion string `json:"xiao_zhi_version"`
TtsVoiceName string `json:"tts_voice_name"`
}
type AgentConfig struct {
AgentName string `json:"agent_name"`
AssistantName string `json:"assistant_name"`
LlmModel string `json:"llm_model"`
TtsVoice string `json:"tts_voice"`
TtsSpeechSpeed string `json:"tts_speech_speed"`
TtsPitch int `json:"tts_pitch"`
AsrSpeed string `json:"asr_speed"`
Language string `json:"language"`
Character string `json:"character"`
Memory string `json:"memory"`
MemoryType string `json:"memory_type"`
KnowledgeBaseIds []int `json:"knowledge_base_ids"`
McpEndpoints []string `json:"mcp_endpoints"`
ProductMcpEndpoints []string `json:"product_mcp_endpoints"`
}
type CreateAgentResponse struct {
Id int `json:"id"`
}
// Agent class
type Agent struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
AgentName string `json:"agent_name"`
TtsVoice string `json:"tts_voice"`
LlmModel string `json:"llm_model"`
AssistantName string `json:"assistant_name"`
UserName string `json:"user_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Memory string `json:"memory"`
Character string `json:"character"`
LongMemorySwitch int `json:"long_memory_switch"`
LangCode string `json:"lang_code"`
Language string `json:"language"`
TtsSpeechSpeed string `json:"tts_speech_speed"`
AsrSpeed string `json:"asr_speed"`
TtsPitch int `json:"tts_pitch"`
AgentTemplateID int64 `json:"agent_template_id"`
MemoryUpdatedAt time.Time `json:"memory_updated_at"`
ShareAgentID *int64 `json:"share_agent_id"`
Source string `json:"source"`
McpEndpoints []string `json:"mcp_endpoints"`
MemoryType string `json:"memory_type"`
KnowledgeBaseIDs []int64 `json:"knowledge_base_ids"`
MaxMessageCount *int64 `json:"max_message_count"`
ProductMcpEndpoints []string `json:"product_mcp_endpoints"`
DeviceCount int `json:"deviceCount"`
LastDevice LastDevice `json:"lastDevice"`
}
// LastDevice nested device struct
type LastDevice struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
MacAddress string `json:"mac_address"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastConnectedAt time.Time `json:"last_connected_at"`
AutoUpdate int `json:"auto_update"`
Alias *string `json:"alias"`
AgentID int64 `json:"agent_id"`
}
@@ -0,0 +1,24 @@
/*
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
SPDX-License-Identifier: MIT
*/
package xiaozhi
type Conversation struct {
Id int `json:"id"`
UserId int `json:"user_id"`
CreatedAt string `json:"created_at"`
DeviceId int `json:"device_id"`
MsgCount int `json:"msg_count"`
AgentId int `json:"agent_id"`
Model string `json:"model"`
TokenCount int `json:"token_count"`
Duration int `json:"duration"`
ChatSummary ChatSummary `json:"chat_summary"`
}
type ChatSummary struct {
Title string `json:"title"`
Summary string `json:"summary"`
}
+24
View File
@@ -0,0 +1,24 @@
/*
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
SPDX-License-Identifier: MIT
*/
package xiaozhi
type Device struct {
DeviceID int `json:"device_id"`
AgentID int `json:"agent_id"`
ID int `json:"id"`
ProductID int `json:"product_id"`
Seed string `json:"seed"`
SerialNumber string `json:"serial_number"`
ActivateAt string `json:"activate_at"`
ProductName string `json:"product_name"`
MacAddress string `json:"mac_address"`
AppVersion string `json:"app_version"`
BoardName string `json:"board_name"`
ClientId string `json:"client_id"`
IccID string `json:"iccid"`
Imei string `json:"imei"`
Online bool `json:"online"`
}