Spaces:
Runtime error
Runtime error
pond918
commited on
Commit
·
8fdb6b2
1
Parent(s):
0f6d38f
feat: embed interface
Browse files- .vscode/settings.json +1 -1
- app.py +14 -2
- faiss_vdb.py +1 -1
.vscode/settings.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"[python]": {
|
3 |
-
"editor.defaultFormatter": "ms-python.
|
4 |
},
|
5 |
"python.formatting.provider": "none"
|
6 |
}
|
|
|
1 |
{
|
2 |
"[python]": {
|
3 |
+
"editor.defaultFormatter": "ms-python.python"
|
4 |
},
|
5 |
"python.formatting.provider": "none"
|
6 |
}
|
app.py
CHANGED
@@ -33,8 +33,20 @@ i_search = gr.Interface(
|
|
33 |
outputs="json"
|
34 |
)
|
35 |
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
if __name__ == "__main__":
|
40 |
demo.launch()
|
|
|
33 |
outputs="json"
|
34 |
)
|
35 |
|
36 |
+
|
37 |
+
def embed_text(text):
|
38 |
+
arr = vdb.embed_text(text)
|
39 |
+
json_data = json.dumps(arr.tolist())
|
40 |
+
return json_data
|
41 |
+
|
42 |
+
i_embed = gr.Interface(
|
43 |
+
fn=embed_text,
|
44 |
+
inputs=["text"],
|
45 |
+
outputs="json"
|
46 |
+
)
|
47 |
+
|
48 |
+
demo = gr.TabbedInterface([i_upsert, i_search, i_embed], [
|
49 |
+
"upsert role", "search roles", "embed text"])
|
50 |
|
51 |
if __name__ == "__main__":
|
52 |
demo.launch()
|
faiss_vdb.py
CHANGED
@@ -76,7 +76,7 @@ def clear_existing(id):
|
|
76 |
|
77 |
|
78 |
def embed_text(txt):
|
79 |
-
emb = [db.embedding_function()]
|
80 |
vector = np.array(emb, dtype=np.float32)
|
81 |
if db._normalize_L2:
|
82 |
faiss = db.dependable_faiss_import()
|
|
|
76 |
|
77 |
|
78 |
def embed_text(txt):
|
79 |
+
emb = [db.embedding_function(txt)]
|
80 |
vector = np.array(emb, dtype=np.float32)
|
81 |
if db._normalize_L2:
|
82 |
faiss = db.dependable_faiss_import()
|