diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-04-14 23:31:51 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-04-14 23:31:51 +0200 |
commit | cec0f3142c7ca1960984470a1a0f24e880bc8bdd (patch) | |
tree | ace720b02959849dd73ad0e6e0af47c0dd18ea97 /rag/cli.py | |
parent | d8bd9fab918597710185dbaee7257cd2393065d1 (diff) |
Add verbosity
Diffstat (limited to 'rag/cli.py')
-rw-r--r-- | rag/cli.py | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -28,7 +28,7 @@ def rag(generator: str, query: str, limit): for chunk in generator.generate(prompt): print(chunk, end="", flush=True) - print(f"\n\n") + print("\n\n") for i, doc in enumerate(documents): print(f"### Document {i}") print(f"**Title: {doc.title}**") @@ -65,7 +65,21 @@ def rag(generator: str, query: str, limit): type=click.Path(exists=True), default=None, ) -def main(query: Optional[str], generator: str, limit: int, directory: Optional[str]): +@click.option("-v", "--verbose", count=True) +def main( + query: Optional[str], generator: str, limit: int, directory: Optional[str], verbose +): + match verbose: + case 1: + level = "INFO" + case 2: + level = "DEBUG" + case 3: + level = "TRACE" + case _: + level = "ERROR" + log.remove() + log.add(lambda msg: tqdm.write(msg, end=""), colorize=True, level=level) if query: rag(generator, query, limit) elif directory: @@ -75,7 +89,5 @@ def main(query: Optional[str], generator: str, limit: int, directory: Optional[s if __name__ == "__main__": - log.remove() - log.add(lambda msg: tqdm.write(msg, end=""), colorize=True) load_dotenv() main() |