Skip to content

Commit

Permalink
Merge pull request #2255 from Agenta-AI/fix/sdk-api-key
Browse files Browse the repository at this point in the history
[Fix] (SDK) api key not fetched from self.api_key
  • Loading branch information
mmabrouk authored Nov 14, 2024
2 parents ce197c9 + 6f9af4f commit e9e54f8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions agenta-cli/agenta/sdk/agenta_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import logging
import toml
from os import getenv
from typing import Optional
from importlib.metadata import version

Expand Down Expand Up @@ -72,13 +72,13 @@ def init(

self.host = (
host
or os.environ.get("AGENTA_HOST")
or getenv("AGENTA_HOST")
or config.get("backend_host")
or config.get("host")
or "https://cloud.agenta.ai"
)

self.app_id = app_id or config.get("app_id") or os.environ.get("AGENTA_APP_ID")
self.app_id = app_id or config.get("app_id") or getenv("AGENTA_APP_ID")
# if not self.app_id:
# raise ValueError(
# "App ID must be specified. You can provide it in one of the following ways:\n"
Expand All @@ -87,9 +87,7 @@ def init(
# "3. As an environment variable 'AGENTA_APP_ID'."
# )

self.api_key = (
api_key or os.environ.get("AGENTA_API_KEY") or config.get("api_key")
)
self.api_key = api_key or getenv("AGENTA_API_KEY") or config.get("api_key")

self.tracing = Tracing(
url=f"{self.host}/api/observability/v1/otlp/traces", # type: ignore
Expand All @@ -103,15 +101,15 @@ def init(

self.api = AgentaApi(
base_url=self.host + "/api",
api_key=api_key if api_key else "",
api_key=self.api_key if self.api_key else "",
)

self.async_api = AsyncAgentaApi(
base_url=self.host + "/api",
api_key=api_key if api_key else "",
api_key=self.api_key if self.api_key else "",
)

self.base_id = os.environ.get("AGENTA_BASE_ID")
self.base_id = getenv("AGENTA_BASE_ID")

self.config = Config(
host=self.host,
Expand Down

0 comments on commit e9e54f8

Please sign in to comment.