chore(docreader): 重新组织模块文件
This commit is contained in:
@@ -0,0 +1,819 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.6
|
||||
// protoc v5.29.3
|
||||
// source: docreader.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 对象存储提供方
|
||||
type StorageProvider int32
|
||||
|
||||
const (
|
||||
StorageProvider_STORAGE_PROVIDER_UNSPECIFIED StorageProvider = 0
|
||||
StorageProvider_COS StorageProvider = 1 // 腾讯云 COS
|
||||
StorageProvider_MINIO StorageProvider = 2 // MinIO/S3 兼容
|
||||
)
|
||||
|
||||
// Enum value maps for StorageProvider.
|
||||
var (
|
||||
StorageProvider_name = map[int32]string{
|
||||
0: "STORAGE_PROVIDER_UNSPECIFIED",
|
||||
1: "COS",
|
||||
2: "MINIO",
|
||||
}
|
||||
StorageProvider_value = map[string]int32{
|
||||
"STORAGE_PROVIDER_UNSPECIFIED": 0,
|
||||
"COS": 1,
|
||||
"MINIO": 2,
|
||||
}
|
||||
)
|
||||
|
||||
func (x StorageProvider) Enum() *StorageProvider {
|
||||
p := new(StorageProvider)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x StorageProvider) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (StorageProvider) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_docreader_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (StorageProvider) Type() protoreflect.EnumType {
|
||||
return &file_docreader_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x StorageProvider) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use StorageProvider.Descriptor instead.
|
||||
func (StorageProvider) EnumDescriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
// 通用对象存储配置,兼容 COS 与 MinIO
|
||||
type StorageConfig struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Provider StorageProvider `protobuf:"varint,1,opt,name=provider,proto3,enum=docreader.StorageProvider" json:"provider,omitempty"` // 存储提供方
|
||||
Region string `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"` // 区域(COS 使用)
|
||||
BucketName string `protobuf:"bytes,3,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` // 桶名
|
||||
AccessKeyId string `protobuf:"bytes,4,opt,name=access_key_id,json=accessKeyId,proto3" json:"access_key_id,omitempty"` // 访问密钥 ID(MinIO/S3 使用)
|
||||
SecretAccessKey string `protobuf:"bytes,5,opt,name=secret_access_key,json=secretAccessKey,proto3" json:"secret_access_key,omitempty"` // 访问密钥 Secret(MinIO/S3 使用)
|
||||
AppId string `protobuf:"bytes,6,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` // 应用 ID(COS 使用)
|
||||
PathPrefix string `protobuf:"bytes,7,opt,name=path_prefix,json=pathPrefix,proto3" json:"path_prefix,omitempty"` // 路径前缀
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *StorageConfig) Reset() {
|
||||
*x = StorageConfig{}
|
||||
mi := &file_docreader_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *StorageConfig) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StorageConfig) ProtoMessage() {}
|
||||
|
||||
func (x *StorageConfig) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use StorageConfig.ProtoReflect.Descriptor instead.
|
||||
func (*StorageConfig) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetProvider() StorageProvider {
|
||||
if x != nil {
|
||||
return x.Provider
|
||||
}
|
||||
return StorageProvider_STORAGE_PROVIDER_UNSPECIFIED
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetRegion() string {
|
||||
if x != nil {
|
||||
return x.Region
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetBucketName() string {
|
||||
if x != nil {
|
||||
return x.BucketName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetAccessKeyId() string {
|
||||
if x != nil {
|
||||
return x.AccessKeyId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetSecretAccessKey() string {
|
||||
if x != nil {
|
||||
return x.SecretAccessKey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetAppId() string {
|
||||
if x != nil {
|
||||
return x.AppId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StorageConfig) GetPathPrefix() string {
|
||||
if x != nil {
|
||||
return x.PathPrefix
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// VLM 配置
|
||||
type VLMConfig struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ModelName string `protobuf:"bytes,1,opt,name=model_name,json=modelName,proto3" json:"model_name,omitempty"` // VLM Model Name
|
||||
BaseUrl string `protobuf:"bytes,2,opt,name=base_url,json=baseUrl,proto3" json:"base_url,omitempty"` // VLM Base URL
|
||||
ApiKey string `protobuf:"bytes,3,opt,name=api_key,json=apiKey,proto3" json:"api_key,omitempty"` // VLM API Key
|
||||
InterfaceType string `protobuf:"bytes,4,opt,name=interface_type,json=interfaceType,proto3" json:"interface_type,omitempty"` // VLM Interface Type: "ollama" or "openai"
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *VLMConfig) Reset() {
|
||||
*x = VLMConfig{}
|
||||
mi := &file_docreader_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *VLMConfig) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*VLMConfig) ProtoMessage() {}
|
||||
|
||||
func (x *VLMConfig) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use VLMConfig.ProtoReflect.Descriptor instead.
|
||||
func (*VLMConfig) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *VLMConfig) GetModelName() string {
|
||||
if x != nil {
|
||||
return x.ModelName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *VLMConfig) GetBaseUrl() string {
|
||||
if x != nil {
|
||||
return x.BaseUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *VLMConfig) GetApiKey() string {
|
||||
if x != nil {
|
||||
return x.ApiKey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *VLMConfig) GetInterfaceType() string {
|
||||
if x != nil {
|
||||
return x.InterfaceType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ReadConfig struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ChunkSize int32 `protobuf:"varint,1,opt,name=chunk_size,json=chunkSize,proto3" json:"chunk_size,omitempty"` // 分块大小
|
||||
ChunkOverlap int32 `protobuf:"varint,2,opt,name=chunk_overlap,json=chunkOverlap,proto3" json:"chunk_overlap,omitempty"` // 分块重叠
|
||||
Separators []string `protobuf:"bytes,3,rep,name=separators,proto3" json:"separators,omitempty"` // 分隔符
|
||||
EnableMultimodal bool `protobuf:"varint,4,opt,name=enable_multimodal,json=enableMultimodal,proto3" json:"enable_multimodal,omitempty"` // 多模态处理
|
||||
StorageConfig *StorageConfig `protobuf:"bytes,5,opt,name=storage_config,json=storageConfig,proto3" json:"storage_config,omitempty"` // 对象存储配置(通用)
|
||||
VlmConfig *VLMConfig `protobuf:"bytes,6,opt,name=vlm_config,json=vlmConfig,proto3" json:"vlm_config,omitempty"` // VLM 配置
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReadConfig) Reset() {
|
||||
*x = ReadConfig{}
|
||||
mi := &file_docreader_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReadConfig) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadConfig) ProtoMessage() {}
|
||||
|
||||
func (x *ReadConfig) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadConfig.ProtoReflect.Descriptor instead.
|
||||
func (*ReadConfig) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ReadConfig) GetChunkSize() int32 {
|
||||
if x != nil {
|
||||
return x.ChunkSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ReadConfig) GetChunkOverlap() int32 {
|
||||
if x != nil {
|
||||
return x.ChunkOverlap
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ReadConfig) GetSeparators() []string {
|
||||
if x != nil {
|
||||
return x.Separators
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadConfig) GetEnableMultimodal() bool {
|
||||
if x != nil {
|
||||
return x.EnableMultimodal
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *ReadConfig) GetStorageConfig() *StorageConfig {
|
||||
if x != nil {
|
||||
return x.StorageConfig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadConfig) GetVlmConfig() *VLMConfig {
|
||||
if x != nil {
|
||||
return x.VlmConfig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 从文件读取文档请求
|
||||
type ReadFromFileRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // 文件内容
|
||||
FileName string `protobuf:"bytes,2,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` // 文件名
|
||||
FileType string `protobuf:"bytes,3,opt,name=file_type,json=fileType,proto3" json:"file_type,omitempty"` // 文件类型
|
||||
ReadConfig *ReadConfig `protobuf:"bytes,4,opt,name=read_config,json=readConfig,proto3" json:"read_config,omitempty"`
|
||||
RequestId string `protobuf:"bytes,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) Reset() {
|
||||
*x = ReadFromFileRequest{}
|
||||
mi := &file_docreader_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadFromFileRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ReadFromFileRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadFromFileRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ReadFromFileRequest) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) GetFileContent() []byte {
|
||||
if x != nil {
|
||||
return x.FileContent
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) GetFileName() string {
|
||||
if x != nil {
|
||||
return x.FileName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) GetFileType() string {
|
||||
if x != nil {
|
||||
return x.FileType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) GetReadConfig() *ReadConfig {
|
||||
if x != nil {
|
||||
return x.ReadConfig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadFromFileRequest) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// 从URL读取文档请求
|
||||
type ReadFromURLRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // 文档URL
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` // 标题
|
||||
ReadConfig *ReadConfig `protobuf:"bytes,3,opt,name=read_config,json=readConfig,proto3" json:"read_config,omitempty"`
|
||||
RequestId string `protobuf:"bytes,4,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReadFromURLRequest) Reset() {
|
||||
*x = ReadFromURLRequest{}
|
||||
mi := &file_docreader_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReadFromURLRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadFromURLRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ReadFromURLRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadFromURLRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ReadFromURLRequest) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ReadFromURLRequest) GetUrl() string {
|
||||
if x != nil {
|
||||
return x.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadFromURLRequest) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadFromURLRequest) GetReadConfig() *ReadConfig {
|
||||
if x != nil {
|
||||
return x.ReadConfig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadFromURLRequest) GetRequestId() string {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// 图片信息
|
||||
type Image struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // 图片URL
|
||||
Caption string `protobuf:"bytes,2,opt,name=caption,proto3" json:"caption,omitempty"` // 图片描述
|
||||
OcrText string `protobuf:"bytes,3,opt,name=ocr_text,json=ocrText,proto3" json:"ocr_text,omitempty"` // OCR提取的文本内容
|
||||
OriginalUrl string `protobuf:"bytes,4,opt,name=original_url,json=originalUrl,proto3" json:"original_url,omitempty"` // 原始图片URL
|
||||
Start int32 `protobuf:"varint,5,opt,name=start,proto3" json:"start,omitempty"` // 图片在文本中的开始位置
|
||||
End int32 `protobuf:"varint,6,opt,name=end,proto3" json:"end,omitempty"` // 图片在文本中的结束位置
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Image) Reset() {
|
||||
*x = Image{}
|
||||
mi := &file_docreader_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Image) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Image) ProtoMessage() {}
|
||||
|
||||
func (x *Image) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Image.ProtoReflect.Descriptor instead.
|
||||
func (*Image) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *Image) GetUrl() string {
|
||||
if x != nil {
|
||||
return x.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Image) GetCaption() string {
|
||||
if x != nil {
|
||||
return x.Caption
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Image) GetOcrText() string {
|
||||
if x != nil {
|
||||
return x.OcrText
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Image) GetOriginalUrl() string {
|
||||
if x != nil {
|
||||
return x.OriginalUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Image) GetStart() int32 {
|
||||
if x != nil {
|
||||
return x.Start
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Image) GetEnd() int32 {
|
||||
if x != nil {
|
||||
return x.End
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Chunk struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"` // 块内容
|
||||
Seq int32 `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"` // 块在文档中的次序
|
||||
Start int32 `protobuf:"varint,3,opt,name=start,proto3" json:"start,omitempty"` // 块在文档中的起始位置
|
||||
End int32 `protobuf:"varint,4,opt,name=end,proto3" json:"end,omitempty"` // 块在文档中的结束位置
|
||||
Images []*Image `protobuf:"bytes,5,rep,name=images,proto3" json:"images,omitempty"` // 块中包含的图片信息
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Chunk) Reset() {
|
||||
*x = Chunk{}
|
||||
mi := &file_docreader_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Chunk) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Chunk) ProtoMessage() {}
|
||||
|
||||
func (x *Chunk) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Chunk.ProtoReflect.Descriptor instead.
|
||||
func (*Chunk) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *Chunk) GetContent() string {
|
||||
if x != nil {
|
||||
return x.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Chunk) GetSeq() int32 {
|
||||
if x != nil {
|
||||
return x.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Chunk) GetStart() int32 {
|
||||
if x != nil {
|
||||
return x.Start
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Chunk) GetEnd() int32 {
|
||||
if x != nil {
|
||||
return x.End
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Chunk) GetImages() []*Image {
|
||||
if x != nil {
|
||||
return x.Images
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 从URL读取文档响应
|
||||
type ReadResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Chunks []*Chunk `protobuf:"bytes,1,rep,name=chunks,proto3" json:"chunks,omitempty"` // 文档分块
|
||||
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` // 错误信息
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReadResponse) Reset() {
|
||||
*x = ReadResponse{}
|
||||
mi := &file_docreader_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReadResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ReadResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ReadResponse) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *ReadResponse) GetChunks() []*Chunk {
|
||||
if x != nil {
|
||||
return x.Chunks
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadResponse) GetError() string {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_docreader_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_docreader_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x0fdocreader.proto\x12\tdocreader\"\x88\x02\n" +
|
||||
"\rStorageConfig\x126\n" +
|
||||
"\bprovider\x18\x01 \x01(\x0e2\x1a.docreader.StorageProviderR\bprovider\x12\x16\n" +
|
||||
"\x06region\x18\x02 \x01(\tR\x06region\x12\x1f\n" +
|
||||
"\vbucket_name\x18\x03 \x01(\tR\n" +
|
||||
"bucketName\x12\"\n" +
|
||||
"\raccess_key_id\x18\x04 \x01(\tR\vaccessKeyId\x12*\n" +
|
||||
"\x11secret_access_key\x18\x05 \x01(\tR\x0fsecretAccessKey\x12\x15\n" +
|
||||
"\x06app_id\x18\x06 \x01(\tR\x05appId\x12\x1f\n" +
|
||||
"\vpath_prefix\x18\a \x01(\tR\n" +
|
||||
"pathPrefix\"\x85\x01\n" +
|
||||
"\tVLMConfig\x12\x1d\n" +
|
||||
"\n" +
|
||||
"model_name\x18\x01 \x01(\tR\tmodelName\x12\x19\n" +
|
||||
"\bbase_url\x18\x02 \x01(\tR\abaseUrl\x12\x17\n" +
|
||||
"\aapi_key\x18\x03 \x01(\tR\x06apiKey\x12%\n" +
|
||||
"\x0einterface_type\x18\x04 \x01(\tR\rinterfaceType\"\x93\x02\n" +
|
||||
"\n" +
|
||||
"ReadConfig\x12\x1d\n" +
|
||||
"\n" +
|
||||
"chunk_size\x18\x01 \x01(\x05R\tchunkSize\x12#\n" +
|
||||
"\rchunk_overlap\x18\x02 \x01(\x05R\fchunkOverlap\x12\x1e\n" +
|
||||
"\n" +
|
||||
"separators\x18\x03 \x03(\tR\n" +
|
||||
"separators\x12+\n" +
|
||||
"\x11enable_multimodal\x18\x04 \x01(\bR\x10enableMultimodal\x12?\n" +
|
||||
"\x0estorage_config\x18\x05 \x01(\v2\x18.docreader.StorageConfigR\rstorageConfig\x123\n" +
|
||||
"\n" +
|
||||
"vlm_config\x18\x06 \x01(\v2\x14.docreader.VLMConfigR\tvlmConfig\"\xc9\x01\n" +
|
||||
"\x13ReadFromFileRequest\x12!\n" +
|
||||
"\ffile_content\x18\x01 \x01(\fR\vfileContent\x12\x1b\n" +
|
||||
"\tfile_name\x18\x02 \x01(\tR\bfileName\x12\x1b\n" +
|
||||
"\tfile_type\x18\x03 \x01(\tR\bfileType\x126\n" +
|
||||
"\vread_config\x18\x04 \x01(\v2\x15.docreader.ReadConfigR\n" +
|
||||
"readConfig\x12\x1d\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x05 \x01(\tR\trequestId\"\x93\x01\n" +
|
||||
"\x12ReadFromURLRequest\x12\x10\n" +
|
||||
"\x03url\x18\x01 \x01(\tR\x03url\x12\x14\n" +
|
||||
"\x05title\x18\x02 \x01(\tR\x05title\x126\n" +
|
||||
"\vread_config\x18\x03 \x01(\v2\x15.docreader.ReadConfigR\n" +
|
||||
"readConfig\x12\x1d\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x04 \x01(\tR\trequestId\"\x99\x01\n" +
|
||||
"\x05Image\x12\x10\n" +
|
||||
"\x03url\x18\x01 \x01(\tR\x03url\x12\x18\n" +
|
||||
"\acaption\x18\x02 \x01(\tR\acaption\x12\x19\n" +
|
||||
"\bocr_text\x18\x03 \x01(\tR\aocrText\x12!\n" +
|
||||
"\foriginal_url\x18\x04 \x01(\tR\voriginalUrl\x12\x14\n" +
|
||||
"\x05start\x18\x05 \x01(\x05R\x05start\x12\x10\n" +
|
||||
"\x03end\x18\x06 \x01(\x05R\x03end\"\x85\x01\n" +
|
||||
"\x05Chunk\x12\x18\n" +
|
||||
"\acontent\x18\x01 \x01(\tR\acontent\x12\x10\n" +
|
||||
"\x03seq\x18\x02 \x01(\x05R\x03seq\x12\x14\n" +
|
||||
"\x05start\x18\x03 \x01(\x05R\x05start\x12\x10\n" +
|
||||
"\x03end\x18\x04 \x01(\x05R\x03end\x12(\n" +
|
||||
"\x06images\x18\x05 \x03(\v2\x10.docreader.ImageR\x06images\"N\n" +
|
||||
"\fReadResponse\x12(\n" +
|
||||
"\x06chunks\x18\x01 \x03(\v2\x10.docreader.ChunkR\x06chunks\x12\x14\n" +
|
||||
"\x05error\x18\x02 \x01(\tR\x05error*G\n" +
|
||||
"\x0fStorageProvider\x12 \n" +
|
||||
"\x1cSTORAGE_PROVIDER_UNSPECIFIED\x10\x00\x12\a\n" +
|
||||
"\x03COS\x10\x01\x12\t\n" +
|
||||
"\x05MINIO\x10\x022\x9f\x01\n" +
|
||||
"\tDocReader\x12I\n" +
|
||||
"\fReadFromFile\x12\x1e.docreader.ReadFromFileRequest\x1a\x17.docreader.ReadResponse\"\x00\x12G\n" +
|
||||
"\vReadFromURL\x12\x1d.docreader.ReadFromURLRequest\x1a\x17.docreader.ReadResponse\"\x00B5Z3github.com/Tencent/WeKnora/internal/docreader/protob\x06proto3"
|
||||
|
||||
var (
|
||||
file_docreader_proto_rawDescOnce sync.Once
|
||||
file_docreader_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_docreader_proto_rawDescGZIP() []byte {
|
||||
file_docreader_proto_rawDescOnce.Do(func() {
|
||||
file_docreader_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_docreader_proto_rawDesc), len(file_docreader_proto_rawDesc)))
|
||||
})
|
||||
return file_docreader_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_docreader_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_docreader_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_docreader_proto_goTypes = []any{
|
||||
(StorageProvider)(0), // 0: docreader.StorageProvider
|
||||
(*StorageConfig)(nil), // 1: docreader.StorageConfig
|
||||
(*VLMConfig)(nil), // 2: docreader.VLMConfig
|
||||
(*ReadConfig)(nil), // 3: docreader.ReadConfig
|
||||
(*ReadFromFileRequest)(nil), // 4: docreader.ReadFromFileRequest
|
||||
(*ReadFromURLRequest)(nil), // 5: docreader.ReadFromURLRequest
|
||||
(*Image)(nil), // 6: docreader.Image
|
||||
(*Chunk)(nil), // 7: docreader.Chunk
|
||||
(*ReadResponse)(nil), // 8: docreader.ReadResponse
|
||||
}
|
||||
var file_docreader_proto_depIdxs = []int32{
|
||||
0, // 0: docreader.StorageConfig.provider:type_name -> docreader.StorageProvider
|
||||
1, // 1: docreader.ReadConfig.storage_config:type_name -> docreader.StorageConfig
|
||||
2, // 2: docreader.ReadConfig.vlm_config:type_name -> docreader.VLMConfig
|
||||
3, // 3: docreader.ReadFromFileRequest.read_config:type_name -> docreader.ReadConfig
|
||||
3, // 4: docreader.ReadFromURLRequest.read_config:type_name -> docreader.ReadConfig
|
||||
6, // 5: docreader.Chunk.images:type_name -> docreader.Image
|
||||
7, // 6: docreader.ReadResponse.chunks:type_name -> docreader.Chunk
|
||||
4, // 7: docreader.DocReader.ReadFromFile:input_type -> docreader.ReadFromFileRequest
|
||||
5, // 8: docreader.DocReader.ReadFromURL:input_type -> docreader.ReadFromURLRequest
|
||||
8, // 9: docreader.DocReader.ReadFromFile:output_type -> docreader.ReadResponse
|
||||
8, // 10: docreader.DocReader.ReadFromURL:output_type -> docreader.ReadResponse
|
||||
9, // [9:11] is the sub-list for method output_type
|
||||
7, // [7:9] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_docreader_proto_init() }
|
||||
func file_docreader_proto_init() {
|
||||
if File_docreader_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_docreader_proto_rawDesc), len(file_docreader_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_docreader_proto_goTypes,
|
||||
DependencyIndexes: file_docreader_proto_depIdxs,
|
||||
EnumInfos: file_docreader_proto_enumTypes,
|
||||
MessageInfos: file_docreader_proto_msgTypes,
|
||||
}.Build()
|
||||
File_docreader_proto = out.File
|
||||
file_docreader_proto_goTypes = nil
|
||||
file_docreader_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package docreader;
|
||||
|
||||
option go_package = "github.com/Tencent/WeKnora/internal/docreader/proto";
|
||||
|
||||
// 文档读取服务
|
||||
service DocReader {
|
||||
// 从文件读取文档
|
||||
rpc ReadFromFile(ReadFromFileRequest) returns (ReadResponse) {}
|
||||
// 从URL读取文档
|
||||
rpc ReadFromURL(ReadFromURLRequest) returns (ReadResponse) {}
|
||||
}
|
||||
|
||||
// 对象存储提供方
|
||||
enum StorageProvider {
|
||||
STORAGE_PROVIDER_UNSPECIFIED = 0;
|
||||
COS = 1; // 腾讯云 COS
|
||||
MINIO = 2; // MinIO/S3 兼容
|
||||
}
|
||||
|
||||
// 通用对象存储配置,兼容 COS 与 MinIO
|
||||
message StorageConfig {
|
||||
StorageProvider provider = 1; // 存储提供方
|
||||
string region = 2; // 区域(COS 使用)
|
||||
string bucket_name = 3; // 桶名
|
||||
string access_key_id = 4; // 访问密钥 ID(MinIO/S3 使用)
|
||||
string secret_access_key = 5; // 访问密钥 Secret(MinIO/S3 使用)
|
||||
string app_id = 6; // 应用 ID(COS 使用)
|
||||
string path_prefix = 7; // 路径前缀
|
||||
}
|
||||
|
||||
// VLM 配置
|
||||
message VLMConfig {
|
||||
string model_name = 1; // VLM Model Name
|
||||
string base_url = 2; // VLM Base URL
|
||||
string api_key = 3; // VLM API Key
|
||||
string interface_type = 4; // VLM Interface Type: "ollama" or "openai"
|
||||
}
|
||||
|
||||
message ReadConfig {
|
||||
int32 chunk_size = 1; // 分块大小
|
||||
int32 chunk_overlap = 2; // 分块重叠
|
||||
repeated string separators = 3; // 分隔符
|
||||
bool enable_multimodal = 4; // 多模态处理
|
||||
StorageConfig storage_config = 5; // 对象存储配置(通用)
|
||||
VLMConfig vlm_config = 6; // VLM 配置
|
||||
}
|
||||
|
||||
// 从文件读取文档请求
|
||||
message ReadFromFileRequest {
|
||||
bytes file_content = 1; // 文件内容
|
||||
string file_name = 2; // 文件名
|
||||
string file_type = 3; // 文件类型
|
||||
ReadConfig read_config = 4;
|
||||
string request_id = 5;
|
||||
}
|
||||
|
||||
// 从URL读取文档请求
|
||||
message ReadFromURLRequest {
|
||||
string url = 1; // 文档URL
|
||||
string title = 2; // 标题
|
||||
ReadConfig read_config = 3;
|
||||
string request_id = 4;
|
||||
}
|
||||
|
||||
// 图片信息
|
||||
message Image {
|
||||
string url = 1; // 图片URL
|
||||
string caption = 2; // 图片描述
|
||||
string ocr_text = 3; // OCR提取的文本内容
|
||||
string original_url = 4; // 原始图片URL
|
||||
int32 start = 5; // 图片在文本中的开始位置
|
||||
int32 end = 6; // 图片在文本中的结束位置
|
||||
}
|
||||
|
||||
message Chunk {
|
||||
string content = 1; // 块内容
|
||||
int32 seq = 2; // 块在文档中的次序
|
||||
int32 start = 3; // 块在文档中的起始位置
|
||||
int32 end = 4; // 块在文档中的结束位置
|
||||
repeated Image images = 5; // 块中包含的图片信息
|
||||
}
|
||||
|
||||
// 从URL读取文档响应
|
||||
message ReadResponse {
|
||||
repeated Chunk chunks = 1; // 文档分块
|
||||
string error = 2; // 错误信息
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.29.3
|
||||
// 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_ReadFromFile_FullMethodName = "/docreader.DocReader/ReadFromFile"
|
||||
DocReader_ReadFromURL_FullMethodName = "/docreader.DocReader/ReadFromURL"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
// 从文件读取文档
|
||||
ReadFromFile(ctx context.Context, in *ReadFromFileRequest, opts ...grpc.CallOption) (*ReadResponse, error)
|
||||
// 从URL读取文档
|
||||
ReadFromURL(ctx context.Context, in *ReadFromURLRequest, opts ...grpc.CallOption) (*ReadResponse, error)
|
||||
}
|
||||
|
||||
type docReaderClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDocReaderClient(cc grpc.ClientConnInterface) DocReaderClient {
|
||||
return &docReaderClient{cc}
|
||||
}
|
||||
|
||||
func (c *docReaderClient) ReadFromFile(ctx context.Context, in *ReadFromFileRequest, opts ...grpc.CallOption) (*ReadResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ReadResponse)
|
||||
err := c.cc.Invoke(ctx, DocReader_ReadFromFile_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *docReaderClient) ReadFromURL(ctx context.Context, in *ReadFromURLRequest, opts ...grpc.CallOption) (*ReadResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ReadResponse)
|
||||
err := c.cc.Invoke(ctx, DocReader_ReadFromURL_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 {
|
||||
// 从文件读取文档
|
||||
ReadFromFile(context.Context, *ReadFromFileRequest) (*ReadResponse, error)
|
||||
// 从URL读取文档
|
||||
ReadFromURL(context.Context, *ReadFromURLRequest) (*ReadResponse, 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) ReadFromFile(context.Context, *ReadFromFileRequest) (*ReadResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReadFromFile not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) ReadFromURL(context.Context, *ReadFromURLRequest) (*ReadResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReadFromURL 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 pancis, 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_ReadFromFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReadFromFileRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DocReaderServer).ReadFromFile(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: DocReader_ReadFromFile_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DocReaderServer).ReadFromFile(ctx, req.(*ReadFromFileRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DocReader_ReadFromURL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReadFromURLRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DocReaderServer).ReadFromURL(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: DocReader_ReadFromURL_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DocReaderServer).ReadFromURL(ctx, req.(*ReadFromURLRequest))
|
||||
}
|
||||
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: "ReadFromFile",
|
||||
Handler: _DocReader_ReadFromFile_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReadFromURL",
|
||||
Handler: _DocReader_ReadFromURL_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "docreader.proto",
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
# -*- 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\"\xb9\x01\n\rStorageConfig\x12,\n\x08provider\x18\x01 \x01(\x0e\x32\x1a.docreader.StorageProvider\x12\x0e\n\x06region\x18\x02 \x01(\t\x12\x13\n\x0b\x62ucket_name\x18\x03 \x01(\t\x12\x15\n\raccess_key_id\x18\x04 \x01(\t\x12\x19\n\x11secret_access_key\x18\x05 \x01(\t\x12\x0e\n\x06\x61pp_id\x18\x06 \x01(\t\x12\x13\n\x0bpath_prefix\x18\x07 \x01(\t\"Z\n\tVLMConfig\x12\x12\n\nmodel_name\x18\x01 \x01(\t\x12\x10\n\x08\x62\x61se_url\x18\x02 \x01(\t\x12\x0f\n\x07\x61pi_key\x18\x03 \x01(\t\x12\x16\n\x0einterface_type\x18\x04 \x01(\t\"\xc2\x01\n\nReadConfig\x12\x12\n\nchunk_size\x18\x01 \x01(\x05\x12\x15\n\rchunk_overlap\x18\x02 \x01(\x05\x12\x12\n\nseparators\x18\x03 \x03(\t\x12\x19\n\x11\x65nable_multimodal\x18\x04 \x01(\x08\x12\x30\n\x0estorage_config\x18\x05 \x01(\x0b\x32\x18.docreader.StorageConfig\x12(\n\nvlm_config\x18\x06 \x01(\x0b\x32\x14.docreader.VLMConfig\"\x91\x01\n\x13ReadFromFileRequest\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*\n\x0bread_config\x18\x04 \x01(\x0b\x32\x15.docreader.ReadConfig\x12\x12\n\nrequest_id\x18\x05 \x01(\t\"p\n\x12ReadFromURLRequest\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\r\n\x05title\x18\x02 \x01(\t\x12*\n\x0bread_config\x18\x03 \x01(\x0b\x32\x15.docreader.ReadConfig\x12\x12\n\nrequest_id\x18\x04 \x01(\t\"i\n\x05Image\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x0f\n\x07\x63\x61ption\x18\x02 \x01(\t\x12\x10\n\x08ocr_text\x18\x03 \x01(\t\x12\x14\n\x0coriginal_url\x18\x04 \x01(\t\x12\r\n\x05start\x18\x05 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x06 \x01(\x05\"c\n\x05\x43hunk\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12\x0b\n\x03seq\x18\x02 \x01(\x05\x12\r\n\x05start\x18\x03 \x01(\x05\x12\x0b\n\x03\x65nd\x18\x04 \x01(\x05\x12 \n\x06images\x18\x05 \x03(\x0b\x32\x10.docreader.Image\"?\n\x0cReadResponse\x12 \n\x06\x63hunks\x18\x01 \x03(\x0b\x32\x10.docreader.Chunk\x12\r\n\x05\x65rror\x18\x02 \x01(\t*G\n\x0fStorageProvider\x12 \n\x1cSTORAGE_PROVIDER_UNSPECIFIED\x10\x00\x12\x07\n\x03\x43OS\x10\x01\x12\t\n\x05MINIO\x10\x02\x32\x9f\x01\n\tDocReader\x12I\n\x0cReadFromFile\x12\x1e.docreader.ReadFromFileRequest\x1a\x17.docreader.ReadResponse\"\x00\x12G\n\x0bReadFromURL\x12\x1d.docreader.ReadFromURLRequest\x1a\x17.docreader.ReadResponse\"\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['_STORAGEPROVIDER']._serialized_start=1042
|
||||
_globals['_STORAGEPROVIDER']._serialized_end=1113
|
||||
_globals['_STORAGECONFIG']._serialized_start=31
|
||||
_globals['_STORAGECONFIG']._serialized_end=216
|
||||
_globals['_VLMCONFIG']._serialized_start=218
|
||||
_globals['_VLMCONFIG']._serialized_end=308
|
||||
_globals['_READCONFIG']._serialized_start=311
|
||||
_globals['_READCONFIG']._serialized_end=505
|
||||
_globals['_READFROMFILEREQUEST']._serialized_start=508
|
||||
_globals['_READFROMFILEREQUEST']._serialized_end=653
|
||||
_globals['_READFROMURLREQUEST']._serialized_start=655
|
||||
_globals['_READFROMURLREQUEST']._serialized_end=767
|
||||
_globals['_IMAGE']._serialized_start=769
|
||||
_globals['_IMAGE']._serialized_end=874
|
||||
_globals['_CHUNK']._serialized_start=876
|
||||
_globals['_CHUNK']._serialized_end=975
|
||||
_globals['_READRESPONSE']._serialized_start=977
|
||||
_globals['_READRESPONSE']._serialized_end=1040
|
||||
_globals['_DOCREADER']._serialized_start=1116
|
||||
_globals['_DOCREADER']._serialized_end=1275
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
@@ -0,0 +1,145 @@
|
||||
# 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 . import docreader_pb2 as docreader__pb2
|
||||
|
||||
GRPC_GENERATED_VERSION = '1.76.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):
|
||||
"""文档读取服务
|
||||
"""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.ReadFromFile = channel.unary_unary(
|
||||
'/docreader.DocReader/ReadFromFile',
|
||||
request_serializer=docreader__pb2.ReadFromFileRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ReadResponse.FromString,
|
||||
_registered_method=True)
|
||||
self.ReadFromURL = channel.unary_unary(
|
||||
'/docreader.DocReader/ReadFromURL',
|
||||
request_serializer=docreader__pb2.ReadFromURLRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ReadResponse.FromString,
|
||||
_registered_method=True)
|
||||
|
||||
|
||||
class DocReaderServicer(object):
|
||||
"""文档读取服务
|
||||
"""
|
||||
|
||||
def ReadFromFile(self, request, context):
|
||||
"""从文件读取文档
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReadFromURL(self, request, context):
|
||||
"""从URL读取文档
|
||||
"""
|
||||
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 = {
|
||||
'ReadFromFile': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReadFromFile,
|
||||
request_deserializer=docreader__pb2.ReadFromFileRequest.FromString,
|
||||
response_serializer=docreader__pb2.ReadResponse.SerializeToString,
|
||||
),
|
||||
'ReadFromURL': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReadFromURL,
|
||||
request_deserializer=docreader__pb2.ReadFromURLRequest.FromString,
|
||||
response_serializer=docreader__pb2.ReadResponse.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):
|
||||
"""文档读取服务
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def ReadFromFile(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/ReadFromFile',
|
||||
docreader__pb2.ReadFromFileRequest.SerializeToString,
|
||||
docreader__pb2.ReadResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
||||
@staticmethod
|
||||
def ReadFromURL(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/ReadFromURL',
|
||||
docreader__pb2.ReadFromURLRequest.SerializeToString,
|
||||
docreader__pb2.ReadResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
Reference in New Issue
Block a user