改进 服务定义

This commit is contained in:
Twilight 2024-07-17 20:58:03 +08:00
parent 33d1389370
commit 33cc5f06fb
20 changed files with 1466 additions and 689 deletions

View File

@ -3,6 +3,7 @@
setup: setup:
go run . setup go run . setup
ent: ent:
# go run -mod=mod entgo.io/ent/cmd/ent new User
go generate ./ent go generate ./ent
grpc-web: grpc-web:
grpcwebproxy --backend_addr=localhost:8081 --run_http_server --run_tls_server=false --server_http_debug_port 18081 --allow_all_origins --server_bind_address 127.0.0.1 grpcwebproxy --backend_addr=localhost:8081 --run_http_server --run_tls_server=false --server_http_debug_port 18081 --allow_all_origins --server_bind_address 127.0.0.1

View File

@ -1,260 +0,0 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: api/library/library.proto
/*
Package library is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package library
import (
"context"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
var (
filter_LibraryService_ListLibrary_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_LibraryService_ListLibrary_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_ListLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ListLibrary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_LibraryService_ListLibrary_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_ListLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ListLibrary(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_LibraryService_CreateLibrary_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_LibraryService_CreateLibrary_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_CreateLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CreateLibrary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_LibraryService_CreateLibrary_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_CreateLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CreateLibrary(ctx, &protoReq)
return msg, metadata, err
}
// RegisterLibraryServiceHandlerServer registers the http handlers for service LibraryService to "mux".
// UnaryRPC :call LibraryServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterLibraryServiceHandlerFromEndpoint instead.
func RegisterLibraryServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LibraryServiceServer) error {
mux.Handle("GET", pattern_LibraryService_ListLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/LibraryService.LibraryService/ListLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_LibraryService_ListLibrary_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_LibraryService_ListLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_LibraryService_CreateLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/LibraryService.LibraryService/CreateLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_LibraryService_CreateLibrary_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_LibraryService_CreateLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterLibraryServiceHandlerFromEndpoint is same as RegisterLibraryServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterLibraryServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterLibraryServiceHandler(ctx, mux, conn)
}
// RegisterLibraryServiceHandler registers the http handlers for service LibraryService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterLibraryServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterLibraryServiceHandlerClient(ctx, mux, NewLibraryServiceClient(conn))
}
// RegisterLibraryServiceHandlerClient registers the http handlers for service LibraryService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LibraryServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LibraryServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "LibraryServiceClient" to call the correct interceptors.
func RegisterLibraryServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LibraryServiceClient) error {
mux.Handle("GET", pattern_LibraryService_ListLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/LibraryService.LibraryService/ListLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_LibraryService_ListLibrary_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_LibraryService_ListLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_LibraryService_CreateLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/LibraryService.LibraryService/CreateLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_LibraryService_CreateLibrary_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_LibraryService_CreateLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_LibraryService_ListLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "libraries"}, ""))
pattern_LibraryService_CreateLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "libraries"}, ""))
)
var (
forward_LibraryService_ListLibrary_0 = runtime.ForwardResponseMessage
forward_LibraryService_CreateLibrary_0 = runtime.ForwardResponseMessage
)

View File

@ -1,150 +0,0 @@
{
"swagger": "2.0",
"info": {
"title": "api/library/library.proto",
"version": "version not set"
},
"tags": [
{
"name": "LibraryService"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/v1/libraries": {
"get": {
"operationId": "LibraryService_ListLibrary",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/LibraryServiceListLibraryResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "page",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
}
],
"tags": [
"LibraryService"
]
},
"post": {
"operationId": "LibraryService_CreateLibrary",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/LibraryServiceCreateLibraryResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "name",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"LibraryService"
]
}
}
},
"definitions": {
"LibraryServiceCreateLibraryResponse": {
"type": "object",
"properties": {
"library": {
"$ref": "#/definitions/LibraryServiceLibrary"
}
}
},
"LibraryServiceLibrary": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64"
},
"name": {
"type": "string"
},
"userId": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"LibraryServiceListLibraryResponse": {
"type": "object",
"properties": {
"libraries": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/LibraryServiceLibrary"
}
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -1,141 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc (unknown)
// source: api/library/library.proto
package library
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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// LibraryServiceClient is the client API for LibraryService 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 LibraryServiceClient interface {
ListLibrary(ctx context.Context, in *ListLibraryRequest, opts ...grpc.CallOption) (*ListLibraryResponse, error)
CreateLibrary(ctx context.Context, in *CreateLibraryRequest, opts ...grpc.CallOption) (*CreateLibraryResponse, error)
}
type libraryServiceClient struct {
cc grpc.ClientConnInterface
}
func NewLibraryServiceClient(cc grpc.ClientConnInterface) LibraryServiceClient {
return &libraryServiceClient{cc}
}
func (c *libraryServiceClient) ListLibrary(ctx context.Context, in *ListLibraryRequest, opts ...grpc.CallOption) (*ListLibraryResponse, error) {
out := new(ListLibraryResponse)
err := c.cc.Invoke(ctx, "/LibraryService.LibraryService/ListLibrary", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libraryServiceClient) CreateLibrary(ctx context.Context, in *CreateLibraryRequest, opts ...grpc.CallOption) (*CreateLibraryResponse, error) {
out := new(CreateLibraryResponse)
err := c.cc.Invoke(ctx, "/LibraryService.LibraryService/CreateLibrary", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LibraryServiceServer is the server API for LibraryService service.
// All implementations must embed UnimplementedLibraryServiceServer
// for forward compatibility
type LibraryServiceServer interface {
ListLibrary(context.Context, *ListLibraryRequest) (*ListLibraryResponse, error)
CreateLibrary(context.Context, *CreateLibraryRequest) (*CreateLibraryResponse, error)
mustEmbedUnimplementedLibraryServiceServer()
}
// UnimplementedLibraryServiceServer must be embedded to have forward compatible implementations.
type UnimplementedLibraryServiceServer struct {
}
func (UnimplementedLibraryServiceServer) ListLibrary(context.Context, *ListLibraryRequest) (*ListLibraryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListLibrary not implemented")
}
func (UnimplementedLibraryServiceServer) CreateLibrary(context.Context, *CreateLibraryRequest) (*CreateLibraryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateLibrary not implemented")
}
func (UnimplementedLibraryServiceServer) mustEmbedUnimplementedLibraryServiceServer() {}
// UnsafeLibraryServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LibraryServiceServer will
// result in compilation errors.
type UnsafeLibraryServiceServer interface {
mustEmbedUnimplementedLibraryServiceServer()
}
func RegisterLibraryServiceServer(s grpc.ServiceRegistrar, srv LibraryServiceServer) {
s.RegisterService(&LibraryService_ServiceDesc, srv)
}
func _LibraryService_ListLibrary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListLibraryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServiceServer).ListLibrary(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/LibraryService.LibraryService/ListLibrary",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServiceServer).ListLibrary(ctx, req.(*ListLibraryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LibraryService_CreateLibrary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateLibraryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibraryServiceServer).CreateLibrary(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/LibraryService.LibraryService/CreateLibrary",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibraryServiceServer).CreateLibrary(ctx, req.(*CreateLibraryRequest))
}
return interceptor(ctx, in, info, handler)
}
// LibraryService_ServiceDesc is the grpc.ServiceDesc for LibraryService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var LibraryService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "LibraryService.LibraryService",
HandlerType: (*LibraryServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListLibrary",
Handler: _LibraryService_ListLibrary_Handler,
},
{
MethodName: "CreateLibrary",
Handler: _LibraryService_CreateLibrary_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/library/library.proto",
}

344
api/rag/document.pb.go Normal file
View File

@ -0,0 +1,344 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc (unknown)
// source: api/rag/document.proto
package rag
import (
_ "google.golang.org/genproto/googleapis/api/annotations"
_ "google.golang.org/genproto/googleapis/api/httpbody"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
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 CreateDocumentRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
LibraryId string `protobuf:"bytes,3,opt,name=library_id,json=libraryId,proto3" json:"library_id,omitempty"`
}
func (x *CreateDocumentRequest) Reset() {
*x = CreateDocumentRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_api_rag_document_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateDocumentRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateDocumentRequest) ProtoMessage() {}
func (x *CreateDocumentRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_rag_document_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateDocumentRequest.ProtoReflect.Descriptor instead.
func (*CreateDocumentRequest) Descriptor() ([]byte, []int) {
return file_api_rag_document_proto_rawDescGZIP(), []int{0}
}
func (x *CreateDocumentRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CreateDocumentRequest) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *CreateDocumentRequest) GetLibraryId() string {
if x != nil {
return x.LibraryId
}
return ""
}
type CreateDocumentResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
}
func (x *CreateDocumentResponse) Reset() {
*x = CreateDocumentResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_api_rag_document_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateDocumentResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateDocumentResponse) ProtoMessage() {}
func (x *CreateDocumentResponse) ProtoReflect() protoreflect.Message {
mi := &file_api_rag_document_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateDocumentResponse.ProtoReflect.Descriptor instead.
func (*CreateDocumentResponse) Descriptor() ([]byte, []int) {
return file_api_rag_document_proto_rawDescGZIP(), []int{1}
}
func (x *CreateDocumentResponse) GetDocument() *Document {
if x != nil {
return x.Document
}
return nil
}
type Document struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"`
LibraryId string `protobuf:"bytes,4,opt,name=library_id,json=libraryId,proto3" json:"library_id,omitempty"`
CreatedAt string `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt string `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
}
func (x *Document) Reset() {
*x = Document{}
if protoimpl.UnsafeEnabled {
mi := &file_api_rag_document_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Document) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Document) ProtoMessage() {}
func (x *Document) ProtoReflect() protoreflect.Message {
mi := &file_api_rag_document_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Document.ProtoReflect.Descriptor instead.
func (*Document) Descriptor() ([]byte, []int) {
return file_api_rag_document_proto_rawDescGZIP(), []int{2}
}
func (x *Document) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *Document) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Document) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *Document) GetLibraryId() string {
if x != nil {
return x.LibraryId
}
return ""
}
func (x *Document) GetCreatedAt() string {
if x != nil {
return x.CreatedAt
}
return ""
}
func (x *Document) GetUpdatedAt() string {
if x != nil {
return x.UpdatedAt
}
return ""
}
var File_api_rag_document_proto protoreflect.FileDescriptor
var file_api_rag_document_proto_rawDesc = []byte{
0x0a, 0x16, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x64, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x69,
0x62, 0x72, 0x61, 0x72, 0x79, 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74,
0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x25, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08,
0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0xa5, 0x01, 0x0a, 0x08, 0x44, 0x6f, 0x63,
0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e,
0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74,
0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x5f, 0x69,
0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41,
0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18,
0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74,
0x42, 0x1e, 0x5a, 0x1c, 0x6c, 0x65, 0x61, 0x66, 0x64, 0x65, 0x76, 0x2e, 0x74, 0x6f, 0x70, 0x2f,
0x6c, 0x65, 0x61, 0x66, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61, 0x67,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_api_rag_document_proto_rawDescOnce sync.Once
file_api_rag_document_proto_rawDescData = file_api_rag_document_proto_rawDesc
)
func file_api_rag_document_proto_rawDescGZIP() []byte {
file_api_rag_document_proto_rawDescOnce.Do(func() {
file_api_rag_document_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_rag_document_proto_rawDescData)
})
return file_api_rag_document_proto_rawDescData
}
var file_api_rag_document_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_api_rag_document_proto_goTypes = []interface{}{
(*CreateDocumentRequest)(nil), // 0: CreateDocumentRequest
(*CreateDocumentResponse)(nil), // 1: CreateDocumentResponse
(*Document)(nil), // 2: Document
}
var file_api_rag_document_proto_depIdxs = []int32{
2, // 0: CreateDocumentResponse.document:type_name -> Document
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_api_rag_document_proto_init() }
func file_api_rag_document_proto_init() {
if File_api_rag_document_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_api_rag_document_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateDocumentRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_rag_document_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateDocumentResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_rag_document_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Document); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_rag_document_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_api_rag_document_proto_goTypes,
DependencyIndexes: file_api_rag_document_proto_depIdxs,
MessageInfos: file_api_rag_document_proto_msgTypes,
}.Build()
File_api_rag_document_proto = out.File
file_api_rag_document_proto_rawDesc = nil
file_api_rag_document_proto_goTypes = nil
file_api_rag_document_proto_depIdxs = nil
}

27
api/rag/document.proto Normal file
View File

@ -0,0 +1,27 @@
syntax = "proto3";
import "google/api/annotations.proto";
import "google/api/httpbody.proto";
option go_package = "leafdev.top/leaf/rag/api/rag";
message CreateDocumentRequest {
string name = 1;
string content = 2;
string library_id = 3;
}
message CreateDocumentResponse {
Document document = 1;
}
message Document {
int64 id = 1;
string name = 2;
string content = 3;
string library_id = 4;
string created_at = 5;
string updated_at = 6;
}

View File

@ -0,0 +1,46 @@
{
"swagger": "2.0",
"info": {
"title": "api/rag/document.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string",
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
}
},
"additionalProperties": {},
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

View File

@ -2,9 +2,9 @@
// versions: // versions:
// protoc-gen-go v1.28.1 // protoc-gen-go v1.28.1
// protoc (unknown) // protoc (unknown)
// source: api/library/library.proto // source: api/rag/library.proto
package library package rag
import ( import (
_ "google.golang.org/genproto/googleapis/api/annotations" _ "google.golang.org/genproto/googleapis/api/annotations"
@ -21,6 +21,7 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// import "google.golang.org/grpc/health/grpc_health_v1";
type Library struct { type Library struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -36,7 +37,7 @@ type Library struct {
func (x *Library) Reset() { func (x *Library) Reset() {
*x = Library{} *x = Library{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_library_library_proto_msgTypes[0] mi := &file_api_rag_library_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -49,7 +50,7 @@ func (x *Library) String() string {
func (*Library) ProtoMessage() {} func (*Library) ProtoMessage() {}
func (x *Library) ProtoReflect() protoreflect.Message { func (x *Library) ProtoReflect() protoreflect.Message {
mi := &file_api_library_library_proto_msgTypes[0] mi := &file_api_rag_library_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -62,7 +63,7 @@ func (x *Library) ProtoReflect() protoreflect.Message {
// Deprecated: Use Library.ProtoReflect.Descriptor instead. // Deprecated: Use Library.ProtoReflect.Descriptor instead.
func (*Library) Descriptor() ([]byte, []int) { func (*Library) Descriptor() ([]byte, []int) {
return file_api_library_library_proto_rawDescGZIP(), []int{0} return file_api_rag_library_proto_rawDescGZIP(), []int{0}
} }
func (x *Library) GetId() int64 { func (x *Library) GetId() int64 {
@ -111,7 +112,7 @@ type ListLibraryRequest struct {
func (x *ListLibraryRequest) Reset() { func (x *ListLibraryRequest) Reset() {
*x = ListLibraryRequest{} *x = ListLibraryRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_library_library_proto_msgTypes[1] mi := &file_api_rag_library_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -124,7 +125,7 @@ func (x *ListLibraryRequest) String() string {
func (*ListLibraryRequest) ProtoMessage() {} func (*ListLibraryRequest) ProtoMessage() {}
func (x *ListLibraryRequest) ProtoReflect() protoreflect.Message { func (x *ListLibraryRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_library_library_proto_msgTypes[1] mi := &file_api_rag_library_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -137,7 +138,7 @@ func (x *ListLibraryRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListLibraryRequest.ProtoReflect.Descriptor instead. // Deprecated: Use ListLibraryRequest.ProtoReflect.Descriptor instead.
func (*ListLibraryRequest) Descriptor() ([]byte, []int) { func (*ListLibraryRequest) Descriptor() ([]byte, []int) {
return file_api_library_library_proto_rawDescGZIP(), []int{1} return file_api_rag_library_proto_rawDescGZIP(), []int{1}
} }
func (x *ListLibraryRequest) GetPage() int32 { func (x *ListLibraryRequest) GetPage() int32 {
@ -158,7 +159,7 @@ type ListLibraryResponse struct {
func (x *ListLibraryResponse) Reset() { func (x *ListLibraryResponse) Reset() {
*x = ListLibraryResponse{} *x = ListLibraryResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_library_library_proto_msgTypes[2] mi := &file_api_rag_library_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -171,7 +172,7 @@ func (x *ListLibraryResponse) String() string {
func (*ListLibraryResponse) ProtoMessage() {} func (*ListLibraryResponse) ProtoMessage() {}
func (x *ListLibraryResponse) ProtoReflect() protoreflect.Message { func (x *ListLibraryResponse) ProtoReflect() protoreflect.Message {
mi := &file_api_library_library_proto_msgTypes[2] mi := &file_api_rag_library_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -184,7 +185,7 @@ func (x *ListLibraryResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListLibraryResponse.ProtoReflect.Descriptor instead. // Deprecated: Use ListLibraryResponse.ProtoReflect.Descriptor instead.
func (*ListLibraryResponse) Descriptor() ([]byte, []int) { func (*ListLibraryResponse) Descriptor() ([]byte, []int) {
return file_api_library_library_proto_rawDescGZIP(), []int{2} return file_api_rag_library_proto_rawDescGZIP(), []int{2}
} }
func (x *ListLibraryResponse) GetLibraries() []*Library { func (x *ListLibraryResponse) GetLibraries() []*Library {
@ -205,7 +206,7 @@ type CreateLibraryRequest struct {
func (x *CreateLibraryRequest) Reset() { func (x *CreateLibraryRequest) Reset() {
*x = CreateLibraryRequest{} *x = CreateLibraryRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_library_library_proto_msgTypes[3] mi := &file_api_rag_library_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -218,7 +219,7 @@ func (x *CreateLibraryRequest) String() string {
func (*CreateLibraryRequest) ProtoMessage() {} func (*CreateLibraryRequest) ProtoMessage() {}
func (x *CreateLibraryRequest) ProtoReflect() protoreflect.Message { func (x *CreateLibraryRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_library_library_proto_msgTypes[3] mi := &file_api_rag_library_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -231,7 +232,7 @@ func (x *CreateLibraryRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateLibraryRequest.ProtoReflect.Descriptor instead. // Deprecated: Use CreateLibraryRequest.ProtoReflect.Descriptor instead.
func (*CreateLibraryRequest) Descriptor() ([]byte, []int) { func (*CreateLibraryRequest) Descriptor() ([]byte, []int) {
return file_api_library_library_proto_rawDescGZIP(), []int{3} return file_api_rag_library_proto_rawDescGZIP(), []int{3}
} }
func (x *CreateLibraryRequest) GetName() string { func (x *CreateLibraryRequest) GetName() string {
@ -252,7 +253,7 @@ type CreateLibraryResponse struct {
func (x *CreateLibraryResponse) Reset() { func (x *CreateLibraryResponse) Reset() {
*x = CreateLibraryResponse{} *x = CreateLibraryResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_library_library_proto_msgTypes[4] mi := &file_api_rag_library_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -265,7 +266,7 @@ func (x *CreateLibraryResponse) String() string {
func (*CreateLibraryResponse) ProtoMessage() {} func (*CreateLibraryResponse) ProtoMessage() {}
func (x *CreateLibraryResponse) ProtoReflect() protoreflect.Message { func (x *CreateLibraryResponse) ProtoReflect() protoreflect.Message {
mi := &file_api_library_library_proto_msgTypes[4] mi := &file_api_rag_library_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -278,7 +279,7 @@ func (x *CreateLibraryResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateLibraryResponse.ProtoReflect.Descriptor instead. // Deprecated: Use CreateLibraryResponse.ProtoReflect.Descriptor instead.
func (*CreateLibraryResponse) Descriptor() ([]byte, []int) { func (*CreateLibraryResponse) Descriptor() ([]byte, []int) {
return file_api_library_library_proto_rawDescGZIP(), []int{4} return file_api_rag_library_proto_rawDescGZIP(), []int{4}
} }
func (x *CreateLibraryResponse) GetLibrary() *Library { func (x *CreateLibraryResponse) GetLibrary() *Library {
@ -288,99 +289,76 @@ func (x *CreateLibraryResponse) GetLibrary() *Library {
return nil return nil
} }
var File_api_library_library_proto protoreflect.FileDescriptor var File_api_rag_library_proto protoreflect.FileDescriptor
var file_api_library_library_proto_rawDesc = []byte{ var file_api_rag_library_proto_rawDesc = []byte{
0x0a, 0x19, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2f, 0x6c, 0x69, 0x0a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x62, 0x72, 0x61, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x4c, 0x69, 0x62, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x84, 0x01, 0x0a, 0x07, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x84, 0x01, 0x0a, 0x07, 0x4c, 0x69, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69,
0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d,
0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01,
0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1d, 0x0a,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28,
0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x09, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x28, 0x0a, 0x12,
0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65,
0x22, 0x28, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x22, 0x3d, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69,
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, 0x13, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a,
0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x09, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x65, 0x12, 0x35, 0x0a, 0x09, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x32, 0x08, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x09, 0x6c, 0x69, 0x62, 0x72,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x61, 0x72, 0x69, 0x65, 0x73, 0x22, 0x2a, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x09, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a,
0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x22, 0x2a, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x22, 0x3b, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x07, 0x6c, 0x69,
0x6e, 0x61, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x4c, 0x69,
0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x07, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x42, 0x1e,
0x07, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x5a, 0x1c, 0x6c, 0x65, 0x61, 0x66, 0x64, 0x65, 0x76, 0x2e, 0x74, 0x6f, 0x70, 0x2f, 0x6c, 0x65,
0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x61, 0x66, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61, 0x67, 0x62, 0x06,
0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x07, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x32, 0xfc, 0x01, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x79, 0x12, 0x22, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4,
0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x62,
0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x77, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x24, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c,
0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e,
0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x42,
0x24, 0x5a, 0x22, 0x6c, 0x65, 0x61, 0x66, 0x64, 0x65, 0x76, 0x2e, 0x74, 0x6f, 0x70, 0x2f, 0x6c,
0x65, 0x61, 0x66, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x69,
0x62, 0x72, 0x61, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
file_api_library_library_proto_rawDescOnce sync.Once file_api_rag_library_proto_rawDescOnce sync.Once
file_api_library_library_proto_rawDescData = file_api_library_library_proto_rawDesc file_api_rag_library_proto_rawDescData = file_api_rag_library_proto_rawDesc
) )
func file_api_library_library_proto_rawDescGZIP() []byte { func file_api_rag_library_proto_rawDescGZIP() []byte {
file_api_library_library_proto_rawDescOnce.Do(func() { file_api_rag_library_proto_rawDescOnce.Do(func() {
file_api_library_library_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_library_library_proto_rawDescData) file_api_rag_library_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_rag_library_proto_rawDescData)
}) })
return file_api_library_library_proto_rawDescData return file_api_rag_library_proto_rawDescData
} }
var file_api_library_library_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_api_rag_library_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_api_library_library_proto_goTypes = []interface{}{ var file_api_rag_library_proto_goTypes = []interface{}{
(*Library)(nil), // 0: LibraryService.Library (*Library)(nil), // 0: Library
(*ListLibraryRequest)(nil), // 1: LibraryService.ListLibraryRequest (*ListLibraryRequest)(nil), // 1: ListLibraryRequest
(*ListLibraryResponse)(nil), // 2: LibraryService.ListLibraryResponse (*ListLibraryResponse)(nil), // 2: ListLibraryResponse
(*CreateLibraryRequest)(nil), // 3: LibraryService.CreateLibraryRequest (*CreateLibraryRequest)(nil), // 3: CreateLibraryRequest
(*CreateLibraryResponse)(nil), // 4: LibraryService.CreateLibraryResponse (*CreateLibraryResponse)(nil), // 4: CreateLibraryResponse
} }
var file_api_library_library_proto_depIdxs = []int32{ var file_api_rag_library_proto_depIdxs = []int32{
0, // 0: LibraryService.ListLibraryResponse.libraries:type_name -> LibraryService.Library 0, // 0: ListLibraryResponse.libraries:type_name -> Library
0, // 1: LibraryService.CreateLibraryResponse.library:type_name -> LibraryService.Library 0, // 1: CreateLibraryResponse.library:type_name -> Library
1, // 2: LibraryService.LibraryService.ListLibrary:input_type -> LibraryService.ListLibraryRequest 2, // [2:2] is the sub-list for method output_type
3, // 3: LibraryService.LibraryService.CreateLibrary:input_type -> LibraryService.CreateLibraryRequest 2, // [2:2] is the sub-list for method input_type
2, // 4: LibraryService.LibraryService.ListLibrary:output_type -> LibraryService.ListLibraryResponse
4, // 5: LibraryService.LibraryService.CreateLibrary:output_type -> LibraryService.CreateLibraryResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee 2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name 0, // [0:2] is the sub-list for field type_name
} }
func init() { file_api_library_library_proto_init() } func init() { file_api_rag_library_proto_init() }
func file_api_library_library_proto_init() { func file_api_rag_library_proto_init() {
if File_api_library_library_proto != nil { if File_api_rag_library_proto != nil {
return return
} }
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_api_library_library_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_api_rag_library_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Library); i { switch v := v.(*Library); i {
case 0: case 0:
return &v.state return &v.state
@ -392,7 +370,7 @@ func file_api_library_library_proto_init() {
return nil return nil
} }
} }
file_api_library_library_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_api_rag_library_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListLibraryRequest); i { switch v := v.(*ListLibraryRequest); i {
case 0: case 0:
return &v.state return &v.state
@ -404,7 +382,7 @@ func file_api_library_library_proto_init() {
return nil return nil
} }
} }
file_api_library_library_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_api_rag_library_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListLibraryResponse); i { switch v := v.(*ListLibraryResponse); i {
case 0: case 0:
return &v.state return &v.state
@ -416,7 +394,7 @@ func file_api_library_library_proto_init() {
return nil return nil
} }
} }
file_api_library_library_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_api_rag_library_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateLibraryRequest); i { switch v := v.(*CreateLibraryRequest); i {
case 0: case 0:
return &v.state return &v.state
@ -428,7 +406,7 @@ func file_api_library_library_proto_init() {
return nil return nil
} }
} }
file_api_library_library_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { file_api_rag_library_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateLibraryResponse); i { switch v := v.(*CreateLibraryResponse); i {
case 0: case 0:
return &v.state return &v.state
@ -445,18 +423,18 @@ func file_api_library_library_proto_init() {
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_library_library_proto_rawDesc, RawDescriptor: file_api_rag_library_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 5, NumMessages: 5,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 0,
}, },
GoTypes: file_api_library_library_proto_goTypes, GoTypes: file_api_rag_library_proto_goTypes,
DependencyIndexes: file_api_library_library_proto_depIdxs, DependencyIndexes: file_api_rag_library_proto_depIdxs,
MessageInfos: file_api_library_library_proto_msgTypes, MessageInfos: file_api_rag_library_proto_msgTypes,
}.Build() }.Build()
File_api_library_library_proto = out.File File_api_rag_library_proto = out.File
file_api_library_library_proto_rawDesc = nil file_api_rag_library_proto_rawDesc = nil
file_api_library_library_proto_goTypes = nil file_api_rag_library_proto_goTypes = nil
file_api_library_library_proto_depIdxs = nil file_api_rag_library_proto_depIdxs = nil
} }

View File

@ -1,27 +1,11 @@
syntax = "proto3"; syntax = "proto3";
package LibraryService;
option go_package = "leafdev.top/leaf/rag/proto/library"; option go_package = "leafdev.top/leaf/rag/api/rag";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
//import "google.golang.org/grpc/health/grpc_health_v1"; //import "google.golang.org/grpc/health/grpc_health_v1";
service LibraryService {
rpc ListLibrary(ListLibraryRequest) returns (ListLibraryResponse) {
option (google.api.http) = {
get: "/api/v1/libraries"
};
}
rpc CreateLibrary(CreateLibraryRequest) returns (CreateLibraryResponse) {
option (google.api.http) = {
post: "/api/v1/libraries"
};
}
}
message Library { message Library {
int64 id = 1; int64 id = 1;
string name = 2; string name = 2;

View File

@ -0,0 +1,46 @@
{
"swagger": "2.0",
"info": {
"title": "api/rag/library.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string",
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
}
},
"additionalProperties": {},
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

104
api/rag/rag.pb.go Normal file
View File

@ -0,0 +1,104 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc (unknown)
// source: api/rag/rag.proto
package rag
import (
_ "google.golang.org/genproto/googleapis/api/annotations"
_ "google.golang.org/genproto/googleapis/api/httpbody"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
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)
)
var File_api_rag_rag_proto protoreflect.FileDescriptor
var file_api_rag_rag_proto_rawDesc = []byte{
0x0a, 0x11, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x72, 0x61, 0x67, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x52, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a,
0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, 0x6f,
0x64, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61,
0x67, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x9a, 0x02, 0x0a, 0x0a, 0x52, 0x41, 0x47, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74,
0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x17, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x13, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d,
0x65, 0x6e, 0x74, 0x73, 0x12, 0x53, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c,
0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19,
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f,
0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x59, 0x0a, 0x0d, 0x43, 0x72, 0x65,
0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x15, 0x2e, 0x43, 0x72, 0x65,
0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x13, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x69, 0x65, 0x73, 0x42, 0x1e, 0x5a, 0x1c, 0x6c, 0x65, 0x61, 0x66, 0x64, 0x65, 0x76, 0x2e,
0x74, 0x6f, 0x70, 0x2f, 0x6c, 0x65, 0x61, 0x66, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x72, 0x61, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_api_rag_rag_proto_goTypes = []interface{}{
(*CreateDocumentRequest)(nil), // 0: CreateDocumentRequest
(*ListLibraryRequest)(nil), // 1: ListLibraryRequest
(*CreateLibraryRequest)(nil), // 2: CreateLibraryRequest
(*CreateDocumentResponse)(nil), // 3: CreateDocumentResponse
(*ListLibraryResponse)(nil), // 4: ListLibraryResponse
(*CreateLibraryResponse)(nil), // 5: CreateLibraryResponse
}
var file_api_rag_rag_proto_depIdxs = []int32{
0, // 0: RagService.RAGService.CreateDocument:input_type -> CreateDocumentRequest
1, // 1: RagService.RAGService.ListLibrary:input_type -> ListLibraryRequest
2, // 2: RagService.RAGService.CreateLibrary:input_type -> CreateLibraryRequest
3, // 3: RagService.RAGService.CreateDocument:output_type -> CreateDocumentResponse
4, // 4: RagService.RAGService.ListLibrary:output_type -> ListLibraryResponse
5, // 5: RagService.RAGService.CreateLibrary:output_type -> CreateLibraryResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_api_rag_rag_proto_init() }
func file_api_rag_rag_proto_init() {
if File_api_rag_rag_proto != nil {
return
}
file_api_rag_document_proto_init()
file_api_rag_library_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_rag_rag_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_api_rag_rag_proto_goTypes,
DependencyIndexes: file_api_rag_rag_proto_depIdxs,
}.Build()
File_api_rag_rag_proto = out.File
file_api_rag_rag_proto_rawDesc = nil
file_api_rag_rag_proto_goTypes = nil
file_api_rag_rag_proto_depIdxs = nil
}

347
api/rag/rag.pb.gw.go Normal file
View File

@ -0,0 +1,347 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: api/rag/rag.proto
/*
Package rag is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package rag
import (
"context"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
var (
filter_RAGService_CreateDocument_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_RAGService_CreateDocument_0(ctx context.Context, marshaler runtime.Marshaler, client RAGServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateDocumentRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RAGService_CreateDocument_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CreateDocument(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_RAGService_CreateDocument_0(ctx context.Context, marshaler runtime.Marshaler, server RAGServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateDocumentRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RAGService_CreateDocument_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CreateDocument(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_RAGService_ListLibrary_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_RAGService_ListLibrary_0(ctx context.Context, marshaler runtime.Marshaler, client RAGServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RAGService_ListLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ListLibrary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_RAGService_ListLibrary_0(ctx context.Context, marshaler runtime.Marshaler, server RAGServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RAGService_ListLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ListLibrary(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_RAGService_CreateLibrary_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_RAGService_CreateLibrary_0(ctx context.Context, marshaler runtime.Marshaler, client RAGServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RAGService_CreateLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CreateLibrary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_RAGService_CreateLibrary_0(ctx context.Context, marshaler runtime.Marshaler, server RAGServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateLibraryRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RAGService_CreateLibrary_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CreateLibrary(ctx, &protoReq)
return msg, metadata, err
}
// RegisterRAGServiceHandlerServer registers the http handlers for service RAGService to "mux".
// UnaryRPC :call RAGServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterRAGServiceHandlerFromEndpoint instead.
func RegisterRAGServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RAGServiceServer) error {
mux.Handle("POST", pattern_RAGService_CreateDocument_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/RagService.RAGService/CreateDocument", runtime.WithHTTPPathPattern("/api/v1/documents"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_RAGService_CreateDocument_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_RAGService_CreateDocument_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_RAGService_ListLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/RagService.RAGService/ListLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_RAGService_ListLibrary_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_RAGService_ListLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_RAGService_CreateLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/RagService.RAGService/CreateLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_RAGService_CreateLibrary_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_RAGService_CreateLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterRAGServiceHandlerFromEndpoint is same as RegisterRAGServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterRAGServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterRAGServiceHandler(ctx, mux, conn)
}
// RegisterRAGServiceHandler registers the http handlers for service RAGService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterRAGServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterRAGServiceHandlerClient(ctx, mux, NewRAGServiceClient(conn))
}
// RegisterRAGServiceHandlerClient registers the http handlers for service RAGService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RAGServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RAGServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "RAGServiceClient" to call the correct interceptors.
func RegisterRAGServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RAGServiceClient) error {
mux.Handle("POST", pattern_RAGService_CreateDocument_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/RagService.RAGService/CreateDocument", runtime.WithHTTPPathPattern("/api/v1/documents"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RAGService_CreateDocument_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_RAGService_CreateDocument_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_RAGService_ListLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/RagService.RAGService/ListLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RAGService_ListLibrary_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_RAGService_ListLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_RAGService_CreateLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/RagService.RAGService/CreateLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RAGService_CreateLibrary_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_RAGService_CreateLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_RAGService_CreateDocument_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "documents"}, ""))
pattern_RAGService_ListLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "libraries"}, ""))
pattern_RAGService_CreateLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "libraries"}, ""))
)
var (
forward_RAGService_CreateDocument_0 = runtime.ForwardResponseMessage
forward_RAGService_ListLibrary_0 = runtime.ForwardResponseMessage
forward_RAGService_CreateLibrary_0 = runtime.ForwardResponseMessage
)

33
api/rag/rag.proto Normal file
View File

@ -0,0 +1,33 @@
syntax = "proto3";
package RagService;
option go_package = "leafdev.top/leaf/rag/api/rag";
import "google/api/annotations.proto";
import "google/api/httpbody.proto";
import "api/rag/document.proto";
import "api/rag/library.proto";
service RAGService {
rpc CreateDocument(CreateDocumentRequest) returns (CreateDocumentResponse) {
option (google.api.http) = {
post: "/api/v1/documents"
};
}
rpc ListLibrary(ListLibraryRequest) returns (ListLibraryResponse) {
option (google.api.http) = {
get: "/api/v1/libraries"
};
}
rpc CreateLibrary(CreateLibraryRequest) returns (CreateLibraryResponse) {
option (google.api.http) = {
post: "/api/v1/libraries"
};
}
}

227
api/rag/rag.swagger.json Normal file
View File

@ -0,0 +1,227 @@
{
"swagger": "2.0",
"info": {
"title": "api/rag/rag.proto",
"version": "version not set"
},
"tags": [
{
"name": "RAGService"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/v1/documents": {
"post": {
"operationId": "RAGService_CreateDocument",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/CreateDocumentResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "name",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "content",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "libraryId",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"RAGService"
]
}
},
"/api/v1/libraries": {
"get": {
"operationId": "RAGService_ListLibrary",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ListLibraryResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "page",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
}
],
"tags": [
"RAGService"
]
},
"post": {
"operationId": "RAGService_CreateLibrary",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/CreateLibraryResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "name",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"RAGService"
]
}
}
},
"definitions": {
"CreateDocumentResponse": {
"type": "object",
"properties": {
"document": {
"$ref": "#/definitions/Document"
}
}
},
"CreateLibraryResponse": {
"type": "object",
"properties": {
"library": {
"$ref": "#/definitions/Library"
}
}
},
"Document": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64"
},
"name": {
"type": "string"
},
"content": {
"type": "string"
},
"libraryId": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"Library": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64"
},
"name": {
"type": "string"
},
"userId": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
},
"title": "import \"google.golang.org/grpc/health/grpc_health_v1\";"
},
"ListLibraryResponse": {
"type": "object",
"properties": {
"libraries": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/Library"
}
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string",
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
}
},
"additionalProperties": {},
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

177
api/rag/rag_grpc.pb.go Normal file
View File

@ -0,0 +1,177 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc (unknown)
// source: api/rag/rag.proto
package rag
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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// RAGServiceClient is the client API for RAGService 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 RAGServiceClient interface {
CreateDocument(ctx context.Context, in *CreateDocumentRequest, opts ...grpc.CallOption) (*CreateDocumentResponse, error)
ListLibrary(ctx context.Context, in *ListLibraryRequest, opts ...grpc.CallOption) (*ListLibraryResponse, error)
CreateLibrary(ctx context.Context, in *CreateLibraryRequest, opts ...grpc.CallOption) (*CreateLibraryResponse, error)
}
type rAGServiceClient struct {
cc grpc.ClientConnInterface
}
func NewRAGServiceClient(cc grpc.ClientConnInterface) RAGServiceClient {
return &rAGServiceClient{cc}
}
func (c *rAGServiceClient) CreateDocument(ctx context.Context, in *CreateDocumentRequest, opts ...grpc.CallOption) (*CreateDocumentResponse, error) {
out := new(CreateDocumentResponse)
err := c.cc.Invoke(ctx, "/RagService.RAGService/CreateDocument", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *rAGServiceClient) ListLibrary(ctx context.Context, in *ListLibraryRequest, opts ...grpc.CallOption) (*ListLibraryResponse, error) {
out := new(ListLibraryResponse)
err := c.cc.Invoke(ctx, "/RagService.RAGService/ListLibrary", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *rAGServiceClient) CreateLibrary(ctx context.Context, in *CreateLibraryRequest, opts ...grpc.CallOption) (*CreateLibraryResponse, error) {
out := new(CreateLibraryResponse)
err := c.cc.Invoke(ctx, "/RagService.RAGService/CreateLibrary", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RAGServiceServer is the server API for RAGService service.
// All implementations must embed UnimplementedRAGServiceServer
// for forward compatibility
type RAGServiceServer interface {
CreateDocument(context.Context, *CreateDocumentRequest) (*CreateDocumentResponse, error)
ListLibrary(context.Context, *ListLibraryRequest) (*ListLibraryResponse, error)
CreateLibrary(context.Context, *CreateLibraryRequest) (*CreateLibraryResponse, error)
mustEmbedUnimplementedRAGServiceServer()
}
// UnimplementedRAGServiceServer must be embedded to have forward compatible implementations.
type UnimplementedRAGServiceServer struct {
}
func (UnimplementedRAGServiceServer) CreateDocument(context.Context, *CreateDocumentRequest) (*CreateDocumentResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateDocument not implemented")
}
func (UnimplementedRAGServiceServer) ListLibrary(context.Context, *ListLibraryRequest) (*ListLibraryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListLibrary not implemented")
}
func (UnimplementedRAGServiceServer) CreateLibrary(context.Context, *CreateLibraryRequest) (*CreateLibraryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateLibrary not implemented")
}
func (UnimplementedRAGServiceServer) mustEmbedUnimplementedRAGServiceServer() {}
// UnsafeRAGServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to RAGServiceServer will
// result in compilation errors.
type UnsafeRAGServiceServer interface {
mustEmbedUnimplementedRAGServiceServer()
}
func RegisterRAGServiceServer(s grpc.ServiceRegistrar, srv RAGServiceServer) {
s.RegisterService(&RAGService_ServiceDesc, srv)
}
func _RAGService_CreateDocument_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateDocumentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RAGServiceServer).CreateDocument(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/RagService.RAGService/CreateDocument",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RAGServiceServer).CreateDocument(ctx, req.(*CreateDocumentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _RAGService_ListLibrary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListLibraryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RAGServiceServer).ListLibrary(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/RagService.RAGService/ListLibrary",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RAGServiceServer).ListLibrary(ctx, req.(*ListLibraryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _RAGService_CreateLibrary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateLibraryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RAGServiceServer).CreateLibrary(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/RagService.RAGService/CreateLibrary",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RAGServiceServer).CreateLibrary(ctx, req.(*CreateLibraryRequest))
}
return interceptor(ctx, in, info, handler)
}
// RAGService_ServiceDesc is the grpc.ServiceDesc for RAGService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RAGService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "RagService.RAGService",
HandlerType: (*RAGServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateDocument",
Handler: _RAGService_CreateDocument_Handler,
},
{
MethodName: "ListLibrary",
Handler: _RAGService_ListLibrary_Handler,
},
{
MethodName: "CreateLibrary",
Handler: _RAGService_CreateLibrary_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/rag/rag.proto",
}

View File

@ -9,11 +9,11 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"
"leafdev.top/leaf/rag/api/library" ragApi "leafdev.top/leaf/rag/api/rag"
libraryGw "leafdev.top/leaf/rag/api/library" //ragGW "leafdev.top/leaf/rag/api/rag"
grpc2 "leafdev.top/leaf/rag/internal/middleware/grpc" grpc2 "leafdev.top/leaf/rag/internal/middleware/grpc"
"leafdev.top/leaf/rag/internal/providers/jwks" "leafdev.top/leaf/rag/internal/providers/jwks"
"leafdev.top/leaf/rag/internal/services/libraryService" "leafdev.top/leaf/rag/internal/services/rag"
"net" "net"
"net/http" "net/http"
"strings" "strings"
@ -57,7 +57,7 @@ func StartGRPC() {
reflection.Register(grpcServer) reflection.Register(grpcServer)
library.RegisterLibraryServiceServer(grpcServer, libraryService.LibraryService{}) ragApi.RegisterRAGServiceServer(grpcServer, rag.Service{})
var wg = sync.WaitGroup{} var wg = sync.WaitGroup{}
@ -81,10 +81,12 @@ func StartGRPC() {
mux := runtime.NewServeMux() mux := runtime.NewServeMux()
clientOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())} clientOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
err = libraryGw.RegisterLibraryServiceHandlerFromEndpoint(ctx, mux, "127.0.0.1:"+getPortFromAddr(config.ListenAddr.GRPC), clientOpts)
err = ragApi.RegisterRAGServiceHandlerFromEndpoint(ctx, mux, "127.0.0.1:"+getPortFromAddr(config.ListenAddr.GRPC), clientOpts)
if err != nil { if err != nil {
panic(err) panic(err)
} }
logger.Info("GRPC Gateway listening at " + config.ListenAddr.HTTP) logger.Info("GRPC Gateway listening at " + config.ListenAddr.HTTP)
err = http.ListenAndServe(config.ListenAddr.HTTP, mux) err = http.ListenAndServe(config.ListenAddr.HTTP, mux)
if err != nil { if err != nil {

View File

@ -96,3 +96,8 @@ func GetUser(ctx context.Context) *models.User {
return user.(*models.User) return user.(*models.User)
} }
func SetUser(ctx context.Context, user *models.User) context.Context {
context.WithValue(ctx, consts.AuthMiddlewareKey, user)
return context.WithValue(ctx, consts.AuthMiddlewareKey, user)
}

View File

@ -0,0 +1,4 @@
package rag
type DocumentService struct {
}

View File

@ -1,29 +1,25 @@
package libraryService package rag
import ( import (
"context" "context"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
libraryApi "leafdev.top/leaf/rag/api/library" ragApi "leafdev.top/leaf/rag/api/rag"
"leafdev.top/leaf/rag/internal/logic" "leafdev.top/leaf/rag/internal/logic"
) )
type LibraryService struct {
libraryApi.UnimplementedLibraryServiceServer
}
var libraryLogic = logic.NewLibraryLogic() var libraryLogic = logic.NewLibraryLogic()
func (LibraryService) ListLibrary(ctx context.Context, _ *libraryApi.ListLibraryRequest) (*libraryApi.ListLibraryResponse, error) { func (Service) ListLibrary(ctx context.Context, _ *ragApi.ListLibraryRequest) (*ragApi.ListLibraryResponse, error) {
libraries, err := libraryLogic.ListLibrary(ctx) libraries, err := libraryLogic.ListLibrary(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
libraryResponse := &libraryApi.ListLibraryResponse{} libraryResponse := &ragApi.ListLibraryResponse{}
// convert // convert
for _, library := range libraries { for _, library := range libraries {
var libraryResponseItem = libraryApi.Library{ var libraryResponseItem = ragApi.Library{
Id: int64(library.ID), Id: int64(library.ID),
Name: library.Name, Name: library.Name,
UserId: library.UserID, UserId: library.UserID,
@ -36,13 +32,13 @@ func (LibraryService) ListLibrary(ctx context.Context, _ *libraryApi.ListLibrary
return libraryResponse, err return libraryResponse, err
} }
func (LibraryService) CreateLibrary(ctx context.Context, req *libraryApi.CreateLibraryRequest) (*libraryApi.CreateLibraryResponse, error) { func (Service) CreateLibrary(ctx context.Context, req *ragApi.CreateLibraryRequest) (*ragApi.CreateLibraryResponse, error) {
library, err := libraryLogic.CreateLibrary(ctx, req.Name) library, err := libraryLogic.CreateLibrary(ctx, req.Name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var libraryApiResponse libraryApi.CreateLibraryResponse var libraryApiResponse ragApi.CreateLibraryResponse
err = mapstructure.Decode(library, &libraryApiResponse) err = mapstructure.Decode(library, &libraryApiResponse)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -0,0 +1,7 @@
package rag
import ragApi "leafdev.top/leaf/rag/api/rag"
type Service struct {
ragApi.UnimplementedRAGServiceServer
}