Query the table and return the results
(
self,
query_text: str,
collection: str = None,
n_results: int = 5
)
| 53 | print(f"Batch {i+1}/{num_batches} added") |
| 54 | |
| 55 | def query_table( |
| 56 | self, |
| 57 | query_text: str, |
| 58 | collection: str = None, |
| 59 | n_results: int = 5 |
| 60 | ) -> pd.DataFrame: |
| 61 | """ |
| 62 | Query the table and return the results |
| 63 | """ |
| 64 | if not collection: |
| 65 | collection = self.collection_name |
| 66 | results = self.query([query_text], collection=collection, n_results=n_results) |
| 67 | |
| 68 | metadata_results = results['metadatas'][0] |
| 69 | |
| 70 | df_results = pd.DataFrame([json.loads(item['response']) for item in metadata_results]) |
| 71 | return df_results |
| 72 | |
| 73 | def peek_table(self, collection: str = None, n_results: int = 20) -> pd.DataFrame: |
| 74 | """ |
no test coverage detected