/ adk-sock-shop / agents / __init__.py
__init__.py
 1  """Supplier Intake Agent."""
 2  
 3  import logging
 4  import os
 5  
 6  import litellm
 7  
 8  from . import agent
 9  
10  # Set default OPENAI_API_KEY if not already set
11  if "OPENAI_API_KEY" not in os.environ:
12      api_key_file = "/run/secrets/openai-api-key"
13      if os.path.exists(api_key_file):
14          try:
15              with open(api_key_file, 'r') as f:
16                  api_key = f.read().strip()
17                  if api_key:
18                      os.environ["OPENAI_API_KEY"] = api_key
19                      logging.info(f"OPENAI_API_KEY set from file: {api_key}")
20          except Exception as e:
21              pass  # Silently ignore file read errors
22  else:
23      logging.info(f"OPENAI_API_KEY already set in environment")
24  
25  # Set the base URL for the OpenAI API to the Docker Model Runner URL
26  os.environ["OTEL_SDK_DISABLED"] = "true"
27  
28  # Enable logging with reduced verbosity
29  logging.basicConfig(
30      level=logging.INFO,  # Less verbose than DEBUG
31      format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
32      force=True,  # override ADK defaults
33  )
34  logging.getLogger("opentelemetry").setLevel(logging.ERROR)
35  logging.getLogger("google.adk").setLevel(logging.INFO)
36  logging.getLogger("LiteLLM").setLevel(logging.INFO)  # Much less verbose
37  logging.getLogger("litellm").setLevel(logging.INFO)  # Also reduce this
38  logging.getLogger("httpx").setLevel(logging.WARNING)  # Reduce HTTP logs
39  logging.getLogger("httpcore").setLevel(logging.WARNING)  # Reduce HTTP core logs
40  litellm.set_verbose = False  # Disable raw HTTP logs # type: ignore
41  
42  __all__ = ["agent"]