chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,127 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package docreader;
|
||||
|
||||
option go_package = "github.com/Tencent/WeKnora/internal/docreader/proto";
|
||||
|
||||
service DocReader {
|
||||
rpc Read(ReadRequest) returns (ReadResponse) {}
|
||||
// ReadStream is the streaming counterpart of Read. It first emits one
|
||||
// ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
// error), then emits one message per image. This keeps every gRPC message
|
||||
// small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
// unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
// with bounded memory on both ends.
|
||||
rpc ReadStream(ReadRequest) returns (stream ReadStreamResponse) {}
|
||||
rpc ListEngines(ListEnginesRequest) returns (ListEnginesResponse) {}
|
||||
// PreprocessImage straightens and crops a photographed page so that OCR sees
|
||||
// an upright, content-tight image. The caller sends the raw photograph and
|
||||
// receives either the corrected page or a verdict that this input is not a
|
||||
// page worth correcting — never an error for "not correctable", because the
|
||||
// caller's fallback (use the original bytes) is a normal outcome rather than
|
||||
// a failure to report.
|
||||
rpc PreprocessImage(PreprocessImageRequest) returns (PreprocessImageResponse) {}
|
||||
}
|
||||
|
||||
// PreprocessImageRequest carries one photographed page.
|
||||
message PreprocessImageRequest {
|
||||
bytes image = 1;
|
||||
}
|
||||
|
||||
message PreprocessImageResponse {
|
||||
// image is the corrected page, JPEG-encoded. Empty when fallback_needed.
|
||||
bytes image = 1;
|
||||
// fallback_needed tells the caller to keep its original bytes: the input is
|
||||
// not a correctable page, or correcting it would not be an improvement.
|
||||
bool fallback_needed = 2;
|
||||
// Diagnostics for the run's trace and for tuning the thresholds.
|
||||
float theta = 3; // dominant text-line angle (degrees)
|
||||
float residual = 4; // residual skew after alignment; > 2 means low quality
|
||||
bool flip = 5; // whether a 180-degree flip was applied
|
||||
int32 n_boxes = 6; // text boxes detected
|
||||
int32 n_kept = 7; // text boxes kept after filtering
|
||||
// status is "ok" | "no_text" | "low_quality", for logs and metrics.
|
||||
string status = 8;
|
||||
}
|
||||
|
||||
message ReadConfig {
|
||||
string parser_engine = 1;
|
||||
map<string, string> parser_engine_overrides = 2;
|
||||
// image_storage removed: image persistence is now handled entirely by the Go App.
|
||||
// Field number 3 is reserved for backward compatibility.
|
||||
reserved 3;
|
||||
}
|
||||
|
||||
// Unified read request: set file_content for file mode, url for URL mode.
|
||||
message ReadRequest {
|
||||
bytes file_content = 1;
|
||||
string file_name = 2;
|
||||
string file_type = 3;
|
||||
string url = 4;
|
||||
string title = 5;
|
||||
ReadConfig config = 6;
|
||||
string request_id = 7;
|
||||
}
|
||||
|
||||
message ImageRef {
|
||||
string filename = 1;
|
||||
string original_ref = 2;
|
||||
string mime_type = 3;
|
||||
string storage_key = 4; // download URL from shared storage
|
||||
bytes image_data = 5; // inline bytes fallback
|
||||
}
|
||||
|
||||
// SourceBlock ties a range of markdown_content to the place in the original
|
||||
// file it was parsed from, so a citation can open the file there.
|
||||
message SourceBlock {
|
||||
// Unicode code point offsets into markdown_content, end exclusive.
|
||||
uint32 start = 1;
|
||||
uint32 end = 2;
|
||||
// JSON-encoded locator: {"type":"pdf","page":3,"bbox":[x0,y0,x1,y1]}
|
||||
// with ordinals 1-based and bbox as fractions of the page, origin top-left.
|
||||
string locator_json = 3;
|
||||
}
|
||||
|
||||
message ReadResponse {
|
||||
string markdown_content = 1;
|
||||
repeated ImageRef image_refs = 2;
|
||||
string image_dir_path = 3;
|
||||
map<string, string> metadata = 4;
|
||||
string error = 5;
|
||||
repeated SourceBlock source_blocks = 6;
|
||||
}
|
||||
|
||||
// Metadata header for a streamed read. Sent exactly once, before any image.
|
||||
message ReadStreamMeta {
|
||||
string markdown_content = 1;
|
||||
string image_dir_path = 2;
|
||||
map<string, string> metadata = 3;
|
||||
string error = 4;
|
||||
uint32 image_count = 5; // best-effort total image count (0 if unknown)
|
||||
repeated SourceBlock source_blocks = 6;
|
||||
}
|
||||
|
||||
// One frame of a ReadStream. The first frame carries `meta`; every subsequent
|
||||
// frame carries a single `image`.
|
||||
message ReadStreamResponse {
|
||||
oneof payload {
|
||||
ReadStreamMeta meta = 1;
|
||||
ImageRef image = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ListEnginesRequest {
|
||||
map<string, string> config_overrides = 1;
|
||||
}
|
||||
|
||||
message ParserEngineInfo {
|
||||
string name = 1;
|
||||
string description = 2;
|
||||
repeated string file_types = 3;
|
||||
bool available = 4;
|
||||
string unavailable_reason = 5;
|
||||
}
|
||||
|
||||
message ListEnginesResponse {
|
||||
repeated ParserEngineInfo engines = 1;
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc v3.21.12
|
||||
// source: docreader.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
DocReader_Read_FullMethodName = "/docreader.DocReader/Read"
|
||||
DocReader_ReadStream_FullMethodName = "/docreader.DocReader/ReadStream"
|
||||
DocReader_ListEngines_FullMethodName = "/docreader.DocReader/ListEngines"
|
||||
DocReader_PreprocessImage_FullMethodName = "/docreader.DocReader/PreprocessImage"
|
||||
)
|
||||
|
||||
// DocReaderClient is the client API for DocReader 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 DocReaderClient interface {
|
||||
Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error)
|
||||
// ReadStream is the streaming counterpart of Read. It first emits one
|
||||
// ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
// error), then emits one message per image. This keeps every gRPC message
|
||||
// small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
// unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
// with bounded memory on both ends.
|
||||
ReadStream(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadStreamResponse], error)
|
||||
ListEngines(ctx context.Context, in *ListEnginesRequest, opts ...grpc.CallOption) (*ListEnginesResponse, error)
|
||||
// PreprocessImage straightens and crops a photographed page so that OCR sees
|
||||
// an upright, content-tight image. The caller sends the raw photograph and
|
||||
// receives either the corrected page or a verdict that this input is not a
|
||||
// page worth correcting — never an error for "not correctable", because the
|
||||
// caller's fallback (use the original bytes) is a normal outcome rather than
|
||||
// a failure to report.
|
||||
PreprocessImage(ctx context.Context, in *PreprocessImageRequest, opts ...grpc.CallOption) (*PreprocessImageResponse, error)
|
||||
}
|
||||
|
||||
type docReaderClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDocReaderClient(cc grpc.ClientConnInterface) DocReaderClient {
|
||||
return &docReaderClient{cc}
|
||||
}
|
||||
|
||||
func (c *docReaderClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ReadResponse)
|
||||
err := c.cc.Invoke(ctx, DocReader_Read_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *docReaderClient) ReadStream(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadStreamResponse], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &DocReader_ServiceDesc.Streams[0], DocReader_ReadStream_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[ReadRequest, ReadStreamResponse]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type DocReader_ReadStreamClient = grpc.ServerStreamingClient[ReadStreamResponse]
|
||||
|
||||
func (c *docReaderClient) ListEngines(ctx context.Context, in *ListEnginesRequest, opts ...grpc.CallOption) (*ListEnginesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListEnginesResponse)
|
||||
err := c.cc.Invoke(ctx, DocReader_ListEngines_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *docReaderClient) PreprocessImage(ctx context.Context, in *PreprocessImageRequest, opts ...grpc.CallOption) (*PreprocessImageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PreprocessImageResponse)
|
||||
err := c.cc.Invoke(ctx, DocReader_PreprocessImage_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DocReaderServer is the server API for DocReader service.
|
||||
// All implementations must embed UnimplementedDocReaderServer
|
||||
// for forward compatibility.
|
||||
type DocReaderServer interface {
|
||||
Read(context.Context, *ReadRequest) (*ReadResponse, error)
|
||||
// ReadStream is the streaming counterpart of Read. It first emits one
|
||||
// ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
// error), then emits one message per image. This keeps every gRPC message
|
||||
// small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
// unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
// with bounded memory on both ends.
|
||||
ReadStream(*ReadRequest, grpc.ServerStreamingServer[ReadStreamResponse]) error
|
||||
ListEngines(context.Context, *ListEnginesRequest) (*ListEnginesResponse, error)
|
||||
// PreprocessImage straightens and crops a photographed page so that OCR sees
|
||||
// an upright, content-tight image. The caller sends the raw photograph and
|
||||
// receives either the corrected page or a verdict that this input is not a
|
||||
// page worth correcting — never an error for "not correctable", because the
|
||||
// caller's fallback (use the original bytes) is a normal outcome rather than
|
||||
// a failure to report.
|
||||
PreprocessImage(context.Context, *PreprocessImageRequest) (*PreprocessImageResponse, error)
|
||||
mustEmbedUnimplementedDocReaderServer()
|
||||
}
|
||||
|
||||
// UnimplementedDocReaderServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedDocReaderServer struct{}
|
||||
|
||||
func (UnimplementedDocReaderServer) Read(context.Context, *ReadRequest) (*ReadResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Read not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) ReadStream(*ReadRequest, grpc.ServerStreamingServer[ReadStreamResponse]) error {
|
||||
return status.Error(codes.Unimplemented, "method ReadStream not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) ListEngines(context.Context, *ListEnginesRequest) (*ListEnginesResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListEngines not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) PreprocessImage(context.Context, *PreprocessImageRequest) (*PreprocessImageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method PreprocessImage not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) mustEmbedUnimplementedDocReaderServer() {}
|
||||
func (UnimplementedDocReaderServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeDocReaderServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DocReaderServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDocReaderServer interface {
|
||||
mustEmbedUnimplementedDocReaderServer()
|
||||
}
|
||||
|
||||
func RegisterDocReaderServer(s grpc.ServiceRegistrar, srv DocReaderServer) {
|
||||
// If the following call panics, it indicates UnimplementedDocReaderServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&DocReader_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _DocReader_Read_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReadRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DocReaderServer).Read(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: DocReader_Read_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DocReaderServer).Read(ctx, req.(*ReadRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DocReader_ReadStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(ReadRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(DocReaderServer).ReadStream(m, &grpc.GenericServerStream[ReadRequest, ReadStreamResponse]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type DocReader_ReadStreamServer = grpc.ServerStreamingServer[ReadStreamResponse]
|
||||
|
||||
func _DocReader_ListEngines_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListEnginesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DocReaderServer).ListEngines(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: DocReader_ListEngines_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DocReaderServer).ListEngines(ctx, req.(*ListEnginesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DocReader_PreprocessImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PreprocessImageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DocReaderServer).PreprocessImage(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: DocReader_PreprocessImage_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DocReaderServer).PreprocessImage(ctx, req.(*PreprocessImageRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// DocReader_ServiceDesc is the grpc.ServiceDesc for DocReader service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var DocReader_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "docreader.DocReader",
|
||||
HandlerType: (*DocReaderServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Read",
|
||||
Handler: _DocReader_Read_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListEngines",
|
||||
Handler: _DocReader_ListEngines_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PreprocessImage",
|
||||
Handler: _DocReader_PreprocessImage_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ReadStream",
|
||||
Handler: _DocReader_ReadStream_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "docreader.proto",
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# NO CHECKED-IN PROTOBUF GENCODE
|
||||
# source: docreader.proto
|
||||
# Protobuf Python Version: 6.31.1
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import runtime_version as _runtime_version
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
_runtime_version.ValidateProtobufRuntimeVersion(
|
||||
_runtime_version.Domain.PUBLIC,
|
||||
6,
|
||||
31,
|
||||
1,
|
||||
'',
|
||||
'docreader.proto'
|
||||
)
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0f\x64ocreader.proto\x12\tdocreader\"\'\n\x16PreprocessImageRequest\x12\r\n\x05image\x18\x01 \x01(\x0c\"\xa1\x01\n\x17PreprocessImageResponse\x12\r\n\x05image\x18\x01 \x01(\x0c\x12\x17\n\x0f\x66\x61llback_needed\x18\x02 \x01(\x08\x12\r\n\x05theta\x18\x03 \x01(\x02\x12\x10\n\x08residual\x18\x04 \x01(\x02\x12\x0c\n\x04\x66lip\x18\x05 \x01(\x08\x12\x0f\n\x07n_boxes\x18\x06 \x01(\x05\x12\x0e\n\x06n_kept\x18\x07 \x01(\x05\x12\x0e\n\x06status\x18\x08 \x01(\t\"\xba\x01\n\nReadConfig\x12\x15\n\rparser_engine\x18\x01 \x01(\t\x12Q\n\x17parser_engine_overrides\x18\x02 \x03(\x0b\x32\x30.docreader.ReadConfig.ParserEngineOverridesEntry\x1a<\n\x1aParserEngineOverridesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01J\x04\x08\x03\x10\x04\"\xa0\x01\n\x0bReadRequest\x12\x14\n\x0c\x66ile_content\x18\x01 \x01(\x0c\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x11\n\tfile_type\x18\x03 \x01(\t\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\r\n\x05title\x18\x05 \x01(\t\x12%\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x15.docreader.ReadConfig\x12\x12\n\nrequest_id\x18\x07 \x01(\t\"n\n\x08ImageRef\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\x12\x14\n\x0coriginal_ref\x18\x02 \x01(\t\x12\x11\n\tmime_type\x18\x03 \x01(\t\x12\x13\n\x0bstorage_key\x18\x04 \x01(\t\x12\x12\n\nimage_data\x18\x05 \x01(\x0c\"?\n\x0bSourceBlock\x12\r\n\x05start\x18\x01 \x01(\r\x12\x0b\n\x03\x65nd\x18\x02 \x01(\r\x12\x14\n\x0clocator_json\x18\x03 \x01(\t\"\x91\x02\n\x0cReadResponse\x12\x18\n\x10markdown_content\x18\x01 \x01(\t\x12\'\n\nimage_refs\x18\x02 \x03(\x0b\x32\x13.docreader.ImageRef\x12\x16\n\x0eimage_dir_path\x18\x03 \x01(\t\x12\x37\n\x08metadata\x18\x04 \x03(\x0b\x32%.docreader.ReadResponse.MetadataEntry\x12\r\n\x05\x65rror\x18\x05 \x01(\t\x12-\n\rsource_blocks\x18\x06 \x03(\x0b\x32\x16.docreader.SourceBlock\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x81\x02\n\x0eReadStreamMeta\x12\x18\n\x10markdown_content\x18\x01 \x01(\t\x12\x16\n\x0eimage_dir_path\x18\x02 \x01(\t\x12\x39\n\x08metadata\x18\x03 \x03(\x0b\x32\'.docreader.ReadStreamMeta.MetadataEntry\x12\r\n\x05\x65rror\x18\x04 \x01(\t\x12\x13\n\x0bimage_count\x18\x05 \x01(\r\x12-\n\rsource_blocks\x18\x06 \x03(\x0b\x32\x16.docreader.SourceBlock\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"p\n\x12ReadStreamResponse\x12)\n\x04meta\x18\x01 \x01(\x0b\x32\x19.docreader.ReadStreamMetaH\x00\x12$\n\x05image\x18\x02 \x01(\x0b\x32\x13.docreader.ImageRefH\x00\x42\t\n\x07payload\"\x9a\x01\n\x12ListEnginesRequest\x12L\n\x10\x63onfig_overrides\x18\x01 \x03(\x0b\x32\x32.docreader.ListEnginesRequest.ConfigOverridesEntry\x1a\x36\n\x14\x43onfigOverridesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"x\n\x10ParserEngineInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x12\n\nfile_types\x18\x03 \x03(\t\x12\x11\n\tavailable\x18\x04 \x01(\x08\x12\x1a\n\x12unavailable_reason\x18\x05 \x01(\t\"C\n\x13ListEnginesResponse\x12,\n\x07\x65ngines\x18\x01 \x03(\x0b\x32\x1b.docreader.ParserEngineInfo2\xbb\x02\n\tDocReader\x12\x39\n\x04Read\x12\x16.docreader.ReadRequest\x1a\x17.docreader.ReadResponse\"\x00\x12G\n\nReadStream\x12\x16.docreader.ReadRequest\x1a\x1d.docreader.ReadStreamResponse\"\x00\x30\x01\x12N\n\x0bListEngines\x12\x1d.docreader.ListEnginesRequest\x1a\x1e.docreader.ListEnginesResponse\"\x00\x12Z\n\x0fPreprocessImage\x12!.docreader.PreprocessImageRequest\x1a\".docreader.PreprocessImageResponse\"\x00\x42\x35Z3github.com/Tencent/WeKnora/internal/docreader/protob\x06proto3')
|
||||
|
||||
_globals = globals()
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'docreader_pb2', _globals)
|
||||
if not _descriptor._USE_C_DESCRIPTORS:
|
||||
_globals['DESCRIPTOR']._loaded_options = None
|
||||
_globals['DESCRIPTOR']._serialized_options = b'Z3github.com/Tencent/WeKnora/internal/docreader/proto'
|
||||
_globals['_READCONFIG_PARSERENGINEOVERRIDESENTRY']._loaded_options = None
|
||||
_globals['_READCONFIG_PARSERENGINEOVERRIDESENTRY']._serialized_options = b'8\001'
|
||||
_globals['_READRESPONSE_METADATAENTRY']._loaded_options = None
|
||||
_globals['_READRESPONSE_METADATAENTRY']._serialized_options = b'8\001'
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._loaded_options = None
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._serialized_options = b'8\001'
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._loaded_options = None
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_options = b'8\001'
|
||||
_globals['_PREPROCESSIMAGEREQUEST']._serialized_start=30
|
||||
_globals['_PREPROCESSIMAGEREQUEST']._serialized_end=69
|
||||
_globals['_PREPROCESSIMAGERESPONSE']._serialized_start=72
|
||||
_globals['_PREPROCESSIMAGERESPONSE']._serialized_end=233
|
||||
_globals['_READCONFIG']._serialized_start=236
|
||||
_globals['_READCONFIG']._serialized_end=422
|
||||
_globals['_READCONFIG_PARSERENGINEOVERRIDESENTRY']._serialized_start=356
|
||||
_globals['_READCONFIG_PARSERENGINEOVERRIDESENTRY']._serialized_end=416
|
||||
_globals['_READREQUEST']._serialized_start=425
|
||||
_globals['_READREQUEST']._serialized_end=585
|
||||
_globals['_IMAGEREF']._serialized_start=587
|
||||
_globals['_IMAGEREF']._serialized_end=697
|
||||
_globals['_SOURCEBLOCK']._serialized_start=699
|
||||
_globals['_SOURCEBLOCK']._serialized_end=762
|
||||
_globals['_READRESPONSE']._serialized_start=765
|
||||
_globals['_READRESPONSE']._serialized_end=1038
|
||||
_globals['_READRESPONSE_METADATAENTRY']._serialized_start=991
|
||||
_globals['_READRESPONSE_METADATAENTRY']._serialized_end=1038
|
||||
_globals['_READSTREAMMETA']._serialized_start=1041
|
||||
_globals['_READSTREAMMETA']._serialized_end=1298
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._serialized_start=991
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._serialized_end=1038
|
||||
_globals['_READSTREAMRESPONSE']._serialized_start=1300
|
||||
_globals['_READSTREAMRESPONSE']._serialized_end=1412
|
||||
_globals['_LISTENGINESREQUEST']._serialized_start=1415
|
||||
_globals['_LISTENGINESREQUEST']._serialized_end=1569
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_start=1515
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_end=1569
|
||||
_globals['_PARSERENGINEINFO']._serialized_start=1571
|
||||
_globals['_PARSERENGINEINFO']._serialized_end=1691
|
||||
_globals['_LISTENGINESRESPONSE']._serialized_start=1693
|
||||
_globals['_LISTENGINESRESPONSE']._serialized_end=1760
|
||||
_globals['_DOCREADER']._serialized_start=1763
|
||||
_globals['_DOCREADER']._serialized_end=2078
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
@@ -0,0 +1,177 @@
|
||||
from google.protobuf.internal import containers as _containers
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from collections.abc import Iterable as _Iterable, Mapping as _Mapping
|
||||
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
|
||||
|
||||
DESCRIPTOR: _descriptor.FileDescriptor
|
||||
|
||||
class PreprocessImageRequest(_message.Message):
|
||||
__slots__ = ("image",)
|
||||
IMAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
image: bytes
|
||||
def __init__(self, image: _Optional[bytes] = ...) -> None: ...
|
||||
|
||||
class PreprocessImageResponse(_message.Message):
|
||||
__slots__ = ("image", "fallback_needed", "theta", "residual", "flip", "n_boxes", "n_kept", "status")
|
||||
IMAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
FALLBACK_NEEDED_FIELD_NUMBER: _ClassVar[int]
|
||||
THETA_FIELD_NUMBER: _ClassVar[int]
|
||||
RESIDUAL_FIELD_NUMBER: _ClassVar[int]
|
||||
FLIP_FIELD_NUMBER: _ClassVar[int]
|
||||
N_BOXES_FIELD_NUMBER: _ClassVar[int]
|
||||
N_KEPT_FIELD_NUMBER: _ClassVar[int]
|
||||
STATUS_FIELD_NUMBER: _ClassVar[int]
|
||||
image: bytes
|
||||
fallback_needed: bool
|
||||
theta: float
|
||||
residual: float
|
||||
flip: bool
|
||||
n_boxes: int
|
||||
n_kept: int
|
||||
status: str
|
||||
def __init__(self, image: _Optional[bytes] = ..., fallback_needed: bool = ..., theta: _Optional[float] = ..., residual: _Optional[float] = ..., flip: bool = ..., n_boxes: _Optional[int] = ..., n_kept: _Optional[int] = ..., status: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class ReadConfig(_message.Message):
|
||||
__slots__ = ("parser_engine", "parser_engine_overrides")
|
||||
class ParserEngineOverridesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
PARSER_ENGINE_FIELD_NUMBER: _ClassVar[int]
|
||||
PARSER_ENGINE_OVERRIDES_FIELD_NUMBER: _ClassVar[int]
|
||||
parser_engine: str
|
||||
parser_engine_overrides: _containers.ScalarMap[str, str]
|
||||
def __init__(self, parser_engine: _Optional[str] = ..., parser_engine_overrides: _Optional[_Mapping[str, str]] = ...) -> None: ...
|
||||
|
||||
class ReadRequest(_message.Message):
|
||||
__slots__ = ("file_content", "file_name", "file_type", "url", "title", "config", "request_id")
|
||||
FILE_CONTENT_FIELD_NUMBER: _ClassVar[int]
|
||||
FILE_NAME_FIELD_NUMBER: _ClassVar[int]
|
||||
FILE_TYPE_FIELD_NUMBER: _ClassVar[int]
|
||||
URL_FIELD_NUMBER: _ClassVar[int]
|
||||
TITLE_FIELD_NUMBER: _ClassVar[int]
|
||||
CONFIG_FIELD_NUMBER: _ClassVar[int]
|
||||
REQUEST_ID_FIELD_NUMBER: _ClassVar[int]
|
||||
file_content: bytes
|
||||
file_name: str
|
||||
file_type: str
|
||||
url: str
|
||||
title: str
|
||||
config: ReadConfig
|
||||
request_id: str
|
||||
def __init__(self, file_content: _Optional[bytes] = ..., file_name: _Optional[str] = ..., file_type: _Optional[str] = ..., url: _Optional[str] = ..., title: _Optional[str] = ..., config: _Optional[_Union[ReadConfig, _Mapping]] = ..., request_id: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class ImageRef(_message.Message):
|
||||
__slots__ = ("filename", "original_ref", "mime_type", "storage_key", "image_data")
|
||||
FILENAME_FIELD_NUMBER: _ClassVar[int]
|
||||
ORIGINAL_REF_FIELD_NUMBER: _ClassVar[int]
|
||||
MIME_TYPE_FIELD_NUMBER: _ClassVar[int]
|
||||
STORAGE_KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_DATA_FIELD_NUMBER: _ClassVar[int]
|
||||
filename: str
|
||||
original_ref: str
|
||||
mime_type: str
|
||||
storage_key: str
|
||||
image_data: bytes
|
||||
def __init__(self, filename: _Optional[str] = ..., original_ref: _Optional[str] = ..., mime_type: _Optional[str] = ..., storage_key: _Optional[str] = ..., image_data: _Optional[bytes] = ...) -> None: ...
|
||||
|
||||
class SourceBlock(_message.Message):
|
||||
__slots__ = ("start", "end", "locator_json")
|
||||
START_FIELD_NUMBER: _ClassVar[int]
|
||||
END_FIELD_NUMBER: _ClassVar[int]
|
||||
LOCATOR_JSON_FIELD_NUMBER: _ClassVar[int]
|
||||
start: int
|
||||
end: int
|
||||
locator_json: str
|
||||
def __init__(self, start: _Optional[int] = ..., end: _Optional[int] = ..., locator_json: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class ReadResponse(_message.Message):
|
||||
__slots__ = ("markdown_content", "image_refs", "image_dir_path", "metadata", "error", "source_blocks")
|
||||
class MetadataEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
MARKDOWN_CONTENT_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_REFS_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_DIR_PATH_FIELD_NUMBER: _ClassVar[int]
|
||||
METADATA_FIELD_NUMBER: _ClassVar[int]
|
||||
ERROR_FIELD_NUMBER: _ClassVar[int]
|
||||
SOURCE_BLOCKS_FIELD_NUMBER: _ClassVar[int]
|
||||
markdown_content: str
|
||||
image_refs: _containers.RepeatedCompositeFieldContainer[ImageRef]
|
||||
image_dir_path: str
|
||||
metadata: _containers.ScalarMap[str, str]
|
||||
error: str
|
||||
source_blocks: _containers.RepeatedCompositeFieldContainer[SourceBlock]
|
||||
def __init__(self, markdown_content: _Optional[str] = ..., image_refs: _Optional[_Iterable[_Union[ImageRef, _Mapping]]] = ..., image_dir_path: _Optional[str] = ..., metadata: _Optional[_Mapping[str, str]] = ..., error: _Optional[str] = ..., source_blocks: _Optional[_Iterable[_Union[SourceBlock, _Mapping]]] = ...) -> None: ...
|
||||
|
||||
class ReadStreamMeta(_message.Message):
|
||||
__slots__ = ("markdown_content", "image_dir_path", "metadata", "error", "image_count", "source_blocks")
|
||||
class MetadataEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
MARKDOWN_CONTENT_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_DIR_PATH_FIELD_NUMBER: _ClassVar[int]
|
||||
METADATA_FIELD_NUMBER: _ClassVar[int]
|
||||
ERROR_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_COUNT_FIELD_NUMBER: _ClassVar[int]
|
||||
SOURCE_BLOCKS_FIELD_NUMBER: _ClassVar[int]
|
||||
markdown_content: str
|
||||
image_dir_path: str
|
||||
metadata: _containers.ScalarMap[str, str]
|
||||
error: str
|
||||
image_count: int
|
||||
source_blocks: _containers.RepeatedCompositeFieldContainer[SourceBlock]
|
||||
def __init__(self, markdown_content: _Optional[str] = ..., image_dir_path: _Optional[str] = ..., metadata: _Optional[_Mapping[str, str]] = ..., error: _Optional[str] = ..., image_count: _Optional[int] = ..., source_blocks: _Optional[_Iterable[_Union[SourceBlock, _Mapping]]] = ...) -> None: ...
|
||||
|
||||
class ReadStreamResponse(_message.Message):
|
||||
__slots__ = ("meta", "image")
|
||||
META_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
meta: ReadStreamMeta
|
||||
image: ImageRef
|
||||
def __init__(self, meta: _Optional[_Union[ReadStreamMeta, _Mapping]] = ..., image: _Optional[_Union[ImageRef, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class ListEnginesRequest(_message.Message):
|
||||
__slots__ = ("config_overrides",)
|
||||
class ConfigOverridesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
CONFIG_OVERRIDES_FIELD_NUMBER: _ClassVar[int]
|
||||
config_overrides: _containers.ScalarMap[str, str]
|
||||
def __init__(self, config_overrides: _Optional[_Mapping[str, str]] = ...) -> None: ...
|
||||
|
||||
class ParserEngineInfo(_message.Message):
|
||||
__slots__ = ("name", "description", "file_types", "available", "unavailable_reason")
|
||||
NAME_FIELD_NUMBER: _ClassVar[int]
|
||||
DESCRIPTION_FIELD_NUMBER: _ClassVar[int]
|
||||
FILE_TYPES_FIELD_NUMBER: _ClassVar[int]
|
||||
AVAILABLE_FIELD_NUMBER: _ClassVar[int]
|
||||
UNAVAILABLE_REASON_FIELD_NUMBER: _ClassVar[int]
|
||||
name: str
|
||||
description: str
|
||||
file_types: _containers.RepeatedScalarFieldContainer[str]
|
||||
available: bool
|
||||
unavailable_reason: str
|
||||
def __init__(self, name: _Optional[str] = ..., description: _Optional[str] = ..., file_types: _Optional[_Iterable[str]] = ..., available: bool = ..., unavailable_reason: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class ListEnginesResponse(_message.Message):
|
||||
__slots__ = ("engines",)
|
||||
ENGINES_FIELD_NUMBER: _ClassVar[int]
|
||||
engines: _containers.RepeatedCompositeFieldContainer[ParserEngineInfo]
|
||||
def __init__(self, engines: _Optional[_Iterable[_Union[ParserEngineInfo, _Mapping]]] = ...) -> None: ...
|
||||
@@ -0,0 +1,238 @@
|
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
import warnings
|
||||
|
||||
from docreader.proto import docreader_pb2 as docreader__pb2
|
||||
|
||||
GRPC_GENERATED_VERSION = '1.80.0'
|
||||
GRPC_VERSION = grpc.__version__
|
||||
_version_not_supported = False
|
||||
|
||||
try:
|
||||
from grpc._utilities import first_version_is_lower
|
||||
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
||||
except ImportError:
|
||||
_version_not_supported = True
|
||||
|
||||
if _version_not_supported:
|
||||
raise RuntimeError(
|
||||
f'The grpc package installed is at version {GRPC_VERSION},'
|
||||
+ ' but the generated code in docreader_pb2_grpc.py depends on'
|
||||
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
||||
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
||||
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
||||
)
|
||||
|
||||
|
||||
class DocReaderStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.Read = channel.unary_unary(
|
||||
'/docreader.DocReader/Read',
|
||||
request_serializer=docreader__pb2.ReadRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ReadResponse.FromString,
|
||||
_registered_method=True)
|
||||
self.ReadStream = channel.unary_stream(
|
||||
'/docreader.DocReader/ReadStream',
|
||||
request_serializer=docreader__pb2.ReadRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ReadStreamResponse.FromString,
|
||||
_registered_method=True)
|
||||
self.ListEngines = channel.unary_unary(
|
||||
'/docreader.DocReader/ListEngines',
|
||||
request_serializer=docreader__pb2.ListEnginesRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ListEnginesResponse.FromString,
|
||||
_registered_method=True)
|
||||
self.PreprocessImage = channel.unary_unary(
|
||||
'/docreader.DocReader/PreprocessImage',
|
||||
request_serializer=docreader__pb2.PreprocessImageRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.PreprocessImageResponse.FromString,
|
||||
_registered_method=True)
|
||||
|
||||
|
||||
class DocReaderServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def Read(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReadStream(self, request, context):
|
||||
"""ReadStream is the streaming counterpart of Read. It first emits one
|
||||
ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
error), then emits one message per image. This keeps every gRPC message
|
||||
small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
with bounded memory on both ends.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ListEngines(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def PreprocessImage(self, request, context):
|
||||
"""PreprocessImage straightens and crops a photographed page so that OCR sees
|
||||
an upright, content-tight image. The caller sends the raw photograph and
|
||||
receives either the corrected page or a verdict that this input is not a
|
||||
page worth correcting — never an error for "not correctable", because the
|
||||
caller's fallback (use the original bytes) is a normal outcome rather than
|
||||
a failure to report.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_DocReaderServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'Read': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Read,
|
||||
request_deserializer=docreader__pb2.ReadRequest.FromString,
|
||||
response_serializer=docreader__pb2.ReadResponse.SerializeToString,
|
||||
),
|
||||
'ReadStream': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.ReadStream,
|
||||
request_deserializer=docreader__pb2.ReadRequest.FromString,
|
||||
response_serializer=docreader__pb2.ReadStreamResponse.SerializeToString,
|
||||
),
|
||||
'ListEngines': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ListEngines,
|
||||
request_deserializer=docreader__pb2.ListEnginesRequest.FromString,
|
||||
response_serializer=docreader__pb2.ListEnginesResponse.SerializeToString,
|
||||
),
|
||||
'PreprocessImage': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.PreprocessImage,
|
||||
request_deserializer=docreader__pb2.PreprocessImageRequest.FromString,
|
||||
response_serializer=docreader__pb2.PreprocessImageResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'docreader.DocReader', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
server.add_registered_method_handlers('docreader.DocReader', rpc_method_handlers)
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class DocReader(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def Read(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(
|
||||
request,
|
||||
target,
|
||||
'/docreader.DocReader/Read',
|
||||
docreader__pb2.ReadRequest.SerializeToString,
|
||||
docreader__pb2.ReadResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
||||
@staticmethod
|
||||
def ReadStream(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_stream(
|
||||
request,
|
||||
target,
|
||||
'/docreader.DocReader/ReadStream',
|
||||
docreader__pb2.ReadRequest.SerializeToString,
|
||||
docreader__pb2.ReadStreamResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
||||
@staticmethod
|
||||
def ListEngines(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(
|
||||
request,
|
||||
target,
|
||||
'/docreader.DocReader/ListEngines',
|
||||
docreader__pb2.ListEnginesRequest.SerializeToString,
|
||||
docreader__pb2.ListEnginesResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
||||
@staticmethod
|
||||
def PreprocessImage(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(
|
||||
request,
|
||||
target,
|
||||
'/docreader.DocReader/PreprocessImage',
|
||||
docreader__pb2.PreprocessImageRequest.SerializeToString,
|
||||
docreader__pb2.PreprocessImageResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
Reference in new issue
Block a user