Query the code memory. Args: query_text (str): The query text n_results (int): The number of results to return Returns: List[Dict]: The query results list
(self, query_text: str, n_results: int = 5)
| 34 | self.add_query(code_files, self.collection_name) |
| 35 | |
| 36 | def query_code(self, query_text: str, n_results: int = 5) -> List[Dict]: |
| 37 | """ |
| 38 | Query the code memory. |
| 39 | |
| 40 | Args: |
| 41 | query_text (str): The query text |
| 42 | n_results (int): The number of results to return |
| 43 | |
| 44 | Returns: |
| 45 | List[Dict]: The query results list |
| 46 | """ |
| 47 | results = self.query([query_text], self.collection_name, n_results) |
| 48 | return [ |
| 49 | { |
| 50 | "file": doc.split('\n')[0].replace("File: ", ""), |
| 51 | "content": '\n'.join(doc.split('\n')[3:]), |
| 52 | "metadata": metadata |
| 53 | } |
| 54 | for doc, metadata in zip(results['documents'][0], results['metadatas'][0]) |
| 55 | ] |
| 56 | |
| 57 | class CodeReranker(Reranker): |
| 58 | def __init__(self, model: str) -> None: |