增加 grpc 生成命令

This commit is contained in:
iVamp 2023-11-14 18:52:55 +08:00
parent 013b097adf
commit 821ee53de5
4 changed files with 19 additions and 1 deletions

1
grpc.txt Normal file
View File

@ -0,0 +1 @@
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. .\rpc\ai.proto

17
rpc/ai.proto Normal file
View File

@ -0,0 +1,17 @@
syntax = "proto3";
service LLMQuery {
rpc AddDocument (AddDocumentRequest) returns (AddDocumentReply) {}
}
message AddDocumentRequest {
string text = 1;
uint64 user_id = 2;
string database = 3;
string collection = 4;
}
message AddDocumentReply {
string id = 1;
}

0
rpc/grpc.py Normal file
View File

View File

@ -1,4 +1,5 @@
from langchain.embeddings.openai import OpenAIEmbeddings
import json
question = "这个 yarn 为什么会发生错误,该怎么解决?使用中文回复"
@ -11,7 +12,6 @@ embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")
vec = embeddings.embed_query(question)
# 转换成 json 并保存到文件
import json
v_json = json.dumps(vec)