feat: add AI session management endpoints
- Add CreateSession RPC for creating new AI sessions - Add AskInSession RPC for requests within existing sessions - Add message types: CreateSessionRequest, CreateSessionResponse, AskInSessionRequest, SessionStatusResponse
This commit is contained in:
parent
7d3c064ed8
commit
f0926121d7
352
ai.pb.go
352
ai.pb.go
@ -159,6 +159,282 @@ func (x *AIResponse) GetReasoningContent() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// CreateSessionRequest для создания новой AI сессии
|
||||
type CreateSessionRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // Идентификатор пользователя
|
||||
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")
|
||||
TtlSeconds int64 `protobuf:"varint,4,opt,name=ttl_seconds,json=ttlSeconds,proto3" json:"ttl_seconds,omitempty"` // Время жизни сессии в секундах (по умолчанию 3600 = 1 час)
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateSessionRequest) Reset() {
|
||||
*x = CreateSessionRequest{}
|
||||
mi := &file_ai_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateSessionRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateSessionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateSessionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ai_proto_msgTypes[2]
|
||||
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 CreateSessionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateSessionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ai_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CreateSessionRequest) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateSessionRequest) GetBotUsername() string {
|
||||
if x != nil {
|
||||
return x.BotUsername
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateSessionRequest) GetModelName() string {
|
||||
if x != nil {
|
||||
return x.ModelName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateSessionRequest) GetTtlSeconds() int64 {
|
||||
if x != nil {
|
||||
return x.TtlSeconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// CreateSessionResponse содержит ID созданной сессии
|
||||
type CreateSessionResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // ID сессии
|
||||
Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` // Статус сессии
|
||||
Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` // Текст ошибки, если произошла
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateSessionResponse) Reset() {
|
||||
*x = CreateSessionResponse{}
|
||||
mi := &file_ai_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateSessionResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateSessionResponse) ProtoMessage() {}
|
||||
|
||||
func (x *CreateSessionResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ai_proto_msgTypes[3]
|
||||
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 CreateSessionResponse.ProtoReflect.Descriptor instead.
|
||||
func (*CreateSessionResponse) Descriptor() ([]byte, []int) {
|
||||
return file_ai_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *CreateSessionResponse) GetSessionId() string {
|
||||
if x != nil {
|
||||
return x.SessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateSessionResponse) GetStatus() string {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateSessionResponse) GetError() string {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// AskInSessionRequest для запроса в рамках сессии
|
||||
type AskInSessionRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // ID сессии
|
||||
Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` // Текст запроса
|
||||
EnableReasoning bool `protobuf:"varint,3,opt,name=enable_reasoning,json=enableReasoning,proto3" json:"enable_reasoning,omitempty"` // Включить режим рассуждений (по умолчанию false)
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *AskInSessionRequest) Reset() {
|
||||
*x = AskInSessionRequest{}
|
||||
mi := &file_ai_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *AskInSessionRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AskInSessionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *AskInSessionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ai_proto_msgTypes[4]
|
||||
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 AskInSessionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*AskInSessionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ai_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *AskInSessionRequest) GetSessionId() string {
|
||||
if x != nil {
|
||||
return x.SessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AskInSessionRequest) GetText() string {
|
||||
if x != nil {
|
||||
return x.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AskInSessionRequest) GetEnableReasoning() bool {
|
||||
if x != nil {
|
||||
return x.EnableReasoning
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SessionStatusResponse содержит статус сессии и ответ AI
|
||||
type SessionStatusResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // ID сессии
|
||||
Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` // Статус сессии (active, expired, closed)
|
||||
Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` // Текст ответа от AI
|
||||
Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` // Текст ошибки, если произошла
|
||||
DurationMs float64 `protobuf:"fixed64,5,opt,name=duration_ms,json=durationMs,proto3" json:"duration_ms,omitempty"` // Время выполнения в миллисекундах
|
||||
ReasoningContent string `protobuf:"bytes,6,opt,name=reasoning_content,json=reasoningContent,proto3" json:"reasoning_content,omitempty"` // Текст рассуждений (если включён режим reasoning)
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) Reset() {
|
||||
*x = SessionStatusResponse{}
|
||||
mi := &file_ai_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SessionStatusResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SessionStatusResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ai_proto_msgTypes[5]
|
||||
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 SessionStatusResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SessionStatusResponse) Descriptor() ([]byte, []int) {
|
||||
return file_ai_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) GetSessionId() string {
|
||||
if x != nil {
|
||||
return x.SessionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) GetStatus() string {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) GetContent() string {
|
||||
if x != nil {
|
||||
return x.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) GetError() string {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) GetDurationMs() float64 {
|
||||
if x != nil {
|
||||
return x.DurationMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SessionStatusResponse) GetReasoningContent() string {
|
||||
if x != nil {
|
||||
return x.ReasoningContent
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// HealthCheckRequest для проверки здоровья сервиса
|
||||
type HealthCheckRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -168,7 +444,7 @@ type HealthCheckRequest struct {
|
||||
|
||||
func (x *HealthCheckRequest) Reset() {
|
||||
*x = HealthCheckRequest{}
|
||||
mi := &file_ai_proto_msgTypes[2]
|
||||
mi := &file_ai_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -180,7 +456,7 @@ func (x *HealthCheckRequest) String() string {
|
||||
func (*HealthCheckRequest) ProtoMessage() {}
|
||||
|
||||
func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ai_proto_msgTypes[2]
|
||||
mi := &file_ai_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -193,7 +469,7 @@ func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead.
|
||||
func (*HealthCheckRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ai_proto_rawDescGZIP(), []int{2}
|
||||
return file_ai_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
// HealthCheckResponse для ответа на проверку здоровья
|
||||
@ -207,7 +483,7 @@ type HealthCheckResponse struct {
|
||||
|
||||
func (x *HealthCheckResponse) Reset() {
|
||||
*x = HealthCheckResponse{}
|
||||
mi := &file_ai_proto_msgTypes[3]
|
||||
mi := &file_ai_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -219,7 +495,7 @@ func (x *HealthCheckResponse) String() string {
|
||||
func (*HealthCheckResponse) ProtoMessage() {}
|
||||
|
||||
func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ai_proto_msgTypes[3]
|
||||
mi := &file_ai_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -232,7 +508,7 @@ func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead.
|
||||
func (*HealthCheckResponse) Descriptor() ([]byte, []int) {
|
||||
return file_ai_proto_rawDescGZIP(), []int{3}
|
||||
return file_ai_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *HealthCheckResponse) GetServing() bool {
|
||||
@ -266,14 +542,42 @@ const file_ai_proto_rawDesc = "" +
|
||||
"\x05error\x18\x02 \x01(\tR\x05error\x12\x1f\n" +
|
||||
"\vduration_ms\x18\x03 \x01(\x01R\n" +
|
||||
"durationMs\x12+\n" +
|
||||
"\x11reasoning_content\x18\x04 \x01(\tR\x10reasoningContent\"\x14\n" +
|
||||
"\x11reasoning_content\x18\x04 \x01(\tR\x10reasoningContent\"\x92\x01\n" +
|
||||
"\x14CreateSessionRequest\x12\x17\n" +
|
||||
"\auser_id\x18\x01 \x01(\tR\x06userId\x12!\n" +
|
||||
"\fbot_username\x18\x02 \x01(\tR\vbotUsername\x12\x1d\n" +
|
||||
"\n" +
|
||||
"model_name\x18\x03 \x01(\tR\tmodelName\x12\x1f\n" +
|
||||
"\vttl_seconds\x18\x04 \x01(\x03R\n" +
|
||||
"ttlSeconds\"d\n" +
|
||||
"\x15CreateSessionResponse\x12\x1d\n" +
|
||||
"\n" +
|
||||
"session_id\x18\x01 \x01(\tR\tsessionId\x12\x16\n" +
|
||||
"\x06status\x18\x02 \x01(\tR\x06status\x12\x14\n" +
|
||||
"\x05error\x18\x03 \x01(\tR\x05error\"s\n" +
|
||||
"\x13AskInSessionRequest\x12\x1d\n" +
|
||||
"\n" +
|
||||
"session_id\x18\x01 \x01(\tR\tsessionId\x12\x12\n" +
|
||||
"\x04text\x18\x02 \x01(\tR\x04text\x12)\n" +
|
||||
"\x10enable_reasoning\x18\x03 \x01(\bR\x0fenableReasoning\"\xcc\x01\n" +
|
||||
"\x15SessionStatusResponse\x12\x1d\n" +
|
||||
"\n" +
|
||||
"session_id\x18\x01 \x01(\tR\tsessionId\x12\x16\n" +
|
||||
"\x06status\x18\x02 \x01(\tR\x06status\x12\x18\n" +
|
||||
"\acontent\x18\x03 \x01(\tR\acontent\x12\x14\n" +
|
||||
"\x05error\x18\x04 \x01(\tR\x05error\x12\x1f\n" +
|
||||
"\vduration_ms\x18\x05 \x01(\x01R\n" +
|
||||
"durationMs\x12+\n" +
|
||||
"\x11reasoning_content\x18\x06 \x01(\tR\x10reasoningContent\"\x14\n" +
|
||||
"\x12HealthCheckRequest\"I\n" +
|
||||
"\x13HealthCheckResponse\x12\x18\n" +
|
||||
"\aserving\x18\x01 \x01(\bR\aserving\x12\x18\n" +
|
||||
"\aversion\x18\x02 \x01(\tR\aversion2|\n" +
|
||||
"\aversion\x18\x02 \x01(\tR\aversion2\x86\x02\n" +
|
||||
"\tAIService\x12/\n" +
|
||||
"\x0eGenerateAnswer\x12\r.ai.AIRequest\x1a\x0e.ai.AIResponse\x12>\n" +
|
||||
"\vHealthCheck\x12\x16.ai.HealthCheckRequest\x1a\x17.ai.HealthCheckResponseB,Z*git.be.kaien.ru/l-ai/l-ai-core-proto/protob\x06proto3"
|
||||
"\vHealthCheck\x12\x16.ai.HealthCheckRequest\x1a\x17.ai.HealthCheckResponse\x12D\n" +
|
||||
"\rCreateSession\x12\x18.ai.CreateSessionRequest\x1a\x19.ai.CreateSessionResponse\x12B\n" +
|
||||
"\fAskInSession\x12\x17.ai.AskInSessionRequest\x1a\x19.ai.SessionStatusResponseB,Z*git.be.kaien.ru/l-ai/l-ai-core-proto/protob\x06proto3"
|
||||
|
||||
var (
|
||||
file_ai_proto_rawDescOnce sync.Once
|
||||
@ -287,20 +591,28 @@ func file_ai_proto_rawDescGZIP() []byte {
|
||||
return file_ai_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_ai_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_ai_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_ai_proto_goTypes = []any{
|
||||
(*AIRequest)(nil), // 0: ai.AIRequest
|
||||
(*AIResponse)(nil), // 1: ai.AIResponse
|
||||
(*HealthCheckRequest)(nil), // 2: ai.HealthCheckRequest
|
||||
(*HealthCheckResponse)(nil), // 3: ai.HealthCheckResponse
|
||||
(*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
|
||||
}
|
||||
var file_ai_proto_depIdxs = []int32{
|
||||
0, // 0: ai.AIService.GenerateAnswer:input_type -> ai.AIRequest
|
||||
2, // 1: ai.AIService.HealthCheck:input_type -> ai.HealthCheckRequest
|
||||
1, // 2: ai.AIService.GenerateAnswer:output_type -> ai.AIResponse
|
||||
3, // 3: ai.AIService.HealthCheck:output_type -> ai.HealthCheckResponse
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] is the sub-list for method input_type
|
||||
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
|
||||
@ -317,7 +629,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: 4,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
38
ai.proto
38
ai.proto
@ -20,6 +20,38 @@ message AIResponse {
|
||||
string reasoning_content = 4; // Текст рассуждений (если включён режим reasoning)
|
||||
}
|
||||
|
||||
// CreateSessionRequest для создания новой AI сессии
|
||||
message CreateSessionRequest {
|
||||
string user_id = 1; // Идентификатор пользователя
|
||||
string bot_username = 2; // Username бота для упоминаний
|
||||
string model_name = 3; // Название модели (по умолчанию "venice-uncensored")
|
||||
int64 ttl_seconds = 4; // Время жизни сессии в секундах (по умолчанию 3600 = 1 час)
|
||||
}
|
||||
|
||||
// CreateSessionResponse содержит ID созданной сессии
|
||||
message CreateSessionResponse {
|
||||
string session_id = 1; // ID сессии
|
||||
string status = 2; // Статус сессии
|
||||
string error = 3; // Текст ошибки, если произошла
|
||||
}
|
||||
|
||||
// AskInSessionRequest для запроса в рамках сессии
|
||||
message AskInSessionRequest {
|
||||
string session_id = 1; // ID сессии
|
||||
string text = 2; // Текст запроса
|
||||
bool enable_reasoning = 3; // Включить режим рассуждений (по умолчанию false)
|
||||
}
|
||||
|
||||
// SessionStatusResponse содержит статус сессии и ответ AI
|
||||
message SessionStatusResponse {
|
||||
string session_id = 1; // ID сессии
|
||||
string status = 2; // Статус сессии (active, expired, closed)
|
||||
string content = 3; // Текст ответа от AI
|
||||
string error = 4; // Текст ошибки, если произошла
|
||||
double duration_ms = 5; // Время выполнения в миллисекундах
|
||||
string reasoning_content = 6; // Текст рассуждений (если включён режим reasoning)
|
||||
}
|
||||
|
||||
// HealthCheckRequest для проверки здоровья сервиса
|
||||
message HealthCheckRequest {}
|
||||
|
||||
@ -36,4 +68,10 @@ service AIService {
|
||||
|
||||
// HealthCheck проверяет здоровье сервиса
|
||||
rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
|
||||
|
||||
// CreateSession созда новую AI сессию
|
||||
rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse);
|
||||
|
||||
// AskInSession отправляет запрос в рамках существующей сессии
|
||||
rpc AskInSession(AskInSessionRequest) returns (SessionStatusResponse);
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ const _ = grpc.SupportPackageIsVersion9
|
||||
const (
|
||||
AIService_GenerateAnswer_FullMethodName = "/ai.AIService/GenerateAnswer"
|
||||
AIService_HealthCheck_FullMethodName = "/ai.AIService/HealthCheck"
|
||||
AIService_CreateSession_FullMethodName = "/ai.AIService/CreateSession"
|
||||
AIService_AskInSession_FullMethodName = "/ai.AIService/AskInSession"
|
||||
)
|
||||
|
||||
// AIServiceClient is the client API for AIService service.
|
||||
@ -33,6 +35,10 @@ type AIServiceClient interface {
|
||||
GenerateAnswer(ctx context.Context, in *AIRequest, opts ...grpc.CallOption) (*AIResponse, error)
|
||||
// HealthCheck проверяет здоровье сервиса
|
||||
HealthCheck(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
|
||||
// CreateSession созда новую AI сессию
|
||||
CreateSession(ctx context.Context, in *CreateSessionRequest, opts ...grpc.CallOption) (*CreateSessionResponse, error)
|
||||
// AskInSession отправляет запрос в рамках существующей сессии
|
||||
AskInSession(ctx context.Context, in *AskInSessionRequest, opts ...grpc.CallOption) (*SessionStatusResponse, error)
|
||||
}
|
||||
|
||||
type aIServiceClient struct {
|
||||
@ -63,6 +69,26 @@ func (c *aIServiceClient) HealthCheck(ctx context.Context, in *HealthCheckReques
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *aIServiceClient) CreateSession(ctx context.Context, in *CreateSessionRequest, opts ...grpc.CallOption) (*CreateSessionResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CreateSessionResponse)
|
||||
err := c.cc.Invoke(ctx, AIService_CreateSession_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *aIServiceClient) AskInSession(ctx context.Context, in *AskInSessionRequest, opts ...grpc.CallOption) (*SessionStatusResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SessionStatusResponse)
|
||||
err := c.cc.Invoke(ctx, AIService_AskInSession_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AIServiceServer is the server API for AIService service.
|
||||
// All implementations must embed UnimplementedAIServiceServer
|
||||
// for forward compatibility.
|
||||
@ -73,6 +99,10 @@ type AIServiceServer interface {
|
||||
GenerateAnswer(context.Context, *AIRequest) (*AIResponse, error)
|
||||
// HealthCheck проверяет здоровье сервиса
|
||||
HealthCheck(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
|
||||
// CreateSession созда новую AI сессию
|
||||
CreateSession(context.Context, *CreateSessionRequest) (*CreateSessionResponse, error)
|
||||
// AskInSession отправляет запрос в рамках существующей сессии
|
||||
AskInSession(context.Context, *AskInSessionRequest) (*SessionStatusResponse, error)
|
||||
mustEmbedUnimplementedAIServiceServer()
|
||||
}
|
||||
|
||||
@ -89,6 +119,12 @@ func (UnimplementedAIServiceServer) GenerateAnswer(context.Context, *AIRequest)
|
||||
func (UnimplementedAIServiceServer) HealthCheck(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method HealthCheck not implemented")
|
||||
}
|
||||
func (UnimplementedAIServiceServer) CreateSession(context.Context, *CreateSessionRequest) (*CreateSessionResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateSession not implemented")
|
||||
}
|
||||
func (UnimplementedAIServiceServer) AskInSession(context.Context, *AskInSessionRequest) (*SessionStatusResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method AskInSession not implemented")
|
||||
}
|
||||
func (UnimplementedAIServiceServer) mustEmbedUnimplementedAIServiceServer() {}
|
||||
func (UnimplementedAIServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@ -146,6 +182,42 @@ func _AIService_HealthCheck_Handler(srv interface{}, ctx context.Context, dec fu
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AIService_CreateSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateSessionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AIServiceServer).CreateSession(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AIService_CreateSession_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AIServiceServer).CreateSession(ctx, req.(*CreateSessionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AIService_AskInSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AskInSessionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AIServiceServer).AskInSession(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AIService_AskInSession_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AIServiceServer).AskInSession(ctx, req.(*AskInSessionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AIService_ServiceDesc is the grpc.ServiceDesc for AIService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@ -161,6 +233,14 @@ var AIService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "HealthCheck",
|
||||
Handler: _AIService_HealthCheck_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateSession",
|
||||
Handler: _AIService_CreateSession_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AskInSession",
|
||||
Handler: _AIService_AskInSession_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "ai.proto",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user