langchain done cli
This commit is contained in:
32
services/rag/langchain/cli.py
Normal file
32
services/rag/langchain/cli.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import click
|
||||
from loguru import logger
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Configure logging to output to both file and stdout as specified in requirements
|
||||
def setup_logging():
|
||||
# Create logs directory if it doesn't exist
|
||||
logs_dir = Path("logs")
|
||||
logs_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Add file logging with rotation
|
||||
logger.add("logs/dev.log", rotation="10 MB", retention="10 days")
|
||||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
"""Main CLI group"""
|
||||
setup_logging()
|
||||
pass
|
||||
|
||||
|
||||
@cli.command(name="ping", help="Ping command that outputs pong")
|
||||
def ping():
|
||||
"""Ping command that outputs pong"""
|
||||
logger.info("Ping command executed")
|
||||
click.echo("pong")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
Reference in New Issue
Block a user