-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (34 loc) · 1.74 KB
/
Copy pathmain.py
File metadata and controls
44 lines (34 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from ingest import ingest_command
from query import query_command
import typer # a library for building CLI (Command Line Interface) apps easily
from rich import print as rprint # an enhanced print function for styled/colored terminal output
app = typer.Typer(help="Multi-agent RAG system") # "Multi-agent RAG system" is the help description shown when running "python main.py --help"
# register commands
@app.command(name="ingest") # register externally defined function "def ingest_command()" -> python main.py ingest ./files
def ingest(path: str):
ingest_command(path)
@app.command(name="query") # python main.py query "What is AI?"
def query(
query_text: str,
ui: bool = typer.Option(False, "--ui", help="Enable clean output for Web UI")
):
query_command(query_text, ui=ui)
@app.callback() # define a root-level callback
def main(
verbose: bool = typer.Option(True, "--verbose", "-v", help="Enable verbose mode"),
ui: bool = typer.Option(False, "--ui", help="Global UI flag")
):
"""
For global initialization, initing logging, loading settings, warming up models ...
@app.callback(): run before any specific command (query or ingest)
"""
"""
If --ui is passed, we disable Rich styling and verbose logs
to ensure the Node.js bridge gets clean text.
"""
if ui:
verbose = False
if verbose:
rprint("[yellow]Initializing multi-agent RAG system...[/yellow]")
if __name__ == "__main__":
app() # call app() to start CLI