Spaces:
Runtime error
Runtime error
Commit ·
c072928
1
Parent(s): 2bbd375
Update tickets1.py
Browse files- tickets1.py +5 -5
tickets1.py
CHANGED
|
@@ -90,7 +90,7 @@ from pymilvus import connections, FieldSchema, CollectionSchema, DataType, Colle
|
|
| 90 |
|
| 91 |
|
| 92 |
# # Milvus parameters
|
| 93 |
-
connections.connect(host='127.0.0.1', port='
|
| 94 |
|
| 95 |
|
| 96 |
# In[25]:
|
|
@@ -103,7 +103,7 @@ default_server.listen_port
|
|
| 103 |
|
| 104 |
|
| 105 |
def create_milvus_collection(collection_name, dim):
|
| 106 |
-
connections.connect(host='127.0.0.1', port='
|
| 107 |
if utility.has_collection(collection_name):
|
| 108 |
utility.drop_collection(collection_name)
|
| 109 |
|
|
@@ -148,7 +148,7 @@ insert_pipe = (
|
|
| 148 |
.map('description', 'vec', ops.text_embedding.dpr(model_name='facebook/dpr-ctx_encoder-single-nq-base'))
|
| 149 |
.map('vec', 'vec', lambda x: x / np.linalg.norm(x, axis=0))
|
| 150 |
.map(('id', 'vec'), 'insert_status', ops.ann_insert.milvus_client(host='127.0.0.1',
|
| 151 |
-
port='
|
| 152 |
collection_name='latest_ticket_data'))
|
| 153 |
.output()
|
| 154 |
)
|
|
@@ -193,7 +193,7 @@ ans_pipe = (
|
|
| 193 |
.map('description', 'vec', ops.text_embedding.dpr(model_name="facebook/dpr-ctx_encoder-single-nq-base"))
|
| 194 |
.map('vec', 'vec', lambda x: x / np.linalg.norm(x, axis=0))
|
| 195 |
.map('vec', 'res', ops.ann_search.milvus_client(host='127.0.0.1',
|
| 196 |
-
port='
|
| 197 |
collection_name='latest_ticket_data',
|
| 198 |
limit=1))
|
| 199 |
.map('res', 'category', lambda x: [id_category[int(i[0])] for i in x])
|
|
@@ -224,7 +224,7 @@ def chat(message, history):
|
|
| 224 |
pipe.input('description')
|
| 225 |
.map('description', 'vec', ops.text_embedding.dpr(model_name="facebook/dpr-ctx_encoder-single-nq-base"))
|
| 226 |
.map('vec', 'vec', lambda x: x / np.linalg.norm(x, axis=0))
|
| 227 |
-
.map('vec', 'res', ops.ann_search.milvus_client(host='127.0.0.1', port='
|
| 228 |
.map('res', 'category', lambda x: [id_category[int(i[0])] for i in x])
|
| 229 |
.output('description', 'category')
|
| 230 |
)
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
# # Milvus parameters
|
| 93 |
+
connections.connect(host='127.0.0.1', port='19530')
|
| 94 |
|
| 95 |
|
| 96 |
# In[25]:
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
def create_milvus_collection(collection_name, dim):
|
| 106 |
+
connections.connect(host='127.0.0.1', port='19530')
|
| 107 |
if utility.has_collection(collection_name):
|
| 108 |
utility.drop_collection(collection_name)
|
| 109 |
|
|
|
|
| 148 |
.map('description', 'vec', ops.text_embedding.dpr(model_name='facebook/dpr-ctx_encoder-single-nq-base'))
|
| 149 |
.map('vec', 'vec', lambda x: x / np.linalg.norm(x, axis=0))
|
| 150 |
.map(('id', 'vec'), 'insert_status', ops.ann_insert.milvus_client(host='127.0.0.1',
|
| 151 |
+
port='19530',
|
| 152 |
collection_name='latest_ticket_data'))
|
| 153 |
.output()
|
| 154 |
)
|
|
|
|
| 193 |
.map('description', 'vec', ops.text_embedding.dpr(model_name="facebook/dpr-ctx_encoder-single-nq-base"))
|
| 194 |
.map('vec', 'vec', lambda x: x / np.linalg.norm(x, axis=0))
|
| 195 |
.map('vec', 'res', ops.ann_search.milvus_client(host='127.0.0.1',
|
| 196 |
+
port='19530',
|
| 197 |
collection_name='latest_ticket_data',
|
| 198 |
limit=1))
|
| 199 |
.map('res', 'category', lambda x: [id_category[int(i[0])] for i in x])
|
|
|
|
| 224 |
pipe.input('description')
|
| 225 |
.map('description', 'vec', ops.text_embedding.dpr(model_name="facebook/dpr-ctx_encoder-single-nq-base"))
|
| 226 |
.map('vec', 'vec', lambda x: x / np.linalg.norm(x, axis=0))
|
| 227 |
+
.map('vec', 'res', ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='latest_ticket_data', limit=1))
|
| 228 |
.map('res', 'category', lambda x: [id_category[int(i[0])] for i in x])
|
| 229 |
.output('description', 'category')
|
| 230 |
)
|