增加 grpc 生成命令
This commit is contained in:
parent
013b097adf
commit
821ee53de5
1
grpc.txt
Normal file
1
grpc.txt
Normal file
@ -0,0 +1 @@
|
||||
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. .\rpc\ai.proto
|
17
rpc/ai.proto
Normal file
17
rpc/ai.proto
Normal 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
0
rpc/grpc.py
Normal 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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user