Skip to content

Commit

Permalink
feat(llm): update credentials loading for watsonx
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
  • Loading branch information
Tomas2D committed Oct 15, 2024
1 parent e0c5985 commit 44a79d3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/adapters/watsonx/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,13 @@ function createApiClient({
};
})();

accessToken = accessToken || getEnv("WATSONX_ACCESS_TOKEN");
apiKey = apiKey || getEnv("WATSONX_API_KEY");
if (accessToken && apiKey) {
throw new ValueError(`Use either "accessToken" or "apiKey".`);
} else if (!accessToken && !apiKey) {
accessToken = getEnv("WATSONX_ACCESS_TOKEN");
apiKey = accessToken ? undefined : getEnv("WATSONX_API_KEY");
}

if (!accessToken && !apiKey) {
throw new ValueError(
[
Expand Down

0 comments on commit 44a79d3

Please sign in to comment.