feat: add global_user_id and AnswerGenerationOptions to AIRequest

- Add global_user_id field to identify user for profile/memories lookup
- Add AnswerGenerationOptions with include_user_memories bool
- Include memories in prompt when option is enabled
This commit is contained in:
Kaien 2026-04-15 23:20:11 +03:00
parent f0926121d7
commit d9b7efeca0
2 changed files with 125 additions and 51 deletions

157
ai.pb.go
View File

@ -28,6 +28,8 @@ type AIRequest struct {
BotUsername string `protobuf:"bytes,2,opt,name=bot_username,json=botUsername,proto3" json:"bot_username,omitempty"` // Username бота для упоминаний
ModelName string `protobuf:"bytes,3,opt,name=model_name,json=modelName,proto3" json:"model_name,omitempty"` // Название модели (по умолчанию "venice-uncensored")
EnableReasoning bool `protobuf:"varint,4,opt,name=enable_reasoning,json=enableReasoning,proto3" json:"enable_reasoning,omitempty"` // Включить режим рассуждений (по умолчанию false)
GlobalUserId int64 `protobuf:"varint,5,opt,name=global_user_id,json=globalUserId,proto3" json:"global_user_id,omitempty"` // Global user ID для получения доп. данных (профиль, воспоминания)
Options *AnswerGenerationOptions `protobuf:"bytes,6,opt,name=options,proto3" json:"options,omitempty"` // Дополнительные опции генерации ответа
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -90,6 +92,65 @@ func (x *AIRequest) GetEnableReasoning() bool {
return false
}
func (x *AIRequest) GetGlobalUserId() int64 {
if x != nil {
return x.GlobalUserId
}
return 0
}
func (x *AIRequest) GetOptions() *AnswerGenerationOptions {
if x != nil {
return x.Options
}
return nil
}
// AnswerGenerationOptions содержит дополнительные опции для генерации ответа
type AnswerGenerationOptions struct {
state protoimpl.MessageState `protogen:"open.v1"`
IncludeUserMemories bool `protobuf:"varint,1,opt,name=include_user_memories,json=includeUserMemories,proto3" json:"include_user_memories,omitempty"` // Включить воспоминания о пользователе в промпт
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AnswerGenerationOptions) Reset() {
*x = AnswerGenerationOptions{}
mi := &file_ai_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AnswerGenerationOptions) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AnswerGenerationOptions) ProtoMessage() {}
func (x *AnswerGenerationOptions) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AnswerGenerationOptions.ProtoReflect.Descriptor instead.
func (*AnswerGenerationOptions) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{1}
}
func (x *AnswerGenerationOptions) GetIncludeUserMemories() bool {
if x != nil {
return x.IncludeUserMemories
}
return false
}
// AIResponse содержит ответ от AI модели
type AIResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
@ -103,7 +164,7 @@ type AIResponse struct {
func (x *AIResponse) Reset() {
*x = AIResponse{}
mi := &file_ai_proto_msgTypes[1]
mi := &file_ai_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -115,7 +176,7 @@ func (x *AIResponse) String() string {
func (*AIResponse) ProtoMessage() {}
func (x *AIResponse) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[1]
mi := &file_ai_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -128,7 +189,7 @@ func (x *AIResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use AIResponse.ProtoReflect.Descriptor instead.
func (*AIResponse) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{1}
return file_ai_proto_rawDescGZIP(), []int{2}
}
func (x *AIResponse) GetContent() string {
@ -172,7 +233,7 @@ type CreateSessionRequest struct {
func (x *CreateSessionRequest) Reset() {
*x = CreateSessionRequest{}
mi := &file_ai_proto_msgTypes[2]
mi := &file_ai_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -184,7 +245,7 @@ func (x *CreateSessionRequest) String() string {
func (*CreateSessionRequest) ProtoMessage() {}
func (x *CreateSessionRequest) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[2]
mi := &file_ai_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -197,7 +258,7 @@ func (x *CreateSessionRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateSessionRequest.ProtoReflect.Descriptor instead.
func (*CreateSessionRequest) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{2}
return file_ai_proto_rawDescGZIP(), []int{3}
}
func (x *CreateSessionRequest) GetUserId() string {
@ -240,7 +301,7 @@ type CreateSessionResponse struct {
func (x *CreateSessionResponse) Reset() {
*x = CreateSessionResponse{}
mi := &file_ai_proto_msgTypes[3]
mi := &file_ai_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -252,7 +313,7 @@ func (x *CreateSessionResponse) String() string {
func (*CreateSessionResponse) ProtoMessage() {}
func (x *CreateSessionResponse) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[3]
mi := &file_ai_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -265,7 +326,7 @@ func (x *CreateSessionResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateSessionResponse.ProtoReflect.Descriptor instead.
func (*CreateSessionResponse) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{3}
return file_ai_proto_rawDescGZIP(), []int{4}
}
func (x *CreateSessionResponse) GetSessionId() string {
@ -301,7 +362,7 @@ type AskInSessionRequest struct {
func (x *AskInSessionRequest) Reset() {
*x = AskInSessionRequest{}
mi := &file_ai_proto_msgTypes[4]
mi := &file_ai_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -313,7 +374,7 @@ func (x *AskInSessionRequest) String() string {
func (*AskInSessionRequest) ProtoMessage() {}
func (x *AskInSessionRequest) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[4]
mi := &file_ai_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -326,7 +387,7 @@ func (x *AskInSessionRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use AskInSessionRequest.ProtoReflect.Descriptor instead.
func (*AskInSessionRequest) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{4}
return file_ai_proto_rawDescGZIP(), []int{5}
}
func (x *AskInSessionRequest) GetSessionId() string {
@ -365,7 +426,7 @@ type SessionStatusResponse struct {
func (x *SessionStatusResponse) Reset() {
*x = SessionStatusResponse{}
mi := &file_ai_proto_msgTypes[5]
mi := &file_ai_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -377,7 +438,7 @@ func (x *SessionStatusResponse) String() string {
func (*SessionStatusResponse) ProtoMessage() {}
func (x *SessionStatusResponse) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[5]
mi := &file_ai_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -390,7 +451,7 @@ func (x *SessionStatusResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SessionStatusResponse.ProtoReflect.Descriptor instead.
func (*SessionStatusResponse) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{5}
return file_ai_proto_rawDescGZIP(), []int{6}
}
func (x *SessionStatusResponse) GetSessionId() string {
@ -444,7 +505,7 @@ type HealthCheckRequest struct {
func (x *HealthCheckRequest) Reset() {
*x = HealthCheckRequest{}
mi := &file_ai_proto_msgTypes[6]
mi := &file_ai_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -456,7 +517,7 @@ func (x *HealthCheckRequest) String() string {
func (*HealthCheckRequest) ProtoMessage() {}
func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[6]
mi := &file_ai_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -469,7 +530,7 @@ func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead.
func (*HealthCheckRequest) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{6}
return file_ai_proto_rawDescGZIP(), []int{7}
}
// HealthCheckResponse для ответа на проверку здоровья
@ -483,7 +544,7 @@ type HealthCheckResponse struct {
func (x *HealthCheckResponse) Reset() {
*x = HealthCheckResponse{}
mi := &file_ai_proto_msgTypes[7]
mi := &file_ai_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -495,7 +556,7 @@ func (x *HealthCheckResponse) String() string {
func (*HealthCheckResponse) ProtoMessage() {}
func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {
mi := &file_ai_proto_msgTypes[7]
mi := &file_ai_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -508,7 +569,7 @@ func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead.
func (*HealthCheckResponse) Descriptor() ([]byte, []int) {
return file_ai_proto_rawDescGZIP(), []int{7}
return file_ai_proto_rawDescGZIP(), []int{8}
}
func (x *HealthCheckResponse) GetServing() bool {
@ -529,13 +590,17 @@ var File_ai_proto protoreflect.FileDescriptor
const file_ai_proto_rawDesc = "" +
"\n" +
"\bai.proto\x12\x02ai\"\x8c\x01\n" +
"\bai.proto\x12\x02ai\"\xe9\x01\n" +
"\tAIRequest\x12\x12\n" +
"\x04text\x18\x01 \x01(\tR\x04text\x12!\n" +
"\fbot_username\x18\x02 \x01(\tR\vbotUsername\x12\x1d\n" +
"\n" +
"model_name\x18\x03 \x01(\tR\tmodelName\x12)\n" +
"\x10enable_reasoning\x18\x04 \x01(\bR\x0fenableReasoning\"\x8a\x01\n" +
"\x10enable_reasoning\x18\x04 \x01(\bR\x0fenableReasoning\x12$\n" +
"\x0eglobal_user_id\x18\x05 \x01(\x03R\fglobalUserId\x125\n" +
"\aoptions\x18\x06 \x01(\v2\x1b.ai.AnswerGenerationOptionsR\aoptions\"M\n" +
"\x17AnswerGenerationOptions\x122\n" +
"\x15include_user_memories\x18\x01 \x01(\bR\x13includeUserMemories\"\x8a\x01\n" +
"\n" +
"AIResponse\x12\x18\n" +
"\acontent\x18\x01 \x01(\tR\acontent\x12\x14\n" +
@ -591,31 +656,33 @@ func file_ai_proto_rawDescGZIP() []byte {
return file_ai_proto_rawDescData
}
var file_ai_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_ai_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_ai_proto_goTypes = []any{
(*AIRequest)(nil), // 0: ai.AIRequest
(*AIResponse)(nil), // 1: ai.AIResponse
(*CreateSessionRequest)(nil), // 2: ai.CreateSessionRequest
(*CreateSessionResponse)(nil), // 3: ai.CreateSessionResponse
(*AskInSessionRequest)(nil), // 4: ai.AskInSessionRequest
(*SessionStatusResponse)(nil), // 5: ai.SessionStatusResponse
(*HealthCheckRequest)(nil), // 6: ai.HealthCheckRequest
(*HealthCheckResponse)(nil), // 7: ai.HealthCheckResponse
(*AnswerGenerationOptions)(nil), // 1: ai.AnswerGenerationOptions
(*AIResponse)(nil), // 2: ai.AIResponse
(*CreateSessionRequest)(nil), // 3: ai.CreateSessionRequest
(*CreateSessionResponse)(nil), // 4: ai.CreateSessionResponse
(*AskInSessionRequest)(nil), // 5: ai.AskInSessionRequest
(*SessionStatusResponse)(nil), // 6: ai.SessionStatusResponse
(*HealthCheckRequest)(nil), // 7: ai.HealthCheckRequest
(*HealthCheckResponse)(nil), // 8: ai.HealthCheckResponse
}
var file_ai_proto_depIdxs = []int32{
0, // 0: ai.AIService.GenerateAnswer:input_type -> ai.AIRequest
6, // 1: ai.AIService.HealthCheck:input_type -> ai.HealthCheckRequest
2, // 2: ai.AIService.CreateSession:input_type -> ai.CreateSessionRequest
4, // 3: ai.AIService.AskInSession:input_type -> ai.AskInSessionRequest
1, // 4: ai.AIService.GenerateAnswer:output_type -> ai.AIResponse
7, // 5: ai.AIService.HealthCheck:output_type -> ai.HealthCheckResponse
3, // 6: ai.AIService.CreateSession:output_type -> ai.CreateSessionResponse
5, // 7: ai.AIService.AskInSession:output_type -> ai.SessionStatusResponse
4, // [4:8] is the sub-list for method output_type
0, // [0:4] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
1, // 0: ai.AIRequest.options:type_name -> ai.AnswerGenerationOptions
0, // 1: ai.AIService.GenerateAnswer:input_type -> ai.AIRequest
7, // 2: ai.AIService.HealthCheck:input_type -> ai.HealthCheckRequest
3, // 3: ai.AIService.CreateSession:input_type -> ai.CreateSessionRequest
5, // 4: ai.AIService.AskInSession:input_type -> ai.AskInSessionRequest
2, // 5: ai.AIService.GenerateAnswer:output_type -> ai.AIResponse
8, // 6: ai.AIService.HealthCheck:output_type -> ai.HealthCheckResponse
4, // 7: ai.AIService.CreateSession:output_type -> ai.CreateSessionResponse
6, // 8: ai.AIService.AskInSession:output_type -> ai.SessionStatusResponse
5, // [5:9] is the sub-list for method output_type
1, // [1:5] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_ai_proto_init() }
@ -629,7 +696,7 @@ func file_ai_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_ai_proto_rawDesc), len(file_ai_proto_rawDesc)),
NumEnums: 0,
NumMessages: 8,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -10,6 +10,13 @@ message AIRequest {
string bot_username = 2; // Username бота для упоминаний
string model_name = 3; // Название модели (по умолчанию "venice-uncensored")
bool enable_reasoning = 4; // Включить режим рассуждений (по умолчанию false)
int64 global_user_id = 5; // Global user ID для получения доп. данных (профиль, воспоминания)
AnswerGenerationOptions options = 6; // Дополнительные опции генерации ответа
}
// AnswerGenerationOptions содержит дополнительные опции для генерации ответа
message AnswerGenerationOptions {
bool include_user_memories = 1; // Включить воспоминания о пользователе в промпт
}
// AIResponse содержит ответ от AI модели