topfans/backend/pkg/proto/ai_chat/ai_chat.triple.go
2026-05-28 12:00:19 +08:00

259 lines
9.3 KiB
Go

// Code generated by protoc-gen-triple. DO NOT EDIT.
//
// Source: ai_chat.proto
package ai_chat
import (
"context"
"net/http"
)
import (
"dubbo.apache.org/dubbo-go/v3"
"dubbo.apache.org/dubbo-go/v3/client"
"dubbo.apache.org/dubbo-go/v3/common"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
"dubbo.apache.org/dubbo-go/v3/server"
)
// This is a compile-time assertion to ensure that this generated file and the Triple package
// are compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of Triple newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of Triple or updating the Triple
// version compiled into your binary.
const _ = triple_protocol.IsAtLeastVersion0_1_0
const (
// AIChatServiceName is the fully-qualified name of the AIChatService service.
AIChatServiceName = "topfans.ai_chat.AIChatService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// AIChatServiceInitSessionProcedure is the fully-qualified name of the AIChatService's InitSession RPC.
AIChatServiceInitSessionProcedure = "/topfans.ai_chat.AIChatService/InitSession"
// AIChatServiceSendMessageProcedure is the fully-qualified name of the AIChatService's SendMessage RPC.
AIChatServiceSendMessageProcedure = "/topfans.ai_chat.AIChatService/SendMessage"
// AIChatServiceGetHistoryProcedure is the fully-qualified name of the AIChatService's GetHistory RPC.
AIChatServiceGetHistoryProcedure = "/topfans.ai_chat.AIChatService/GetHistory"
// AIChatServiceGetPersonasProcedure is the fully-qualified name of the AIChatService's GetPersonas RPC.
AIChatServiceGetPersonasProcedure = "/topfans.ai_chat.AIChatService/GetPersonas"
)
var (
_ AIChatService = (*AIChatServiceImpl)(nil)
_ AIChatService_SendMessageClient = (*AIChatServiceSendMessageClient)(nil)
_ AIChatService_SendMessageServer = (*AIChatServiceSendMessageServer)(nil)
)
// AIChatService is a client for the topfans.ai_chat.AIChatService service.
type AIChatService interface {
InitSession(ctx context.Context, req *InitSessionRequest, opts ...client.CallOption) (*InitSessionResponse, error)
SendMessage(ctx context.Context, req *ChatMessageRequest, opts ...client.CallOption) (AIChatService_SendMessageClient, error)
GetHistory(ctx context.Context, req *ChatHistoryRequest, opts ...client.CallOption) (*ChatHistoryResponse, error)
GetPersonas(ctx context.Context, req *GetPersonasRequest, opts ...client.CallOption) (*PersonaListResponse, error)
}
// NewAIChatService constructs a client for the ai_chat.AIChatService service.
func NewAIChatService(cli *client.Client, opts ...client.ReferenceOption) (AIChatService, error) {
conn, err := cli.DialWithInfo("topfans.ai_chat.AIChatService", &AIChatService_ClientInfo, opts...)
if err != nil {
return nil, err
}
return &AIChatServiceImpl{
conn: conn,
}, nil
}
func SetConsumerAIChatService(srv common.RPCService) {
dubbo.SetConsumerServiceWithInfo(srv, &AIChatService_ClientInfo)
}
// AIChatServiceImpl implements AIChatService.
type AIChatServiceImpl struct {
conn *client.Connection
}
func (c *AIChatServiceImpl) InitSession(ctx context.Context, req *InitSessionRequest, opts ...client.CallOption) (*InitSessionResponse, error) {
resp := new(InitSessionResponse)
if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "InitSession", opts...); err != nil {
return nil, err
}
return resp, nil
}
func (c *AIChatServiceImpl) SendMessage(ctx context.Context, req *ChatMessageRequest, opts ...client.CallOption) (AIChatService_SendMessageClient, error) {
stream, err := c.conn.CallServerStream(ctx, req, "SendMessage", opts...)
if err != nil {
return nil, err
}
rawStream := stream.(*triple_protocol.ServerStreamForClient)
return &AIChatServiceSendMessageClient{rawStream}, nil
}
func (c *AIChatServiceImpl) GetHistory(ctx context.Context, req *ChatHistoryRequest, opts ...client.CallOption) (*ChatHistoryResponse, error) {
resp := new(ChatHistoryResponse)
if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "GetHistory", opts...); err != nil {
return nil, err
}
return resp, nil
}
func (c *AIChatServiceImpl) GetPersonas(ctx context.Context, req *GetPersonasRequest, opts ...client.CallOption) (*PersonaListResponse, error) {
resp := new(PersonaListResponse)
if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "GetPersonas", opts...); err != nil {
return nil, err
}
return resp, nil
}
type AIChatService_SendMessageClient interface {
Recv() bool
ResponseHeader() http.Header
ResponseTrailer() http.Header
Msg() *ChatMessageResponse
Err() error
Conn() (triple_protocol.StreamingClientConn, error)
Close() error
}
type AIChatServiceSendMessageClient struct {
*triple_protocol.ServerStreamForClient
}
func (cli *AIChatServiceSendMessageClient) Recv() bool {
msg := new(ChatMessageResponse)
return cli.ServerStreamForClient.Receive(msg)
}
func (cli *AIChatServiceSendMessageClient) Msg() *ChatMessageResponse {
msg := cli.ServerStreamForClient.Msg()
if msg == nil {
return new(ChatMessageResponse)
}
return msg.(*ChatMessageResponse)
}
func (cli *AIChatServiceSendMessageClient) Conn() (triple_protocol.StreamingClientConn, error) {
return cli.ServerStreamForClient.Conn()
}
var AIChatService_ClientInfo = client.ClientInfo{
InterfaceName: "topfans.ai_chat.AIChatService",
MethodNames: []string{"InitSession", "SendMessage", "GetHistory", "GetPersonas"},
ConnectionInjectFunc: func(dubboCliRaw interface{}, conn *client.Connection) {
dubboCli := dubboCliRaw.(*AIChatServiceImpl)
dubboCli.conn = conn
},
}
// AIChatServiceHandler is an implementation of the topfans.ai_chat.AIChatService service.
type AIChatServiceHandler interface {
InitSession(context.Context, *InitSessionRequest) (*InitSessionResponse, error)
SendMessage(context.Context, *ChatMessageRequest, AIChatService_SendMessageServer) error
GetHistory(context.Context, *ChatHistoryRequest) (*ChatHistoryResponse, error)
GetPersonas(context.Context, *GetPersonasRequest) (*PersonaListResponse, error)
}
func RegisterAIChatServiceHandler(srv *server.Server, hdlr AIChatServiceHandler, opts ...server.ServiceOption) error {
return srv.Register(hdlr, &AIChatService_ServiceInfo, opts...)
}
func SetProviderAIChatService(srv common.RPCService) {
dubbo.SetProviderServiceWithInfo(srv, &AIChatService_ServiceInfo)
}
type AIChatService_SendMessageServer interface {
Send(*ChatMessageResponse) error
ResponseHeader() http.Header
ResponseTrailer() http.Header
Conn() triple_protocol.StreamingHandlerConn
}
type AIChatServiceSendMessageServer struct {
*triple_protocol.ServerStream
}
func (g *AIChatServiceSendMessageServer) Send(msg *ChatMessageResponse) error {
return g.ServerStream.Send(msg)
}
var AIChatService_ServiceInfo = server.ServiceInfo{
InterfaceName: "topfans.ai_chat.AIChatService",
ServiceType: (*AIChatServiceHandler)(nil),
Methods: []server.MethodInfo{
{
Name: "InitSession",
Type: constant.CallUnary,
ReqInitFunc: func() interface{} {
return new(InitSessionRequest)
},
MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
req := args[0].(*InitSessionRequest)
res, err := handler.(AIChatServiceHandler).InitSession(ctx, req)
if err != nil {
return nil, err
}
return triple_protocol.NewResponse(res), nil
},
},
{
Name: "SendMessage",
Type: constant.CallServerStream,
ReqInitFunc: func() interface{} {
return new(ChatMessageRequest)
},
StreamInitFunc: func(baseStream interface{}) interface{} {
return &AIChatServiceSendMessageServer{baseStream.(*triple_protocol.ServerStream)}
},
MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
req := args[0].(*ChatMessageRequest)
stream := args[1].(AIChatService_SendMessageServer)
if err := handler.(AIChatServiceHandler).SendMessage(ctx, req, stream); err != nil {
return nil, err
}
return nil, nil
},
},
{
Name: "GetHistory",
Type: constant.CallUnary,
ReqInitFunc: func() interface{} {
return new(ChatHistoryRequest)
},
MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
req := args[0].(*ChatHistoryRequest)
res, err := handler.(AIChatServiceHandler).GetHistory(ctx, req)
if err != nil {
return nil, err
}
return triple_protocol.NewResponse(res), nil
},
},
{
Name: "GetPersonas",
Type: constant.CallUnary,
ReqInitFunc: func() interface{} {
return new(GetPersonasRequest)
},
MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
req := args[0].(*GetPersonasRequest)
res, err := handler.(AIChatServiceHandler).GetPersonas(ctx, req)
if err != nil {
return nil, err
}
return triple_protocol.NewResponse(res), nil
},
},
},
}