Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,7 @@ from datetime import timedelta
|
|
| 14 |
from datetime import timezone
|
| 15 |
from faster_whisper import WhisperModel
|
| 16 |
import io
|
|
|
|
| 17 |
|
| 18 |
app = Flask(__name__)
|
| 19 |
|
|
@@ -79,7 +80,11 @@ def search():
|
|
| 79 |
print('EMBEDDING TIME: ', time.time() - timh)
|
| 80 |
|
| 81 |
timh = time.time()
|
| 82 |
-
if collection_name == "jks":
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
else: results = client.search(collection_name=collection_name, query_vector=(qvector, sq), with_payload=True, limit=100)
|
| 84 |
print('SEARCH TIME: ', time.time() - timh)
|
| 85 |
|
|
@@ -88,8 +93,8 @@ def search():
|
|
| 88 |
new_results = []
|
| 89 |
if collection_name == 'jks':
|
| 90 |
for r in results:
|
| 91 |
-
if 'date' not in r
|
| 92 |
-
new_results.append({"text": r
|
| 93 |
else:
|
| 94 |
for r in results:
|
| 95 |
if 'context' in r.payload and r.payload['context'] != '':
|
|
|
|
| 14 |
from datetime import timezone
|
| 15 |
from faster_whisper import WhisperModel
|
| 16 |
import io
|
| 17 |
+
import requests
|
| 18 |
|
| 19 |
app = Flask(__name__)
|
| 20 |
|
|
|
|
| 80 |
print('EMBEDDING TIME: ', time.time() - timh)
|
| 81 |
|
| 82 |
timh = time.time()
|
| 83 |
+
if collection_name == "jks":
|
| 84 |
+
data = {"vector": sq, "with_payload": True, "limit": topN}
|
| 85 |
+
response = requests.post(qdrant_url+f'jks/points/search', json=data, headers={'Content-Type': 'application/json'})
|
| 86 |
+
|
| 87 |
+
# results = client.search(collection_name=collection_name, query_vector=sq, with_payload=True, limit=topN)
|
| 88 |
else: results = client.search(collection_name=collection_name, query_vector=(qvector, sq), with_payload=True, limit=100)
|
| 89 |
print('SEARCH TIME: ', time.time() - timh)
|
| 90 |
|
|
|
|
| 93 |
new_results = []
|
| 94 |
if collection_name == 'jks':
|
| 95 |
for r in results:
|
| 96 |
+
if 'date' not in r['payload']: r['payload']['date'] = '20200101'
|
| 97 |
+
new_results.append({"text": r['payload']['text'], "date": str(int(r['payload']['date'])), "id": r['id']}) # Implement your Qdrant search here
|
| 98 |
else:
|
| 99 |
for r in results:
|
| 100 |
if 'context' in r.payload and r.payload['context'] != '':
|