Skip to content
Snippets Groups Projects
Commit e3f65bdb authored by maxyousif15's avatar maxyousif15
Browse files

refactor: addressing PR comments

parent b2139404
No related branches found
No related tags found
No related merge requests found
......@@ -28,11 +28,11 @@ class OpenAIEncoder(BaseEncoder):
name = os.getenv("OPENAI_MODEL_NAME", "text-embedding-ada-002")
super().__init__(name=name, score_threshold=score_threshold)
api_key = openai_api_key or os.getenv("OPENAI_API_KEY")
org_id = openai_org_id or os.getenv("OPENAI_ORGANIZATION")
if (api_key is None) and (org_id is None):
openai_org_id = openai_org_id or os.getenv("OPENAI_ORG_ID")
if (api_key is None):
raise ValueError("OpenAI API key cannot be 'None'.")
try:
self.client = openai.Client(api_key=api_key, organization=org_id)
self.client = openai.Client(api_key=api_key, organization=openai_org_id)
except Exception as e:
raise ValueError(
f"OpenAI API client failed to initialize. Error: {e}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment