mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-22 10:08:34 +00:00
feature:add markdown embedding
This commit is contained in:
parent
645530a31d
commit
a498f87bbb
@ -1,61 +1,61 @@
|
||||
from langchain.embeddings import HuggingFaceEmbeddings
|
||||
from langchain.vectorstores import Milvus
|
||||
from pymilvus import Collection,utility
|
||||
from pymilvus import connections, DataType, FieldSchema, CollectionSchema
|
||||
|
||||
# milvus = connections.connect(
|
||||
# alias="default",
|
||||
# host='localhost',
|
||||
# port="19530"
|
||||
# )
|
||||
# collection = Collection("book")
|
||||
|
||||
|
||||
# Get an existing collection.
|
||||
# collection.load()
|
||||
# from langchain.embeddings import HuggingFaceEmbeddings
|
||||
# from langchain.vectorstores import Milvus
|
||||
# from pymilvus import Collection,utility
|
||||
# from pymilvus import connections, DataType, FieldSchema, CollectionSchema
|
||||
#
|
||||
# search_params = {"metric_type": "L2", "params": {}, "offset": 5}
|
||||
# # milvus = connections.connect(
|
||||
# # alias="default",
|
||||
# # host='localhost',
|
||||
# # port="19530"
|
||||
# # )
|
||||
# # collection = Collection("book")
|
||||
#
|
||||
# results = collection.search(
|
||||
# data=[[0.1, 0.2]],
|
||||
# anns_field="book_intro",
|
||||
# param=search_params,
|
||||
# limit=10,
|
||||
# expr=None,
|
||||
# output_fields=['book_id'],
|
||||
# consistency_level="Strong"
|
||||
# )
|
||||
#
|
||||
# # get the IDs of all returned hits
|
||||
# results[0].ids
|
||||
# # Get an existing collection.
|
||||
# # collection.load()
|
||||
# #
|
||||
# # search_params = {"metric_type": "L2", "params": {}, "offset": 5}
|
||||
# #
|
||||
# # results = collection.search(
|
||||
# # data=[[0.1, 0.2]],
|
||||
# # anns_field="book_intro",
|
||||
# # param=search_params,
|
||||
# # limit=10,
|
||||
# # expr=None,
|
||||
# # output_fields=['book_id'],
|
||||
# # consistency_level="Strong"
|
||||
# # )
|
||||
# #
|
||||
# # # get the IDs of all returned hits
|
||||
# # results[0].ids
|
||||
# #
|
||||
# # # get the distances to the query vector from all returned hits
|
||||
# # results[0].distances
|
||||
# #
|
||||
# # # get the value of an output field specified in the search request.
|
||||
# # # vector fields are not supported yet.
|
||||
# # hit = results[0][0]
|
||||
# # hit.entity.get('title')
|
||||
#
|
||||
# # get the distances to the query vector from all returned hits
|
||||
# results[0].distances
|
||||
# # milvus = connections.connect(
|
||||
# # alias="default",
|
||||
# # host='localhost',
|
||||
# # port="19530"
|
||||
# # )
|
||||
# from pilot.vector_store.milvus_store import MilvusStore
|
||||
#
|
||||
# # get the value of an output field specified in the search request.
|
||||
# # vector fields are not supported yet.
|
||||
# hit = results[0][0]
|
||||
# hit.entity.get('title')
|
||||
|
||||
# milvus = connections.connect(
|
||||
# alias="default",
|
||||
# host='localhost',
|
||||
# port="19530"
|
||||
# )
|
||||
from pilot.vector_store.milvus_store import MilvusStore
|
||||
|
||||
data = ["aaa", "bbb"]
|
||||
model_name = "/Users/chenketing/Desktop/project/all-MiniLM-L6-v2"
|
||||
embeddings = HuggingFaceEmbeddings(model_name=model_name)
|
||||
|
||||
# text_embeddings = Text2Vectors()
|
||||
mivuls = MilvusStore(cfg={"url": "127.0.0.1", "port": "19530", "alias": "default", "table_name": "test_k"})
|
||||
|
||||
mivuls.insert(["textc","tezt2"])
|
||||
print("success")
|
||||
|
||||
# mivuls.from_texts(texts=data, embedding=embeddings)
|
||||
# docs,
|
||||
# embedding=embeddings,
|
||||
# connection_args={"host": "127.0.0.1", "port": "19530", "alias": "default"}
|
||||
# )
|
||||
# data = ["aaa", "bbb"]
|
||||
# model_name = "xx/all-MiniLM-L6-v2"
|
||||
# embeddings = HuggingFaceEmbeddings(model_name=model_name)
|
||||
#
|
||||
# # text_embeddings = Text2Vectors()
|
||||
# mivuls = MilvusStore(cfg={"url": "127.0.0.1", "port": "19530", "alias": "default", "table_name": "test_k"})
|
||||
#
|
||||
# mivuls.insert(["textc","tezt2"])
|
||||
# print("success")
|
||||
# ct
|
||||
# # mivuls.from_texts(texts=data, embedding=embeddings)
|
||||
# # docs,
|
||||
# # embedding=embeddings,
|
||||
# # connection_args={"host": "127.0.0.1", "port": "19530", "alias": "default"}
|
||||
# # )
|
Loading…
Reference in New Issue
Block a user