MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / query

Method query

embedding/embeddingHelper.py:90–128  ·  view source on GitHub ↗
(self, text, topK=5, where=None, where_document=None)

Source from the content-addressed store, hash-verified

88 self.redisCaching = RedisCaching()
89
90 def query(self, text, topK=5, where=None, where_document=None):
91 # where={"metadata_field": "is_equal_to_this"},
92 # where_document={"$contains": "search_string"}
93 if self.need_redis:
94 starttime = time.time()
95 res = self.query_preprocessing(text, top_k=topK)
96 if res is not None:
97 if len(res) >= 1:
98 return res
99 if where is None:
100 if where_document is None:
101 result = self.collection.query(
102 query_texts=[text],
103 n_results=topK
104 )
105 else:
106 result = self.collection.query(
107 query_texts=[text],
108 n_results=topK,
109 )
110 else:
111 if where_document is None:
112 result = self.collection.query(
113 query_texts=[text],
114 n_results=topK,
115 where=where
116 )
117 else:
118 result = self.collection.query(
119 query_texts=[text],
120 n_results=topK,
121 where=where
122 )
123
124 result = self.processResult(query=[text], result=result)
125 """
126 result : [[]] 第一层为查询的数量,现在为1,第二层为每一次查询的相似度结果
127 """
128 return result
129
130 def batchQuery(self, texts, topK=5, where=None, where_document=None):
131 # where={"metadata_field": "is_equal_to_this"},

Callers 12

query_allMethod · 0.80
query_latest_idMethod · 0.80
query_latest_offsetMethod · 0.80
query_by_idMethod · 0.80
query_by_idWithSortMethod · 0.80
delete_by_idMethod · 0.80
askFileMethod · 0.80
batchQueryMethod · 0.80
queryByEmbeddingMethod · 0.80
batchQueryByEmbeddingMethod · 0.80
similarity_searchMethod · 0.80

Calls 2

query_preprocessingMethod · 0.95
processResultMethod · 0.95

Tested by

no test coverage detected