Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] (SDK) api key not fetched from self.api_key #2255

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading