ai_customv1

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package ai_customv1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	WenxinworkshopService_ChatCompletions_FullMethodName       = "/baidubce.ai_custom.v1.WenxinworkshopService/ChatCompletions"
	WenxinworkshopService_ChatCompletionsStream_FullMethodName = "/baidubce.ai_custom.v1.WenxinworkshopService/ChatCompletionsStream"
	WenxinworkshopService_ChatEbInstant_FullMethodName         = "/baidubce.ai_custom.v1.WenxinworkshopService/ChatEbInstant"
	WenxinworkshopService_Balance_FullMethodName               = "/baidubce.ai_custom.v1.WenxinworkshopService/Balance"
)

Variables

View Source
var File_baidubce_ai_custom_v1_wenxinworkshop_proto protoreflect.FileDescriptor
View Source
var File_baidubce_ai_custom_v1_wenxinworkshop_service_proto protoreflect.FileDescriptor
View Source
var WenxinworkshopService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "baidubce.ai_custom.v1.WenxinworkshopService",
	HandlerType: (*WenxinworkshopServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ChatCompletions",
			Handler:    _WenxinworkshopService_ChatCompletions_Handler,
		},
		{
			MethodName: "ChatEbInstant",
			Handler:    _WenxinworkshopService_ChatEbInstant_Handler,
		},
		{
			MethodName: "Balance",
			Handler:    _WenxinworkshopService_Balance_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ChatCompletionsStream",
			Handler:       _WenxinworkshopService_ChatCompletionsStream_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "baidubce/ai_custom/v1/wenxinworkshop_service.proto",
}

WenxinworkshopService_ServiceDesc is the grpc.ServiceDesc for WenxinworkshopService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterWenxinworkshopServiceHandler

func RegisterWenxinworkshopServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterWenxinworkshopServiceHandler registers the http handlers for service WenxinworkshopService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterWenxinworkshopServiceHandlerClient

func RegisterWenxinworkshopServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WenxinworkshopServiceClient) error

RegisterWenxinworkshopServiceHandlerClient registers the http handlers for service WenxinworkshopService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "WenxinworkshopServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "WenxinworkshopServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "WenxinworkshopServiceClient" to call the correct interceptors.

func RegisterWenxinworkshopServiceHandlerFromEndpoint

func RegisterWenxinworkshopServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterWenxinworkshopServiceHandlerFromEndpoint is same as RegisterWenxinworkshopServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterWenxinworkshopServiceHandlerServer

func RegisterWenxinworkshopServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WenxinworkshopServiceServer) error

RegisterWenxinworkshopServiceHandlerServer registers the http handlers for service WenxinworkshopService to "mux". UnaryRPC :call WenxinworkshopServiceServer 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 RegisterWenxinworkshopServiceHandlerFromEndpoint instead.

func RegisterWenxinworkshopServiceServer

func RegisterWenxinworkshopServiceServer(s grpc.ServiceRegistrar, srv WenxinworkshopServiceServer)

Types

type BalanceRequest

type BalanceRequest struct {
	// contains filtered or unexported fields
}

func (*BalanceRequest) Descriptor deprecated

func (*BalanceRequest) Descriptor() ([]byte, []int)

Deprecated: Use BalanceRequest.ProtoReflect.Descriptor instead.

func (*BalanceRequest) ProtoMessage

func (*BalanceRequest) ProtoMessage()

func (*BalanceRequest) ProtoReflect

func (x *BalanceRequest) ProtoReflect() protoreflect.Message

func (*BalanceRequest) Reset

func (x *BalanceRequest) Reset()

func (*BalanceRequest) String

func (x *BalanceRequest) String() string

type BalanceResponse

type BalanceResponse struct {
	TotalGranted   float32 `protobuf:"fixed32,1,opt,name=TotalGranted,proto3" json:"TotalGranted,omitempty"`
	TotalUsed      float32 `protobuf:"fixed32,2,opt,name=TotalUsed,proto3" json:"TotalUsed,omitempty"`
	TotalAvailable float32 `protobuf:"fixed32,3,opt,name=TotalAvailable,proto3" json:"TotalAvailable,omitempty"`
	// contains filtered or unexported fields
}

func (*BalanceResponse) Descriptor deprecated

func (*BalanceResponse) Descriptor() ([]byte, []int)

Deprecated: Use BalanceResponse.ProtoReflect.Descriptor instead.

func (*BalanceResponse) GetTotalAvailable

func (x *BalanceResponse) GetTotalAvailable() float32

func (*BalanceResponse) GetTotalGranted

func (x *BalanceResponse) GetTotalGranted() float32

func (*BalanceResponse) GetTotalUsed

func (x *BalanceResponse) GetTotalUsed() float32

func (*BalanceResponse) ProtoMessage

func (*BalanceResponse) ProtoMessage()

func (*BalanceResponse) ProtoReflect

func (x *BalanceResponse) ProtoReflect() protoreflect.Message

func (*BalanceResponse) Reset

func (x *BalanceResponse) Reset()

func (*BalanceResponse) String

func (x *BalanceResponse) String() string

type ChatCompletionsRequest

type ChatCompletionsRequest struct {

	// 是 	聊天上下文信息。说明:
	// (1)messages成员不能为空,1个成员表示单轮对话,多个成员表示多轮对话。
	// (2)最后一个message为当前请求的信息,前面的message为历史对话信息。
	// (3)必须为奇数个成员,成员中message的role必须依次为user、assistant。
	// (4)最后一个message的content长度(即此轮对话的问题)不能超过2000个字符;如果messages中content总长度大于2000字符,系统会依次遗忘最早的历史会话,直到content的总长度不超过2000个字符。
	Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
	// 否 	是否以流式接口的形式返回数据,默认false。
	Stream bool `protobuf:"varint,2,opt,name=stream,proto3" json:"stream,omitempty"`
	// 否 	表示最终用户的唯一标识符,可以监视和检测滥用行为,防止接口恶意调用。
	User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

文心一言云服务

func (*ChatCompletionsRequest) Descriptor deprecated

func (*ChatCompletionsRequest) Descriptor() ([]byte, []int)

Deprecated: Use ChatCompletionsRequest.ProtoReflect.Descriptor instead.

func (*ChatCompletionsRequest) GetMessages

func (x *ChatCompletionsRequest) GetMessages() []*Message

func (*ChatCompletionsRequest) GetStream

func (x *ChatCompletionsRequest) GetStream() bool

func (*ChatCompletionsRequest) GetUser

func (x *ChatCompletionsRequest) GetUser() string

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 ChatEbInstantRequest

type ChatEbInstantRequest struct {

	//	是 	聊天上下文信息。说明:
	//
	// (1)messages成员不能为空,1个成员表示单轮对话,多个成员表示多轮对话。
	// (2)最后一个message为当前请求的信息,前面的message为历史对话信息。
	// (3)必须为奇数个成员,成员中message的role必须依次为user、assistant。
	// (4)最后一个message的content长度(即此轮对话的问题)不能超过2000个字符;如果messages中content总长度大于2000字符,系统会依次遗忘最早的历史会话,直到content的总长度不超过2000个字符。
	Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
	// 否 	是否以流式接口的形式返回数据,默认false。
	Stream bool `protobuf:"varint,2,opt,name=stream,proto3" json:"stream,omitempty"`
	// 否 	表示最终用户的唯一标识符,可以监视和检测滥用行为,防止接口恶意调用。
	User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

ErnieBot-Lite

func (*ChatEbInstantRequest) Descriptor deprecated

func (*ChatEbInstantRequest) Descriptor() ([]byte, []int)

Deprecated: Use ChatEbInstantRequest.ProtoReflect.Descriptor instead.

func (*ChatEbInstantRequest) GetMessages

func (x *ChatEbInstantRequest) GetMessages() []*Message

func (*ChatEbInstantRequest) GetStream

func (x *ChatEbInstantRequest) GetStream() bool

func (*ChatEbInstantRequest) GetUser

func (x *ChatEbInstantRequest) GetUser() string

func (*ChatEbInstantRequest) ProtoMessage

func (*ChatEbInstantRequest) ProtoMessage()

func (*ChatEbInstantRequest) ProtoReflect

func (x *ChatEbInstantRequest) ProtoReflect() protoreflect.Message

func (*ChatEbInstantRequest) Reset

func (x *ChatEbInstantRequest) Reset()

func (*ChatEbInstantRequest) String

func (x *ChatEbInstantRequest) String() string

type ChatResponse

type ChatResponse struct {

	// 本轮对话的id。
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// 回包类型。
	// chat.completion:多轮对话返回
	Object string `protobuf:"bytes,2,opt,name=object,proto3" json:"object,omitempty"`
	// 时间戳。
	Created int32 `protobuf:"varint,3,opt,name=created,proto3" json:"created,omitempty"`
	// 表示当前子句的序号。只有在流式接口模式下会返回该字段。
	SentenceId int32 `protobuf:"varint,4,opt,name=sentence_id,json=sentenceId,proto3" json:"sentence_id,omitempty"`
	// 表示当前子句是否是最后一句。只有在流式接口模式下会返回该字段。
	IsEnd bool `protobuf:"varint,5,opt,name=is_end,json=isEnd,proto3" json:"is_end,omitempty"`
	// 对话返回结果。
	Result string `protobuf:"bytes,6,opt,name=result,proto3" json:"result,omitempty"`
	// 表示用户输入是否存在安全,是否关闭当前会话,清理历史回话信息。
	// true:是,表示用户输入存在安全风险,建议关闭当前会话,清理历史会话信息。
	// false:否,表示用户输入无安全风险。
	NeedClearHistory bool `protobuf:"varint,7,opt,name=need_clear_history,json=needClearHistory,proto3" json:"need_clear_history,omitempty"`
	// token统计信息,token数 = 汉字数+单词数*1.3 (仅为估算逻辑)。
	Usage *Usage `protobuf:"bytes,8,opt,name=usage,proto3" json:"usage,omitempty"`
	// contains filtered or unexported fields
}

文心一言云服务 ErnieBot-Lite

func (*ChatResponse) Descriptor deprecated

func (*ChatResponse) Descriptor() ([]byte, []int)

Deprecated: Use ChatResponse.ProtoReflect.Descriptor instead.

func (*ChatResponse) GetCreated

func (x *ChatResponse) GetCreated() int32

func (*ChatResponse) GetId

func (x *ChatResponse) GetId() string

func (*ChatResponse) GetIsEnd

func (x *ChatResponse) GetIsEnd() bool

func (*ChatResponse) GetNeedClearHistory

func (x *ChatResponse) GetNeedClearHistory() bool

func (*ChatResponse) GetObject

func (x *ChatResponse) GetObject() string

func (*ChatResponse) GetResult

func (x *ChatResponse) GetResult() string

func (*ChatResponse) GetSentenceId

func (x *ChatResponse) GetSentenceId() int32

func (*ChatResponse) GetUsage

func (x *ChatResponse) GetUsage() *Usage

func (*ChatResponse) ProtoMessage

func (*ChatResponse) ProtoMessage()

func (*ChatResponse) ProtoReflect

func (x *ChatResponse) ProtoReflect() protoreflect.Message

func (*ChatResponse) Reset

func (x *ChatResponse) Reset()

func (*ChatResponse) String

func (x *ChatResponse) String() string

type Message

type Message struct {

	// 当前支持以下:
	// user: 表示用户
	// assistant: 表示对话助手
	Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
	// 对话内容,不能为空。
	Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetContent

func (x *Message) GetContent() string

func (*Message) GetRole

func (x *Message) GetRole() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type UnimplementedWenxinworkshopServiceServer

type UnimplementedWenxinworkshopServiceServer struct {
}

UnimplementedWenxinworkshopServiceServer should be embedded to have forward compatible implementations.

func (UnimplementedWenxinworkshopServiceServer) Balance

func (UnimplementedWenxinworkshopServiceServer) ChatCompletions

func (UnimplementedWenxinworkshopServiceServer) ChatEbInstant

type UnsafeWenxinworkshopServiceServer

type UnsafeWenxinworkshopServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeWenxinworkshopServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to WenxinworkshopServiceServer will result in compilation errors.

type Usage

type Usage struct {

	// 问题tokens数。
	PromptTokens int32 `protobuf:"varint,1,opt,name=prompt_tokens,json=promptTokens,proto3" json:"prompt_tokens,omitempty"`
	// 回答tokens数。
	CompletionTokens int32 `protobuf:"varint,2,opt,name=completion_tokens,json=completionTokens,proto3" json:"completion_tokens,omitempty"`
	// tokens总数。
	TotalTokens int32 `protobuf:"varint,3,opt,name=total_tokens,json=totalTokens,proto3" json:"total_tokens,omitempty"`
	// contains filtered or unexported fields
}

func (*Usage) Descriptor deprecated

func (*Usage) Descriptor() ([]byte, []int)

Deprecated: Use Usage.ProtoReflect.Descriptor instead.

func (*Usage) GetCompletionTokens

func (x *Usage) GetCompletionTokens() int32

func (*Usage) GetPromptTokens

func (x *Usage) GetPromptTokens() int32

func (*Usage) GetTotalTokens

func (x *Usage) GetTotalTokens() int32

func (*Usage) ProtoMessage

func (*Usage) ProtoMessage()

func (*Usage) ProtoReflect

func (x *Usage) ProtoReflect() protoreflect.Message

func (*Usage) Reset

func (x *Usage) Reset()

func (*Usage) String

func (x *Usage) String() string

type WenxinworkshopServiceClient

type WenxinworkshopServiceClient interface {
	// 文心一言云服务
	ChatCompletions(ctx context.Context, in *ChatCompletionsRequest, opts ...grpc.CallOption) (*ChatResponse, error)
	ChatCompletionsStream(ctx context.Context, in *ChatCompletionsRequest, opts ...grpc.CallOption) (WenxinworkshopService_ChatCompletionsStreamClient, error)
	ChatEbInstant(ctx context.Context, in *ChatEbInstantRequest, opts ...grpc.CallOption) (*ChatResponse, error)
	// TODO: find api
	Balance(ctx context.Context, in *BalanceRequest, opts ...grpc.CallOption) (*BalanceResponse, error)
}

WenxinworkshopServiceClient is the client API for WenxinworkshopService 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.

type WenxinworkshopServiceServer

type WenxinworkshopServiceServer interface {
	// 文心一言云服务
	ChatCompletions(context.Context, *ChatCompletionsRequest) (*ChatResponse, error)
	ChatCompletionsStream(*ChatCompletionsRequest, WenxinworkshopService_ChatCompletionsStreamServer) error
	ChatEbInstant(context.Context, *ChatEbInstantRequest) (*ChatResponse, error)
	// TODO: find api
	Balance(context.Context, *BalanceRequest) (*BalanceResponse, error)
}

WenxinworkshopServiceServer is the server API for WenxinworkshopService service. All implementations should embed UnimplementedWenxinworkshopServiceServer for forward compatibility

type WenxinworkshopService_ChatCompletionsStreamClient

type WenxinworkshopService_ChatCompletionsStreamClient interface {
	Recv() (*ChatResponse, error)
	grpc.ClientStream
}

type WenxinworkshopService_ChatCompletionsStreamServer

type WenxinworkshopService_ChatCompletionsStreamServer interface {
	Send(*ChatResponse) error
	grpc.ServerStream
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL