diff --git a/grpc.txt b/grpc.txt new file mode 100644 index 0000000..15a604d --- /dev/null +++ b/grpc.txt @@ -0,0 +1 @@ +python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. .\rpc\ai.proto \ No newline at end of file diff --git a/rpc/ai.proto b/rpc/ai.proto new file mode 100644 index 0000000..eab85ac --- /dev/null +++ b/rpc/ai.proto @@ -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; +} \ No newline at end of file diff --git a/rpc/grpc.py b/rpc/grpc.py new file mode 100644 index 0000000..e69de29 diff --git a/text_to_vec.py b/text_to_vec.py index 689b9a3..a5ea2fe 100644 --- a/text_to_vec.py +++ b/text_to_vec.py @@ -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)