-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable LiteLLM logging control 🙉 #722
base: main
Are you sure you want to change the base?
Changes from 5 commits
f7a601c
66cdc60
6e84fb6
ff032a1
bcecf37
b9853c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
import signal | ||
import sys | ||
from pathlib import Path | ||
from typing import Dict, Optional | ||
from typing import Optional | ||
|
||
import click | ||
import structlog | ||
|
@@ -246,6 +246,12 @@ def show_prompts(prompts: Optional[Path]) -> None: | |
default=None, | ||
help="Path to the vector SQLite database file (default: ./sqlite_data/vectordb.db)", | ||
) | ||
@click.option( | ||
"--enable-litellm", | ||
is_flag=True, | ||
default=False, | ||
help="Enable LiteLLM logging (includes LiteLLM Proxy, Router, and core)", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: not a big deal, but this feels like a cosmetic change rather than a functional one, only relevant for developers. For example, removing I would avoid exposing this to the end user with an additional option, and rather only rely on environment variables. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good point! I will make the change. |
||
def serve( | ||
port: Optional[int], | ||
proxy_port: Optional[int], | ||
|
@@ -267,11 +273,12 @@ def serve( | |
ca_key: Optional[str], | ||
server_cert: Optional[str], | ||
server_key: Optional[str], | ||
enable_litellm: bool, | ||
) -> None: | ||
"""Start the codegate server.""" | ||
try: | ||
# Create provider URLs dict from CLI options | ||
cli_provider_urls: Dict[str, str] = {} | ||
# Create provider URLs dictionary from CLI arguments | ||
cli_provider_urls = {} | ||
if vllm_url: | ||
cli_provider_urls["vllm"] = vllm_url | ||
if openai_url: | ||
|
@@ -281,6 +288,9 @@ def serve( | |
if ollama_url: | ||
cli_provider_urls["ollama"] = ollama_url | ||
|
||
# Create external loggers dictionary from CLI arguments | ||
cli_external_loggers = {"litellm": enable_litellm} | ||
|
||
# Load configuration with priority resolution | ||
cfg = Config.load( | ||
config_path=config, | ||
|
@@ -290,7 +300,8 @@ def serve( | |
cli_host=host, | ||
cli_log_level=log_level, | ||
cli_log_format=log_format, | ||
cli_provider_urls=cli_provider_urls, | ||
cli_provider_urls=cli_provider_urls if cli_provider_urls else None, | ||
cli_external_loggers=cli_external_loggers, | ||
model_base_path=model_base_path, | ||
embedding_model=embedding_model, | ||
certs_dir=certs_dir, | ||
|
@@ -302,8 +313,8 @@ def serve( | |
vec_db_path=vec_db_path, | ||
) | ||
|
||
# Set up logging first | ||
setup_logging(cfg.log_level, cfg.log_format) | ||
# Initialize logging | ||
setup_logging(cfg.log_level, cfg.log_format, cfg.external_loggers) | ||
logger = structlog.get_logger("codegate").bind(origin="cli") | ||
|
||
init_db_sync(cfg.db_path) | ||
|
@@ -505,7 +516,7 @@ def generate_certs( | |
cli_log_level=log_level, | ||
cli_log_format=log_format, | ||
) | ||
setup_logging(cfg.log_level, cfg.log_format) | ||
setup_logging(cfg.log_level, cfg.log_format, cfg.external_loggers) | ||
logger = structlog.get_logger("codegate").bind(origin="cli") | ||
|
||
ca = CertificateAuthority.get_instance() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to add the word "logging" to these environment variables. Else, it hints at enabling us disabling a whole component