Pradhyut21 commited on
Commit
6704b62
·
1 Parent(s): 071b72b

fix: initialize OpenAI client with API_BASE_URL and API_KEY from env

Browse files
Files changed (1) hide show
  1. inference.py +6 -2
inference.py CHANGED
@@ -148,9 +148,13 @@ def main():
148
  print(f"ERROR: Server at {BASE_URL} is unreachable: {e}", file=sys.stderr)
149
  return
150
 
151
- api_key = os.environ.get("OPENAI_API_KEY", "dummy_key_for_validation")
 
152
 
153
- client = OpenAI(api_key=api_key)
 
 
 
154
  tasks = ["bug_detection", "security_audit", "architecture_review"]
155
  scores = {}
156
 
 
148
  print(f"ERROR: Server at {BASE_URL} is unreachable: {e}", file=sys.stderr)
149
  return
150
 
151
+ api_key = os.environ.get("API_KEY") or os.environ.get("OPENAI_API_KEY", "dummy_key_for_validation")
152
+ api_base_url = os.environ.get("API_BASE_URL")
153
 
154
+ if api_base_url:
155
+ client = OpenAI(api_key=api_key, base_url=api_base_url)
156
+ else:
157
+ client = OpenAI(api_key=api_key)
158
  tasks = ["bug_detection", "security_audit", "architecture_review"]
159
  scores = {}
160