Spaces:
Runtime error
Runtime error
Commit
·
dcdad29
1
Parent(s):
8d355e0
Update main.py
Browse files
main.py
CHANGED
@@ -3,7 +3,15 @@ from qdrant_client.http import models
|
|
3 |
from flask_cors import CORS
|
4 |
import openai
|
5 |
import qdrant_client
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
import os
|
9 |
os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/'
|
@@ -28,8 +36,7 @@ client = qdrant_client.QdrantClient(
|
|
28 |
api_key="ZQ6jySuPxY5rSh0mJ4jDMoxbZsPqDdbqFBOPwotl9B8N0Ru3S8bzoQ"
|
29 |
)
|
30 |
|
31 |
-
|
32 |
-
#model = SentenceTransformer('models/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2') # good so far
|
33 |
collection_names = ["new_lir"] # replace with the collection name used on Qdrant
|
34 |
|
35 |
import re
|
@@ -87,7 +94,7 @@ def chat():
|
|
87 |
def perform_search_and_get_results(collection_name, query, limit=6):
|
88 |
search_results = client.search(
|
89 |
collection_name=collection_name,
|
90 |
-
query_vector=model.
|
91 |
limit=limit
|
92 |
)
|
93 |
resultes = []
|
@@ -106,7 +113,7 @@ def perform_search_and_get_results_with_filter(collection_name, query,reference_
|
|
106 |
search_results = client.search(
|
107 |
collection_name=collection_name,
|
108 |
query_filter=models.Filter(must=[models.FieldCondition(key="numero_article",match=models.MatchValue(value=reference_filter+"aymane",),)]),
|
109 |
-
query_vector=model.
|
110 |
limit=1
|
111 |
)
|
112 |
resultes = []
|
|
|
3 |
from flask_cors import CORS
|
4 |
import openai
|
5 |
import qdrant_client
|
6 |
+
|
7 |
+
|
8 |
+
# from sentence_transformers import SentenceTransformer
|
9 |
+
#model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2') # good so far
|
10 |
+
#model = SentenceTransformer('models/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2') # good so far
|
11 |
+
|
12 |
+
from langchain.embeddings import HuggingFaceEmbeddings
|
13 |
+
|
14 |
+
model = HuggingFaceEmbeddings(model_name='paraphrase-multilingual-MiniLM-L12-v2')
|
15 |
|
16 |
import os
|
17 |
os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/'
|
|
|
36 |
api_key="ZQ6jySuPxY5rSh0mJ4jDMoxbZsPqDdbqFBOPwotl9B8N0Ru3S8bzoQ"
|
37 |
)
|
38 |
|
39 |
+
|
|
|
40 |
collection_names = ["new_lir"] # replace with the collection name used on Qdrant
|
41 |
|
42 |
import re
|
|
|
94 |
def perform_search_and_get_results(collection_name, query, limit=6):
|
95 |
search_results = client.search(
|
96 |
collection_name=collection_name,
|
97 |
+
query_vector=model.embed_query(query).tolist(),
|
98 |
limit=limit
|
99 |
)
|
100 |
resultes = []
|
|
|
113 |
search_results = client.search(
|
114 |
collection_name=collection_name,
|
115 |
query_filter=models.Filter(must=[models.FieldCondition(key="numero_article",match=models.MatchValue(value=reference_filter+"aymane",),)]),
|
116 |
+
query_vector=model.embed_query(query).tolist(),
|
117 |
limit=1
|
118 |
)
|
119 |
resultes = []
|