|
3 | 3 | from typing import ClassVar, Literal |
4 | 4 |
|
5 | 5 | from prefect.blocks.system import Secret |
| 6 | +from prefect.exceptions import ObjectNotFound |
6 | 7 | from prefect.variables import Variable |
7 | 8 | from pydantic import Field, field_validator, model_validator |
8 | 9 | from pydantic_settings import BaseSettings, SettingsConfigDict |
@@ -56,6 +57,10 @@ def validate_log_level(cls, v: str) -> str: |
56 | 57 | default="anthropic-api-key", |
57 | 58 | description="Name of the Prefect secret block containing Anthropic API key", |
58 | 59 | ) |
| 60 | + letta_api_key_secret_name: str = Field( |
| 61 | + default="letta-api-key", |
| 62 | + description="Name of the Prefect secret block containing Letta API key", |
| 63 | + ) |
59 | 64 |
|
60 | 65 | vector_store_type: Literal["turbopuffer"] = Field( |
61 | 66 | default="turbopuffer", description="Type of vector store to use" |
@@ -94,6 +99,12 @@ def _apply_post_validation_defaults(self) -> "SlackbotSettings": |
94 | 99 | os.environ["TURBOPUFFER_API_KEY"] = api_key |
95 | 100 | except Exception: |
96 | 101 | pass # If secret doesn't exist, turbopuffer will handle the error |
| 102 | + if not os.getenv("LETTA_API_KEY"): |
| 103 | + try: |
| 104 | + api_key = Secret.load(self.letta_api_key_secret_name, _sync=True).get() # type: ignore |
| 105 | + os.environ["LETTA_API_KEY"] = api_key |
| 106 | + except ObjectNotFound: |
| 107 | + pass # If secret doesn't exist, learning-sdk won't be used |
97 | 108 | if not self.admin_slack_user_id: |
98 | 109 | self.admin_slack_user_id = Variable.get("admin-slack-id", _sync=True) |
99 | 110 | return self |
|
0 commit comments