grpcapi

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EncodeRequest_PoolingStrategy_name = map[int32]string{
		0: "CLS_TOKEN",
		1: "REDUCE_MEAN",
		2: "REDUCE_MAX",
		3: "REDUCE_MEAN_MAX",
	}
	EncodeRequest_PoolingStrategy_value = map[string]int32{
		"CLS_TOKEN":       0,
		"REDUCE_MEAN":     1,
		"REDUCE_MAX":      2,
		"REDUCE_MEAN_MAX": 3,
	}
)

Enum value maps for EncodeRequest_PoolingStrategy.

View Source
var BERT_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "bert.grpcapi.BERT",
	HandlerType: (*BERTServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Answer",
			Handler:    _BERT_Answer_Handler,
		},
		{
			MethodName: "Discriminate",
			Handler:    _BERT_Discriminate_Handler,
		},
		{
			MethodName: "Predict",
			Handler:    _BERT_Predict_Handler,
		},
		{
			MethodName: "Encode",
			Handler:    _BERT_Encode_Handler,
		},
		{
			MethodName: "Classify",
			Handler:    _BERT_Classify_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "bert.proto",
}

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

Functions

func RegisterBERTServer

func RegisterBERTServer(s grpc.ServiceRegistrar, srv BERTServer)

Types

type Answer

type Answer struct {
	Text       string  `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	Start      int32   `protobuf:"varint,2,opt,name=start,proto3" json:"start,omitempty"`
	End        int32   `protobuf:"varint,3,opt,name=end,proto3" json:"end,omitempty"`
	Confidence float64 `protobuf:"fixed64,4,opt,name=confidence,proto3" json:"confidence,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the answers.

func (*Answer) Descriptor deprecated

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

Deprecated: Use Answer.ProtoReflect.Descriptor instead.

func (*Answer) GetConfidence

func (x *Answer) GetConfidence() float64

func (*Answer) GetEnd

func (x *Answer) GetEnd() int32

func (*Answer) GetStart

func (x *Answer) GetStart() int32

func (*Answer) GetText

func (x *Answer) GetText() string

func (*Answer) ProtoMessage

func (*Answer) ProtoMessage()

func (*Answer) ProtoReflect

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

func (*Answer) Reset

func (x *Answer) Reset()

func (*Answer) String

func (x *Answer) String() string

type AnswerReply

type AnswerReply struct {
	Answers []*Answer `protobuf:"bytes,1,rep,name=answers,proto3" json:"answers,omitempty"`
	// Took is the number of milliseconds it took the server to execute the request.
	Took int64 `protobuf:"varint,2,opt,name=took,proto3" json:"took,omitempty"`
	// contains filtered or unexported fields
}

func (*AnswerReply) Descriptor deprecated

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

Deprecated: Use AnswerReply.ProtoReflect.Descriptor instead.

func (*AnswerReply) GetAnswers

func (x *AnswerReply) GetAnswers() []*Answer

func (*AnswerReply) GetTook

func (x *AnswerReply) GetTook() int64

func (*AnswerReply) ProtoMessage

func (*AnswerReply) ProtoMessage()

func (*AnswerReply) ProtoReflect

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

func (*AnswerReply) Reset

func (x *AnswerReply) Reset()

func (*AnswerReply) String

func (x *AnswerReply) String() string

type AnswerRequest

type AnswerRequest struct {
	Passage  string `protobuf:"bytes,1,opt,name=passage,proto3" json:"passage,omitempty"`
	Question string `protobuf:"bytes,2,opt,name=question,proto3" json:"question,omitempty"`
	// contains filtered or unexported fields
}

The answer request message containing the passage and question to answer.

func (*AnswerRequest) Descriptor deprecated

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

Deprecated: Use AnswerRequest.ProtoReflect.Descriptor instead.

func (*AnswerRequest) GetPassage

func (x *AnswerRequest) GetPassage() string

func (*AnswerRequest) GetQuestion

func (x *AnswerRequest) GetQuestion() string

func (*AnswerRequest) ProtoMessage

func (*AnswerRequest) ProtoMessage()

func (*AnswerRequest) ProtoReflect

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

func (*AnswerRequest) Reset

func (x *AnswerRequest) Reset()

func (*AnswerRequest) String

func (x *AnswerRequest) String() string

type BERTClient

type BERTClient interface {
	// Sends a request to /answer.
	Answer(ctx context.Context, in *AnswerRequest, opts ...grpc.CallOption) (*AnswerReply, error)
	// Sends a request to /discriminate.
	Discriminate(ctx context.Context, in *DiscriminateRequest, opts ...grpc.CallOption) (*DiscriminateReply, error)
	// Sends a request to /predict.
	Predict(ctx context.Context, in *PredictRequest, opts ...grpc.CallOption) (*PredictReply, error)
	// Sends a request to /encode.
	Encode(ctx context.Context, in *EncodeRequest, opts ...grpc.CallOption) (*EncodeReply, error)
	// Sends a request to /classify.
	Classify(ctx context.Context, in *ClassifyRequest, opts ...grpc.CallOption) (*ClassifyReply, error)
}

BERTClient is the client API for BERT 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 NewBERTClient

func NewBERTClient(cc grpc.ClientConnInterface) BERTClient

type BERTServer

type BERTServer interface {
	// Sends a request to /answer.
	Answer(context.Context, *AnswerRequest) (*AnswerReply, error)
	// Sends a request to /discriminate.
	Discriminate(context.Context, *DiscriminateRequest) (*DiscriminateReply, error)
	// Sends a request to /predict.
	Predict(context.Context, *PredictRequest) (*PredictReply, error)
	// Sends a request to /encode.
	Encode(context.Context, *EncodeRequest) (*EncodeReply, error)
	// Sends a request to /classify.
	Classify(context.Context, *ClassifyRequest) (*ClassifyReply, error)
	// contains filtered or unexported methods
}

BERTServer is the server API for BERT service. All implementations must embed UnimplementedBERTServer for forward compatibility

type ClassConfidencePair

type ClassConfidencePair struct {
	Class      string  `protobuf:"bytes,1,opt,name=class,proto3" json:"class,omitempty"`
	Confidence float64 `protobuf:"fixed64,2,opt,name=confidence,proto3" json:"confidence,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the classification.

func (*ClassConfidencePair) Descriptor deprecated

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

Deprecated: Use ClassConfidencePair.ProtoReflect.Descriptor instead.

func (*ClassConfidencePair) GetClass

func (x *ClassConfidencePair) GetClass() string

func (*ClassConfidencePair) GetConfidence

func (x *ClassConfidencePair) GetConfidence() float64

func (*ClassConfidencePair) ProtoMessage

func (*ClassConfidencePair) ProtoMessage()

func (*ClassConfidencePair) ProtoReflect

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

func (*ClassConfidencePair) Reset

func (x *ClassConfidencePair) Reset()

func (*ClassConfidencePair) String

func (x *ClassConfidencePair) String() string

type ClassifyReply

type ClassifyReply struct {
	Class        string                 `protobuf:"bytes,1,opt,name=class,proto3" json:"class,omitempty"`
	Confidence   float64                `protobuf:"fixed64,2,opt,name=confidence,proto3" json:"confidence,omitempty"`
	Distribution []*ClassConfidencePair `protobuf:"bytes,3,rep,name=distribution,proto3" json:"distribution,omitempty"`
	// Took is the number of milliseconds it took the server to execute the request.
	Took int64 `protobuf:"varint,4,opt,name=took,proto3" json:"took,omitempty"`
	// contains filtered or unexported fields
}

func (*ClassifyReply) Descriptor deprecated

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

Deprecated: Use ClassifyReply.ProtoReflect.Descriptor instead.

func (*ClassifyReply) GetClass

func (x *ClassifyReply) GetClass() string

func (*ClassifyReply) GetConfidence

func (x *ClassifyReply) GetConfidence() float64

func (*ClassifyReply) GetDistribution

func (x *ClassifyReply) GetDistribution() []*ClassConfidencePair

func (*ClassifyReply) GetTook

func (x *ClassifyReply) GetTook() int64

func (*ClassifyReply) ProtoMessage

func (*ClassifyReply) ProtoMessage()

func (*ClassifyReply) ProtoReflect

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

func (*ClassifyReply) Reset

func (x *ClassifyReply) Reset()

func (*ClassifyReply) String

func (x *ClassifyReply) String() string

type ClassifyRequest

type ClassifyRequest struct {
	HasText2 bool   `protobuf:"varint,1,opt,name=has_text2,json=hasText2,proto3" json:"has_text2,omitempty"` // always set this to "true" when using text2
	Text     string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
	Text2    string `protobuf:"bytes,3,opt,name=text2,proto3" json:"text2,omitempty"`
	// contains filtered or unexported fields
}

The classify request message containing the text to classify

func (*ClassifyRequest) Descriptor deprecated

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

Deprecated: Use ClassifyRequest.ProtoReflect.Descriptor instead.

func (*ClassifyRequest) GetHasText2

func (x *ClassifyRequest) GetHasText2() bool

func (*ClassifyRequest) GetText

func (x *ClassifyRequest) GetText() string

func (*ClassifyRequest) GetText2

func (x *ClassifyRequest) GetText2() string

func (*ClassifyRequest) ProtoMessage

func (*ClassifyRequest) ProtoMessage()

func (*ClassifyRequest) ProtoReflect

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

func (*ClassifyRequest) Reset

func (x *ClassifyRequest) Reset()

func (*ClassifyRequest) String

func (x *ClassifyRequest) String() string

type DiscriminateReply

type DiscriminateReply struct {
	Tokens []*Token `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"`
	// Took is the number of milliseconds it took the server to execute the request.
	Took int64 `protobuf:"varint,2,opt,name=took,proto3" json:"took,omitempty"`
	// contains filtered or unexported fields
}

func (*DiscriminateReply) Descriptor deprecated

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

Deprecated: Use DiscriminateReply.ProtoReflect.Descriptor instead.

func (*DiscriminateReply) GetTokens

func (x *DiscriminateReply) GetTokens() []*Token

func (*DiscriminateReply) GetTook

func (x *DiscriminateReply) GetTook() int64

func (*DiscriminateReply) ProtoMessage

func (*DiscriminateReply) ProtoMessage()

func (*DiscriminateReply) ProtoReflect

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

func (*DiscriminateReply) Reset

func (x *DiscriminateReply) Reset()

func (*DiscriminateReply) String

func (x *DiscriminateReply) String() string

type DiscriminateRequest

type DiscriminateRequest struct {
	Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	// contains filtered or unexported fields
}

The discriminate request message containing the text.

func (*DiscriminateRequest) Descriptor deprecated

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

Deprecated: Use DiscriminateRequest.ProtoReflect.Descriptor instead.

func (*DiscriminateRequest) GetText

func (x *DiscriminateRequest) GetText() string

func (*DiscriminateRequest) ProtoMessage

func (*DiscriminateRequest) ProtoMessage()

func (*DiscriminateRequest) ProtoReflect

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

func (*DiscriminateRequest) Reset

func (x *DiscriminateRequest) Reset()

func (*DiscriminateRequest) String

func (x *DiscriminateRequest) String() string

type EncodeReply

type EncodeReply struct {
	Vector []float32 `protobuf:"fixed32,1,rep,packed,name=vector,proto3" json:"vector,omitempty"`
	// Took is the number of milliseconds it took the server to execute the request.
	Took int64 `protobuf:"varint,2,opt,name=took,proto3" json:"took,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the tokens from BERT prediction.

func (*EncodeReply) Descriptor deprecated

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

Deprecated: Use EncodeReply.ProtoReflect.Descriptor instead.

func (*EncodeReply) GetTook

func (x *EncodeReply) GetTook() int64

func (*EncodeReply) GetVector

func (x *EncodeReply) GetVector() []float32

func (*EncodeReply) ProtoMessage

func (*EncodeReply) ProtoMessage()

func (*EncodeReply) ProtoReflect

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

func (*EncodeReply) Reset

func (x *EncodeReply) Reset()

func (*EncodeReply) String

func (x *EncodeReply) String() string

type EncodeRequest

type EncodeRequest struct {
	Text            string                        `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	PoolingStrategy EncodeRequest_PoolingStrategy `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

The encode request message containing the text.

func (*EncodeRequest) Descriptor deprecated

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

Deprecated: Use EncodeRequest.ProtoReflect.Descriptor instead.

func (*EncodeRequest) GetPoolingStrategy added in v0.5.2

func (x *EncodeRequest) GetPoolingStrategy() EncodeRequest_PoolingStrategy

func (*EncodeRequest) GetText

func (x *EncodeRequest) GetText() string

func (*EncodeRequest) ProtoMessage

func (*EncodeRequest) ProtoMessage()

func (*EncodeRequest) ProtoReflect

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

func (*EncodeRequest) Reset

func (x *EncodeRequest) Reset()

func (*EncodeRequest) String

func (x *EncodeRequest) String() string

type EncodeRequest_PoolingStrategy added in v0.5.2

type EncodeRequest_PoolingStrategy int32
const (
	// get the encoding state corresponding to [CLS], i.e. the first token (default)
	EncodeRequest_CLS_TOKEN EncodeRequest_PoolingStrategy = 0
	// take the average of the encoding states
	EncodeRequest_REDUCE_MEAN EncodeRequest_PoolingStrategy = 1
	//  take the maximum of the encoding states
	EncodeRequest_REDUCE_MAX EncodeRequest_PoolingStrategy = 2
	// do REDUCE_MEAN and REDUCE_MAX separately and then concat them together
	EncodeRequest_REDUCE_MEAN_MAX EncodeRequest_PoolingStrategy = 3
)

func (EncodeRequest_PoolingStrategy) Descriptor added in v0.5.2

func (EncodeRequest_PoolingStrategy) Enum added in v0.5.2

func (EncodeRequest_PoolingStrategy) EnumDescriptor deprecated added in v0.5.2

func (EncodeRequest_PoolingStrategy) EnumDescriptor() ([]byte, []int)

Deprecated: Use EncodeRequest_PoolingStrategy.Descriptor instead.

func (EncodeRequest_PoolingStrategy) Number added in v0.5.2

func (EncodeRequest_PoolingStrategy) String added in v0.5.2

func (EncodeRequest_PoolingStrategy) Type added in v0.5.2

type PredictReply

type PredictReply struct {
	Tokens []*Token `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"`
	// Took is the number of milliseconds it took the server to execute the request.
	Took int64 `protobuf:"varint,2,opt,name=took,proto3" json:"took,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the tokens from BERT prediction.

func (*PredictReply) Descriptor deprecated

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

Deprecated: Use PredictReply.ProtoReflect.Descriptor instead.

func (*PredictReply) GetTokens

func (x *PredictReply) GetTokens() []*Token

func (*PredictReply) GetTook

func (x *PredictReply) GetTook() int64

func (*PredictReply) ProtoMessage

func (*PredictReply) ProtoMessage()

func (*PredictReply) ProtoReflect

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

func (*PredictReply) Reset

func (x *PredictReply) Reset()

func (*PredictReply) String

func (x *PredictReply) String() string

type PredictRequest

type PredictRequest struct {
	Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	// contains filtered or unexported fields
}

The predict request message containing the text.

func (*PredictRequest) Descriptor deprecated

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

Deprecated: Use PredictRequest.ProtoReflect.Descriptor instead.

func (*PredictRequest) GetText

func (x *PredictRequest) GetText() string

func (*PredictRequest) ProtoMessage

func (*PredictRequest) ProtoMessage()

func (*PredictRequest) ProtoReflect

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

func (*PredictRequest) Reset

func (x *PredictRequest) Reset()

func (*PredictRequest) String

func (x *PredictRequest) String() string

type Token

type Token struct {
	Text  string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	Start int32  `protobuf:"varint,2,opt,name=start,proto3" json:"start,omitempty"`
	End   int32  `protobuf:"varint,3,opt,name=end,proto3" json:"end,omitempty"`
	Label string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the tokens from discriminate analysis.

func (*Token) Descriptor deprecated

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

Deprecated: Use Token.ProtoReflect.Descriptor instead.

func (*Token) GetEnd

func (x *Token) GetEnd() int32

func (*Token) GetLabel

func (x *Token) GetLabel() string

func (*Token) GetStart

func (x *Token) GetStart() int32

func (*Token) GetText

func (x *Token) GetText() string

func (*Token) ProtoMessage

func (*Token) ProtoMessage()

func (*Token) ProtoReflect

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

func (*Token) Reset

func (x *Token) Reset()

func (*Token) String

func (x *Token) String() string

type UnimplementedBERTServer

type UnimplementedBERTServer struct {
}

UnimplementedBERTServer must be embedded to have forward compatible implementations.

func (UnimplementedBERTServer) Answer

func (UnimplementedBERTServer) Classify

func (UnimplementedBERTServer) Discriminate

func (UnimplementedBERTServer) Encode

func (UnimplementedBERTServer) Predict

type UnsafeBERTServer added in v0.2.0

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

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

Jump to

Keyboard shortcuts

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