61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
CLI entry point for the RAG solution using LlamaIndex and Qdrant.
|
|
"""
|
|
|
|
import click
|
|
from loguru import logger
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def setup_logging():
|
|
"""Setup logging with loguru to file and stdout."""
|
|
# Create logs directory if it doesn't exist
|
|
logs_dir = Path("logs")
|
|
logs_dir.mkdir(exist_ok=True)
|
|
|
|
# Remove default logger to customize it
|
|
logger.remove()
|
|
|
|
# Add file handler with rotation
|
|
logger.add(
|
|
"logs/dev.log",
|
|
rotation="10 MB",
|
|
retention="10 days",
|
|
level="INFO",
|
|
format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {file}:{line} | {message}"
|
|
)
|
|
|
|
# Add stdout handler
|
|
logger.add(
|
|
sys.stdout,
|
|
level="INFO",
|
|
format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}",
|
|
colorize=True
|
|
)
|
|
|
|
|
|
@click.group()
|
|
@click.version_option(version='1.0.0')
|
|
def main():
|
|
"""Main CLI entry point for the RAG solution."""
|
|
setup_logging()
|
|
logger.info("Starting RAG solution CLI")
|
|
|
|
|
|
@main.command(help="Basic connectivity test that returns 'pong'")
|
|
@click.option('--verbose', '-v', is_flag=True, help="Enable verbose output")
|
|
def ping(verbose):
|
|
"""Ping command that outputs 'pong'."""
|
|
if verbose:
|
|
logger.info("Executing ping command")
|
|
click.echo("pong")
|
|
logger.info("Ping command completed successfully")
|
|
else:
|
|
click.echo("pong")
|
|
logger.info("Ping command executed")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main() |