MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / query

Method query

autoagent/memory/rag_memory.py:87–115  ·  view source on GitHub ↗

query: query the memery. Args: query_texts: the query texts to search in the memery. collection: the name of the collection to search. n_results: the number of results to return. Returns: QueryResult class QueryResult(TypedDict):

(self, query_texts: List[str], collection: str = None, n_results: int = 5)

Source from the content-addressed store, hash-verified

85 return ids
86
87 def query(self, query_texts: List[str], collection: str = None, n_results: int = 5) -> QueryResult:
88 """
89 query: query the memery.
90 Args:
91 query_texts: the query texts to search in the memery.
92 collection: the name of the collection to search.
93 n_results: the number of results to return.
94
95 Returns: QueryResult
96 class QueryResult(TypedDict):
97 ids: List[IDs]
98 embeddings: Optional[
99 Union[
100 List[Embeddings],
101 List[PyEmbeddings],
102 List[NDArray[Union[np.int32, np.float32]]],
103 ]
104 ]
105 documents: Optional[List[List[Document]]]
106 uris: Optional[List[List[URI]]]
107 data: Optional[List[Loadable]]
108 metadatas: Optional[List[List[Metadata]]]
109 distances: Optional[List[List[float]]]
110 included: Include
111 """
112 if not collection:
113 collection = self.collection_name
114 query_embedding = self.embedder(query_texts)
115 return self.client.get_or_create_collection(collection).query(query_embeddings=query_embedding, n_results=n_results)
116
117 def peek(self, collection: str = None, n_results: int = 20):
118 """

Callers 5

query_dbFunction · 0.80
query_codeMethod · 0.80
query_tableMethod · 0.80
query_codeMethod · 0.80
query_text_contentMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected