mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 12:07:34 +00:00
revert: do not use MySecretStr
We don't need this if we can set it to empty string. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
bc64635835
commit
2a34226727
86 changed files with 208 additions and 263 deletions
|
@ -6,9 +6,7 @@
|
|||
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from llama_stack.core.secret_types import MySecretStr
|
||||
from pydantic import BaseModel, Field, SecretStr
|
||||
|
||||
|
||||
class BedrockBaseConfig(BaseModel):
|
||||
|
@ -16,12 +14,12 @@ class BedrockBaseConfig(BaseModel):
|
|||
default_factory=lambda: os.getenv("AWS_ACCESS_KEY_ID"),
|
||||
description="The AWS access key to use. Default use environment variable: AWS_ACCESS_KEY_ID",
|
||||
)
|
||||
aws_secret_access_key: MySecretStr = Field(
|
||||
default_factory=lambda: MySecretStr(os.getenv("AWS_SECRET_ACCESS_KEY", "")),
|
||||
aws_secret_access_key: SecretStr = Field(
|
||||
default_factory=lambda: SecretStr(os.getenv("AWS_SECRET_ACCESS_KEY", "")),
|
||||
description="The AWS secret access key to use. Default use environment variable: AWS_SECRET_ACCESS_KEY",
|
||||
)
|
||||
aws_session_token: MySecretStr = Field(
|
||||
default_factory=lambda: MySecretStr(os.getenv("AWS_SESSION_TOKEN", "")),
|
||||
aws_session_token: SecretStr = Field(
|
||||
default_factory=lambda: SecretStr(os.getenv("AWS_SESSION_TOKEN", "")),
|
||||
description="The AWS session token to use. Default use environment variable: AWS_SESSION_TOKEN",
|
||||
)
|
||||
region_name: str | None = Field(
|
||||
|
|
|
@ -8,6 +8,7 @@ from collections.abc import AsyncGenerator, AsyncIterator
|
|||
from typing import Any
|
||||
|
||||
import litellm
|
||||
from pydantic import SecretStr
|
||||
|
||||
from llama_stack.apis.common.content_types import (
|
||||
InterleavedContent,
|
||||
|
@ -39,7 +40,6 @@ from llama_stack.apis.inference import (
|
|||
ToolPromptFormat,
|
||||
)
|
||||
from llama_stack.core.request_headers import NeedsRequestProviderData
|
||||
from llama_stack.core.secret_types import MySecretStr
|
||||
from llama_stack.log import get_logger
|
||||
from llama_stack.providers.utils.inference.model_registry import ModelRegistryHelper, ProviderModelEntry
|
||||
from llama_stack.providers.utils.inference.openai_compat import (
|
||||
|
@ -69,7 +69,7 @@ class LiteLLMOpenAIMixin(
|
|||
def __init__(
|
||||
self,
|
||||
litellm_provider_name: str,
|
||||
api_key_from_config: MySecretStr,
|
||||
api_key_from_config: SecretStr,
|
||||
provider_data_api_key_field: str,
|
||||
model_entries: list[ProviderModelEntry] | None = None,
|
||||
openai_compat_api_base: str | None = None,
|
||||
|
@ -255,7 +255,7 @@ class LiteLLMOpenAIMixin(
|
|||
**get_sampling_options(request.sampling_params),
|
||||
}
|
||||
|
||||
def get_api_key(self) -> MySecretStr:
|
||||
def get_api_key(self) -> SecretStr:
|
||||
provider_data = self.get_request_provider_data()
|
||||
key_field = self.provider_data_api_key_field
|
||||
if provider_data and getattr(provider_data, key_field, None):
|
||||
|
|
|
@ -11,6 +11,7 @@ from collections.abc import AsyncIterator
|
|||
from typing import Any
|
||||
|
||||
from openai import NOT_GIVEN, AsyncOpenAI
|
||||
from pydantic import SecretStr
|
||||
|
||||
from llama_stack.apis.inference import (
|
||||
Model,
|
||||
|
@ -24,7 +25,6 @@ from llama_stack.apis.inference import (
|
|||
OpenAIResponseFormatParam,
|
||||
)
|
||||
from llama_stack.apis.models import ModelType
|
||||
from llama_stack.core.secret_types import MySecretStr
|
||||
from llama_stack.log import get_logger
|
||||
from llama_stack.providers.utils.inference.model_registry import ModelRegistryHelper
|
||||
from llama_stack.providers.utils.inference.openai_compat import prepare_openai_completion_params
|
||||
|
@ -71,14 +71,14 @@ class OpenAIMixin(ModelRegistryHelper, ABC):
|
|||
allowed_models: list[str] = []
|
||||
|
||||
@abstractmethod
|
||||
def get_api_key(self) -> MySecretStr:
|
||||
def get_api_key(self) -> SecretStr:
|
||||
"""
|
||||
Get the API key.
|
||||
|
||||
This method must be implemented by child classes to provide the API key
|
||||
for authenticating with the OpenAI API or compatible endpoints.
|
||||
|
||||
:return: The API key as a MySecretStr
|
||||
:return: The API key as a SecretStr
|
||||
"""
|
||||
pass
|
||||
|
||||
|
|
|
@ -8,9 +8,8 @@ import re
|
|||
from enum import Enum
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic import BaseModel, Field, SecretStr, field_validator
|
||||
|
||||
from llama_stack.core.secret_types import MySecretStr
|
||||
from llama_stack.core.utils.config_dirs import RUNTIME_BASE_DIR
|
||||
|
||||
|
||||
|
@ -75,7 +74,7 @@ class PostgresKVStoreConfig(CommonConfig):
|
|||
port: int = 5432
|
||||
db: str = "llamastack"
|
||||
user: str
|
||||
password: MySecretStr = MySecretStr("")
|
||||
password: SecretStr = SecretStr("")
|
||||
ssl_mode: str | None = None
|
||||
ca_cert_path: str | None = None
|
||||
table_name: str = "llamastack_kvstore"
|
||||
|
@ -119,7 +118,7 @@ class MongoDBKVStoreConfig(CommonConfig):
|
|||
port: int = 27017
|
||||
db: str = "llamastack"
|
||||
user: str | None = None
|
||||
password: MySecretStr = MySecretStr("")
|
||||
password: SecretStr = SecretStr("")
|
||||
collection_name: str = "llamastack_kvstore"
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -9,9 +9,8 @@ from enum import StrEnum
|
|||
from pathlib import Path
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, SecretStr
|
||||
|
||||
from llama_stack.core.secret_types import MySecretStr
|
||||
from llama_stack.core.utils.config_dirs import RUNTIME_BASE_DIR
|
||||
|
||||
from .api import SqlStore
|
||||
|
@ -64,7 +63,7 @@ class PostgresSqlStoreConfig(SqlAlchemySqlStoreConfig):
|
|||
port: int = 5432
|
||||
db: str = "llamastack"
|
||||
user: str
|
||||
password: MySecretStr = MySecretStr("")
|
||||
password: SecretStr = SecretStr("")
|
||||
|
||||
@property
|
||||
def engine_str(self) -> str:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue