syntax = "proto3"; package topfans.ai_chat; option go_package = "github.com/topfans/backend/pkg/proto/ai_chat;ai_chat"; import "google/api/annotations.proto"; // ==================== 对话消息 ==================== message Message { string role = 1; // "user" / "assistant" string content = 2; } // ==================== 对话相关 ==================== message InitSessionRequest { string session_id = 1; int64 user_id = 2; } message InitSessionResponse { string welcome_message = 1; string session_id = 2; } message ChatMessageRequest { string session_id = 1; string message = 2; string persona_id = 3; // 可选,空则用默认人设 int64 user_id = 4; } message ChatMessageResponse { string content = 1; string session_id = 2; bool is_end = 3; string error = 4; } message ChatHistoryRequest { string session_id = 1; int32 limit = 2; // 默认 20 } message ChatHistoryResponse { repeated Message history = 1; } // ==================== 人设管理 ==================== message GetPersonasRequest { int64 user_id = 1; } message PersonaListResponse { repeated PersonaInfo personas = 1; } message PersonaInfo { string id = 1; string name = 2; string description = 3; string avatar_url = 4; string talk_style = 5; bool is_default = 6; int64 created_at = 7; int64 updated_at = 8; } // ==================== AI Chat Service ==================== service AIChatService { // 初始化会话,获取欢迎消息 rpc InitSession(InitSessionRequest) returns (InitSessionResponse); // 发送消息,流式返回 rpc SendMessage(ChatMessageRequest) returns (stream ChatMessageResponse); // 获取对话历史 rpc GetHistory(ChatHistoryRequest) returns (ChatHistoryResponse) { option (google.api.http) = { get: "/api/v1/ai-chat/history/{session_id}" }; } // 获取用户的所有人设 rpc GetPersonas(GetPersonasRequest) returns (PersonaListResponse) { option (google.api.http) = { get: "/api/v1/ai-chat/personas" }; } }