Documentation ¶
Overview ¶
Package textv1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterMinimaxServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterMinimaxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MinimaxServiceClient) error
- func RegisterMinimaxServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterMinimaxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MinimaxServiceServer) error
- func RegisterMinimaxServiceServer(s grpc.ServiceRegistrar, srv MinimaxServiceServer)
- type BaseResponse
- func (*BaseResponse) Descriptor() ([]byte, []int)deprecated
- func (x *BaseResponse) GetStatusCode() int64
- func (x *BaseResponse) GetStatusMsg() string
- func (*BaseResponse) ProtoMessage()
- func (x *BaseResponse) ProtoReflect() protoreflect.Message
- func (x *BaseResponse) Reset()
- func (x *BaseResponse) String() string
- type ChatCompletionsRequest
- func (*ChatCompletionsRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ChatCompletionsRequest) GetBeamWidth() int32
- func (x *ChatCompletionsRequest) GetMessages() []*Message
- func (x *ChatCompletionsRequest) GetModel() string
- func (x *ChatCompletionsRequest) GetPrompt() string
- func (x *ChatCompletionsRequest) GetRoleMeta() *RoleMeta
- func (x *ChatCompletionsRequest) GetSkipInfoMask() bool
- func (x *ChatCompletionsRequest) GetStream() bool
- func (x *ChatCompletionsRequest) GetTemperature() float32
- func (x *ChatCompletionsRequest) GetTopP() float32
- func (x *ChatCompletionsRequest) GetUseStandardSse() bool
- func (x *ChatCompletionsRequest) GetWithEmotion() bool
- func (*ChatCompletionsRequest) ProtoMessage()
- func (x *ChatCompletionsRequest) ProtoReflect() protoreflect.Message
- func (x *ChatCompletionsRequest) Reset()
- func (x *ChatCompletionsRequest) String() string
- type ChatCompletionsResponse
- func (*ChatCompletionsResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ChatCompletionsResponse) GetBaseResp() *BaseResponse
- func (x *ChatCompletionsResponse) GetChoices() []*Choice
- func (x *ChatCompletionsResponse) GetCreated() int64
- func (x *ChatCompletionsResponse) GetInputSensitive() bool
- func (x *ChatCompletionsResponse) GetModel() string
- func (x *ChatCompletionsResponse) GetOutputSensitive() bool
- func (x *ChatCompletionsResponse) GetReply() string
- func (x *ChatCompletionsResponse) GetUsage() *Usage
- func (*ChatCompletionsResponse) ProtoMessage()
- func (x *ChatCompletionsResponse) ProtoReflect() protoreflect.Message
- func (x *ChatCompletionsResponse) Reset()
- func (x *ChatCompletionsResponse) String() string
- type Choice
- func (*Choice) Descriptor() ([]byte, []int)deprecated
- func (x *Choice) GetDelta() string
- func (x *Choice) GetEmotion() string
- func (x *Choice) GetFinishReason() string
- func (x *Choice) GetIndex() int64
- func (x *Choice) GetLogprobes() int64
- func (x *Choice) GetText() string
- func (*Choice) ProtoMessage()
- func (x *Choice) ProtoReflect() protoreflect.Message
- func (x *Choice) Reset()
- func (x *Choice) String() string
- type Message
- type MinimaxServiceClient
- type MinimaxServiceServer
- type MinimaxService_ChatCompletionStreamClient
- type MinimaxService_ChatCompletionStreamServer
- type RoleMeta
- type UnimplementedMinimaxServiceServer
- type UnsafeMinimaxServiceServer
- type Usage
Constants ¶
const ( MinimaxService_ChatCompletions_FullMethodName = "/minimax.text.v1.MinimaxService/ChatCompletions" MinimaxService_ChatCompletionStream_FullMethodName = "/minimax.text.v1.MinimaxService/ChatCompletionStream" )
Variables ¶
var File_minimax_text_v1_chat_proto protoreflect.FileDescriptor
var File_minimax_text_v1_chat_service_proto protoreflect.FileDescriptor
var MinimaxService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "minimax.text.v1.MinimaxService", HandlerType: (*MinimaxServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "ChatCompletions", Handler: _MinimaxService_ChatCompletions_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "ChatCompletionStream", Handler: _MinimaxService_ChatCompletionStream_Handler, ServerStreams: true, }, }, Metadata: "minimax/text/v1/chat_service.proto", }
MinimaxService_ServiceDesc is the grpc.ServiceDesc for MinimaxService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterMinimaxServiceHandler ¶
func RegisterMinimaxServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterMinimaxServiceHandler registers the http handlers for service MinimaxService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterMinimaxServiceHandlerClient ¶
func RegisterMinimaxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MinimaxServiceClient) error
RegisterMinimaxServiceHandlerClient registers the http handlers for service MinimaxService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MinimaxServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MinimaxServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "MinimaxServiceClient" to call the correct interceptors.
func RegisterMinimaxServiceHandlerFromEndpoint ¶
func RegisterMinimaxServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterMinimaxServiceHandlerFromEndpoint is same as RegisterMinimaxServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterMinimaxServiceHandlerServer ¶
func RegisterMinimaxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MinimaxServiceServer) error
RegisterMinimaxServiceHandlerServer registers the http handlers for service MinimaxService to "mux". UnaryRPC :call MinimaxServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMinimaxServiceHandlerFromEndpoint instead.
func RegisterMinimaxServiceServer ¶
func RegisterMinimaxServiceServer(s grpc.ServiceRegistrar, srv MinimaxServiceServer)
Types ¶
type BaseResponse ¶
type BaseResponse struct { // 状态码 // // 1000,未知错误 // 1001,超时 // 1002,触发限流 // 1004,鉴权失败 // 1008,余额不足 // 1013,服务内部错误 // 1027,输出内容严重违规 // 2013,输入格式信息不正常 StatusCode int64 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 错误详情 StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // contains filtered or unexported fields }
func (*BaseResponse) Descriptor
deprecated
func (*BaseResponse) Descriptor() ([]byte, []int)
Deprecated: Use BaseResponse.ProtoReflect.Descriptor instead.
func (*BaseResponse) GetStatusCode ¶
func (x *BaseResponse) GetStatusCode() int64
func (*BaseResponse) GetStatusMsg ¶
func (x *BaseResponse) GetStatusMsg() string
func (*BaseResponse) ProtoMessage ¶
func (*BaseResponse) ProtoMessage()
func (*BaseResponse) ProtoReflect ¶
func (x *BaseResponse) ProtoReflect() protoreflect.Message
func (*BaseResponse) Reset ¶
func (x *BaseResponse) Reset()
func (*BaseResponse) String ¶
func (x *BaseResponse) String() string
type ChatCompletionsRequest ¶
type ChatCompletionsRequest struct { // 目前只能取以下一个值 // abab5-chat Model string `protobuf:"bytes,1,opt,name=model,proto3" json:"model,omitempty"` // 否 对回复添加情绪预测。注意,当with_emotion=true,且请求上下文(输入和输出文本)长时,请求会显著变慢,达到数秒。 WithEmotion bool `protobuf:"varint,2,opt,name=with_emotion,json=withEmotion,proto3" json:"with_emotion,omitempty"` // 否 是否以流式接口的形式返回数据,默认false。 Stream bool `protobuf:"varint,3,opt,name=stream,proto3" json:"stream,omitempty"` // 是否通过流式分批返回结果。如果设置为true,结果分批返回,以一个换行为分割符;若希望使用标准SSE响应格式,可以设置use_standard_sse参数为true。默认false UseStandardSse bool `protobuf:"varint,4,opt,name=use_standard_sse,json=useStandardSse,proto3" json:"use_standard_sse,omitempty"` // 生成多少个结果;不设置默认为1,最大不超过4。 由于beam_width生成多个结果,会消耗更多token。 默认1 BeamWidth int32 `protobuf:"varint,5,opt,name=beam_width,json=beamWidth,proto3" json:"beam_width,omitempty"` // 对话背景、人物或功能设定 长度上限为4096个token,不可为空 Prompt string `protobuf:"bytes,6,opt,name=prompt,proto3" json:"prompt,omitempty"` // 对话上下文信息。说明:"user_name": "我", "bot_name": "专家" RoleMeta *RoleMeta `protobuf:"bytes,7,opt,name=role_meta,json=roleMeta,proto3" json:"role_meta,omitempty"` // 是 聊天上下文信息。说明: // (1)messages成员不能为空,1个成员表示单轮对话,多个成员表示多轮对话。 // (2)最后一个message为当前请求的信息,前面的message为历史对话信息。 // (3)必须为奇数个成员,成员中message的role必须依次为user、assistant。 // (4)最后一个message的content长度(即此轮对话的问题)不能超过2000个字符;如果messages中content总长度大于2000字符,系统会依次遗忘最早的历史会话,直到content的总长度不超过2000个字符。 Messages []*Message `protobuf:"bytes,8,rep,name=messages,proto3" json:"messages,omitempty"` Temperature float32 `protobuf:"fixed32,9,opt,name=temperature,proto3" json:"temperature,omitempty"` TopP float32 `protobuf:"fixed32,10,opt,name=top_p,json=topP,proto3" json:"top_p,omitempty"` // 对输出中易涉及隐私问题的文本信息进行脱敏,目前包括但不限于邮箱、域名、链接、证件号、家庭住址等,默认false,即开启脱敏 默认false SkipInfoMask bool `protobuf:"varint,11,opt,name=skip_info_mask,json=skipInfoMask,proto3" json:"skip_info_mask,omitempty"` // contains filtered or unexported fields }
func (*ChatCompletionsRequest) Descriptor
deprecated
func (*ChatCompletionsRequest) Descriptor() ([]byte, []int)
Deprecated: Use ChatCompletionsRequest.ProtoReflect.Descriptor instead.
func (*ChatCompletionsRequest) GetBeamWidth ¶
func (x *ChatCompletionsRequest) GetBeamWidth() int32
func (*ChatCompletionsRequest) GetMessages ¶
func (x *ChatCompletionsRequest) GetMessages() []*Message
func (*ChatCompletionsRequest) GetModel ¶
func (x *ChatCompletionsRequest) GetModel() string
func (*ChatCompletionsRequest) GetPrompt ¶
func (x *ChatCompletionsRequest) GetPrompt() string
func (*ChatCompletionsRequest) GetRoleMeta ¶
func (x *ChatCompletionsRequest) GetRoleMeta() *RoleMeta
func (*ChatCompletionsRequest) GetSkipInfoMask ¶
func (x *ChatCompletionsRequest) GetSkipInfoMask() bool
func (*ChatCompletionsRequest) GetStream ¶
func (x *ChatCompletionsRequest) GetStream() bool
func (*ChatCompletionsRequest) GetTemperature ¶
func (x *ChatCompletionsRequest) GetTemperature() float32
func (*ChatCompletionsRequest) GetTopP ¶
func (x *ChatCompletionsRequest) GetTopP() float32
func (*ChatCompletionsRequest) GetUseStandardSse ¶
func (x *ChatCompletionsRequest) GetUseStandardSse() bool
func (*ChatCompletionsRequest) GetWithEmotion ¶
func (x *ChatCompletionsRequest) GetWithEmotion() bool
func (*ChatCompletionsRequest) ProtoMessage ¶
func (*ChatCompletionsRequest) ProtoMessage()
func (*ChatCompletionsRequest) ProtoReflect ¶
func (x *ChatCompletionsRequest) ProtoReflect() protoreflect.Message
func (*ChatCompletionsRequest) Reset ¶
func (x *ChatCompletionsRequest) Reset()
func (*ChatCompletionsRequest) String ¶
func (x *ChatCompletionsRequest) String() string
type ChatCompletionsResponse ¶
type ChatCompletionsResponse struct { // 请求发起时间 Created int64 `protobuf:"varint,1,opt,name=created,proto3" json:"created,omitempty"` // 请求指定的模型 Model string `protobuf:"bytes,2,opt,name=model,proto3" json:"model,omitempty"` // 推荐的最好结果 Reply string `protobuf:"bytes,3,opt,name=reply,proto3" json:"reply,omitempty"` // 所有结果 Choices []*Choice `protobuf:"bytes,4,rep,name=choices,proto3" json:"choices,omitempty"` // tokens数使用情况 Usage *Usage `protobuf:"bytes,5,opt,name=usage,proto3" json:"usage,omitempty"` // 输入命中敏感词 InputSensitive bool `protobuf:"varint,6,opt,name=input_sensitive,json=inputSensitive,proto3" json:"input_sensitive,omitempty"` // 输出命中敏感词 OutputSensitive bool `protobuf:"varint,7,opt,name=output_sensitive,json=outputSensitive,proto3" json:"output_sensitive,omitempty"` // 错误状态码和详情 BaseResp *BaseResponse `protobuf:"bytes,8,opt,name=base_resp,json=baseResp,proto3" json:"base_resp,omitempty"` // contains filtered or unexported fields }
func (*ChatCompletionsResponse) Descriptor
deprecated
func (*ChatCompletionsResponse) Descriptor() ([]byte, []int)
Deprecated: Use ChatCompletionsResponse.ProtoReflect.Descriptor instead.
func (*ChatCompletionsResponse) GetBaseResp ¶
func (x *ChatCompletionsResponse) GetBaseResp() *BaseResponse
func (*ChatCompletionsResponse) GetChoices ¶
func (x *ChatCompletionsResponse) GetChoices() []*Choice
func (*ChatCompletionsResponse) GetCreated ¶
func (x *ChatCompletionsResponse) GetCreated() int64
func (*ChatCompletionsResponse) GetInputSensitive ¶
func (x *ChatCompletionsResponse) GetInputSensitive() bool
func (*ChatCompletionsResponse) GetModel ¶
func (x *ChatCompletionsResponse) GetModel() string
func (*ChatCompletionsResponse) GetOutputSensitive ¶
func (x *ChatCompletionsResponse) GetOutputSensitive() bool
func (*ChatCompletionsResponse) GetReply ¶
func (x *ChatCompletionsResponse) GetReply() string
func (*ChatCompletionsResponse) GetUsage ¶
func (x *ChatCompletionsResponse) GetUsage() *Usage
func (*ChatCompletionsResponse) ProtoMessage ¶
func (*ChatCompletionsResponse) ProtoMessage()
func (*ChatCompletionsResponse) ProtoReflect ¶
func (x *ChatCompletionsResponse) ProtoReflect() protoreflect.Message
func (*ChatCompletionsResponse) Reset ¶
func (x *ChatCompletionsResponse) Reset()
func (*ChatCompletionsResponse) String ¶
func (x *ChatCompletionsResponse) String() string
type Choice ¶
type Choice struct { // 文本结果 Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` // 排名 Index int64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` // 分数 Logprobes int64 `protobuf:"varint,3,opt,name=logprobes,proto3" json:"logprobes,omitempty"` // 结束原因,枚举值 // stop:API返回了模型生成的完整结果 // length:模型生成结果超过tokens_to_generate的长度,内容被截断 FinishReason string `protobuf:"bytes,4,opt,name=finish_reason,json=finishReason,proto3" json:"finish_reason,omitempty"` // 回复文本情绪预测 // 取值为以下八者其一 伤心 尴尬 开心 惊讶 愤怒 慌张 疑惑 自然 Emotion string `protobuf:"bytes,5,opt,name=emotion,proto3" json:"emotion,omitempty"` // 当request.stream为true,处于流式模式下,回复文本通过delta给出 Delta string `protobuf:"bytes,6,opt,name=delta,proto3" json:"delta,omitempty"` // contains filtered or unexported fields }
func (*Choice) Descriptor
deprecated
func (*Choice) GetEmotion ¶
func (*Choice) GetFinishReason ¶
func (*Choice) GetLogprobes ¶
func (*Choice) ProtoMessage ¶
func (*Choice) ProtoMessage()
func (*Choice) ProtoReflect ¶
func (x *Choice) ProtoReflect() protoreflect.Message
type Message ¶
type Message struct { // 当前支持以下: // USER: 表示用户 // BOT: 表示对话助手 SenderType string `protobuf:"bytes,1,opt,name=sender_type,json=senderType,proto3" json:"sender_type,omitempty"` // 对话内容,不能为空。 Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` // contains filtered or unexported fields }
func (*Message) Descriptor
deprecated
func (*Message) GetSenderType ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) ProtoReflect ¶
func (x *Message) ProtoReflect() protoreflect.Message
type MinimaxServiceClient ¶
type MinimaxServiceClient interface { ChatCompletions(ctx context.Context, in *ChatCompletionsRequest, opts ...grpc.CallOption) (*ChatCompletionsResponse, error) ChatCompletionStream(ctx context.Context, in *ChatCompletionsRequest, opts ...grpc.CallOption) (MinimaxService_ChatCompletionStreamClient, error) }
MinimaxServiceClient is the client API for MinimaxService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewMinimaxServiceClient ¶
func NewMinimaxServiceClient(cc grpc.ClientConnInterface) MinimaxServiceClient
type MinimaxServiceServer ¶
type MinimaxServiceServer interface { ChatCompletions(context.Context, *ChatCompletionsRequest) (*ChatCompletionsResponse, error) ChatCompletionStream(*ChatCompletionsRequest, MinimaxService_ChatCompletionStreamServer) error }
MinimaxServiceServer is the server API for MinimaxService service. All implementations should embed UnimplementedMinimaxServiceServer for forward compatibility
type MinimaxService_ChatCompletionStreamClient ¶
type MinimaxService_ChatCompletionStreamClient interface { Recv() (*ChatCompletionsResponse, error) grpc.ClientStream }
type MinimaxService_ChatCompletionStreamServer ¶
type MinimaxService_ChatCompletionStreamServer interface { Send(*ChatCompletionsResponse) error grpc.ServerStream }
type RoleMeta ¶
type RoleMeta struct { UserName string `protobuf:"bytes,1,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"` BotName string `protobuf:"bytes,2,opt,name=bot_name,json=botName,proto3" json:"bot_name,omitempty"` // contains filtered or unexported fields }
func (*RoleMeta) Descriptor
deprecated
func (*RoleMeta) GetBotName ¶
func (*RoleMeta) GetUserName ¶
func (*RoleMeta) ProtoMessage ¶
func (*RoleMeta) ProtoMessage()
func (*RoleMeta) ProtoReflect ¶
func (x *RoleMeta) ProtoReflect() protoreflect.Message
type UnimplementedMinimaxServiceServer ¶
type UnimplementedMinimaxServiceServer struct { }
UnimplementedMinimaxServiceServer should be embedded to have forward compatible implementations.
func (UnimplementedMinimaxServiceServer) ChatCompletionStream ¶
func (UnimplementedMinimaxServiceServer) ChatCompletionStream(*ChatCompletionsRequest, MinimaxService_ChatCompletionStreamServer) error
func (UnimplementedMinimaxServiceServer) ChatCompletions ¶
func (UnimplementedMinimaxServiceServer) ChatCompletions(context.Context, *ChatCompletionsRequest) (*ChatCompletionsResponse, error)
type UnsafeMinimaxServiceServer ¶
type UnsafeMinimaxServiceServer interface {
// contains filtered or unexported methods
}
UnsafeMinimaxServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MinimaxServiceServer will result in compilation errors.
type Usage ¶
type Usage struct { // 消耗tokens总数,包括输入和输出;具体计算方式为输入tokens + 最大输出tokens x beam_width。 // 假设beam_width为2,输入tokens为100,输出结果分别为20tokens和30tokens,最终消耗160tokens TotalTokens int64 `protobuf:"varint,1,opt,name=total_tokens,json=totalTokens,proto3" json:"total_tokens,omitempty"` // contains filtered or unexported fields }
func (*Usage) Descriptor
deprecated
func (*Usage) GetTotalTokens ¶
func (*Usage) ProtoMessage ¶
func (*Usage) ProtoMessage()
func (*Usage) ProtoReflect ¶
func (x *Usage) ProtoReflect() protoreflect.Message