updates
This commit is contained in:
@@ -108,9 +108,10 @@ def send_to_openai(state: State):
|
||||
logging.info("Send requested but input buffer is empty.")
|
||||
return
|
||||
|
||||
api_key = os.environ.get("OPENAI_API_KEY") or os.environ.get("BG_AGENT_OPENAI_API_KEY")
|
||||
# Prefer config; fallback to env vars for convenience
|
||||
api_key = state.cfg.api_key or os.environ.get("OPENAI_API_KEY") or os.environ.get("BG_AGENT_OPENAI_API_KEY")
|
||||
if not api_key:
|
||||
logging.error("OPENAI_API_KEY not set. Cannot send.")
|
||||
logging.error("No API key configured. Set in config.py or OPENAI_API_KEY.")
|
||||
return
|
||||
|
||||
# Lazy import to keep startup quick
|
||||
@@ -120,7 +121,8 @@ def send_to_openai(state: State):
|
||||
logging.exception(f"OpenAI SDK not available: {e}")
|
||||
return
|
||||
|
||||
client = OpenAI(api_key=api_key)
|
||||
base = state.cfg.endpoint_base or "https://api.openai.com/v1"
|
||||
client = OpenAI(api_key=api_key, base_url=base)
|
||||
|
||||
# Build chat message with multiple images
|
||||
content_items = [{"type": "text", "text": state.cfg.prompt}]
|
||||
|
||||
@@ -19,6 +19,10 @@ class Settings:
|
||||
)
|
||||
retries: int = 3
|
||||
request_timeout_s: int = 60
|
||||
# Configurable API base and key. If left empty, env vars are used.
|
||||
# Typical base: https://api.openai.com/v1
|
||||
endpoint_base: str = os.environ.get("OPENAI_BASE_URL", "https://api.openai.com/v1")
|
||||
api_key: str = os.environ.get("OPENAI_API_KEY", os.environ.get("BG_AGENT_OPENAI_API_KEY", ""))
|
||||
|
||||
# Typing and clipboard behavior
|
||||
type_interval_s: float = 0.015
|
||||
|
||||
Reference in New Issue
Block a user