Skip to content

Commit

Permalink
最新langchain
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghexian committed Apr 23, 2024
1 parent f00b2a9 commit ab8c4a7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sdk/integrations/langchain/vearch.py
Expand Up @@ -407,7 +407,7 @@ def similarity_search_by_vector(
],
},
"retrieval_param": {"metric_type": "InnerProduct", "efSearch": 64},
"limit": k,
"size": k,
"fields": meta_field_list,

}
Expand All @@ -433,6 +433,8 @@ def similarity_search_by_vector(
for item in res:
content = ""
meta_data={}
if self.flag:
item = item["_source"]
for item_key in item:
if item_key == "text":
content = item[item_key]
Expand Down Expand Up @@ -476,7 +478,7 @@ def similarity_search_with_score(
}
],
},
"limit": k,
"size": k,
"fields": meta_field_list,
"retrieval_param": {"metric_type": "InnerProduct", "efSearch": 64},

Expand Down Expand Up @@ -505,6 +507,7 @@ def similarity_search_with_score(
meta_data = {}
if self.flag:
score = item["_score"]
item = item["_source"]
for item_key in item:
if item_key == "text":
content = item[item_key]
Expand Down Expand Up @@ -585,12 +588,12 @@ def get(
continue
content = ""
meta_info = {}
for field in record:
for field in record["_source"]:
if field == "text":
content = record[field]
content = record["_source"][field]
continue
elif field in meta_field_list:
meta_info[field] = record[field]
meta_info[field] = record["_source"][field]
meta_field_list.remove(field)
continue
results[record["_id"]] = Document(
Expand All @@ -614,4 +617,4 @@ def get(
results[docs_detail["_id"]] = Document(
page_content=content, metadata=meta_info
)
return results
return results

0 comments on commit ab8c4a7

Please sign in to comment.