pond918 commited on
Commit
b96b972
·
1 Parent(s): f076ebc
Files changed (3) hide show
  1. .gitignore +2 -1
  2. README.md +22 -0
  3. faiss_vdb.py +2 -2
.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  env/
2
- data/
 
 
1
  env/
2
+ data/
3
+ __pycache__/
README.md CHANGED
@@ -12,3 +12,25 @@ license: mit
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
15
+
16
+ ## local test
17
+
18
+ run the app:
19
+
20
+ ```shell
21
+ python3 app.py
22
+ ```
23
+
24
+ visit site at: http://127.0.0.1:7860
25
+
26
+ ### upsert API call
27
+
28
+ ```shell
29
+ curl -X POST -H 'Content-type: application/json' --data '{ "data": ["Jill111", { "meta": { "id": "Jill111" }, "content": {"goal": "for test", "skills": [ "for test skills 10 chars least." ] } }] }' http://127.0.0.1:7860/run/predict
30
+ ```
31
+
32
+ ### search API call
33
+
34
+ ```shell
35
+ curl -X POST -H 'Content-type: application/json' --data '{ "data": [{"goal": "for test", "skills": [ "for test skills 10 chars least." ] }, 3] }' http://127.0.0.1:7860/run/predict_1
36
+ ```
faiss_vdb.py CHANGED
@@ -12,13 +12,13 @@ db = FAISS.load_local(db_path, embeddings) if os.path.exists(
12
  db_path) else FAISS.from_texts([''], embeddings)
13
 
14
 
15
- def upsert(text, meta):
16
  """
17
  Args:
18
  text: string
19
  meta: dict, must contain id.
20
  """
21
- db.aadd_texts([text], metadatas=[meta], ids=[meta['id']])
22
  db.save_local(db_path)
23
 
24
 
 
12
  db_path) else FAISS.from_texts([''], embeddings)
13
 
14
 
15
+ async def upsert(text, meta):
16
  """
17
  Args:
18
  text: string
19
  meta: dict, must contain id.
20
  """
21
+ await db.aadd_texts([text], metadatas=[meta], ids=[meta['id']])
22
  db.save_local(db_path)
23
 
24