Skip to content

Commit

Permalink
Merge pull request #883 from PrefectHQ/fix-settings-bleed
Browse files Browse the repository at this point in the history
avoid settings bleed
  • Loading branch information
zzstoatzz authored Mar 25, 2024
2 parents 58765ea + 9ec1f76 commit 0da9680
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/marvin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def __setattr__(self, name: str, value: Any) -> None:


class ChatCompletionSettings(MarvinSettings):
model_config = SettingsConfigDict(env_prefix="marvin_chat_completions_")
model_config = SettingsConfigDict(
env_prefix="marvin_chat_completions_", extra="ignore"
)
model: str = Field(
description="The default chat model to use.", default="gpt-4-1106-preview"
)
Expand All @@ -53,7 +55,7 @@ def encoder(self):


class ChatVisionSettings(MarvinSettings):
model_config = SettingsConfigDict(env_prefix="marvin_chat_vision_")
model_config = SettingsConfigDict(env_prefix="marvin_chat_vision_", extra="ignore")
model: str = Field(
description="The default vision model to use.", default="gpt-4-vision-preview"
)
Expand All @@ -68,6 +70,7 @@ def encoder(self):


class ChatSettings(MarvinSettings):
model_config = SettingsConfigDict(env_prefix="marvin_chat_", extra="ignore")
completions: ChatCompletionSettings = Field(default_factory=ChatCompletionSettings)
vision: ChatVisionSettings = Field(default_factory=ChatVisionSettings)

Expand All @@ -82,7 +85,7 @@ class ImageSettings(MarvinSettings):
style: The default style to use, defaults to `vivid`.
"""

model_config = SettingsConfigDict(env_prefix="marvin_image_")
model_config = SettingsConfigDict(env_prefix="marvin_image_", extra="ignore")

model: str = Field(
default="dall-e-3",
Expand Down Expand Up @@ -112,7 +115,10 @@ class SpeechSettings(MarvinSettings):
speed: The default speed to use, defaults to `1.0`.
"""

model_config = SettingsConfigDict(env_prefix="marvin_speech_")
model_config = SettingsConfigDict(
env_prefix="marvin_speech_",
extra="ignore",
)

model: str = Field(
default="tts-1-hd",
Expand Down Expand Up @@ -141,6 +147,10 @@ class AssistantSettings(MarvinSettings):


class AudioSettings(MarvinSettings):
"""Settings for the audio API."""

model_config = SettingsConfigDict(env_prefix="marvin_audio_", extra="ignore")

speech: SpeechSettings = Field(default_factory=SpeechSettings)


Expand Down Expand Up @@ -169,6 +179,7 @@ class OpenAISettings(MarvinSettings):

model_config = SettingsConfigDict(
env_prefix="marvin_openai_",
extra="ignore",
)

api_key: Optional[SecretStr] = Field(
Expand Down Expand Up @@ -201,11 +212,13 @@ def discover_api_key(cls, v):


class TextAISettings(MarvinSettings):
model_config = SettingsConfigDict(env_prefix="marvin_ai_text_")
model_config = SettingsConfigDict(env_prefix="marvin_ai_text_", extra="ignore")
generate_cache_token_cap: int = Field(600)


class AISettings(MarvinSettings):
model_config = SettingsConfigDict(env_prefix="marvin_ai_", extra="ignore")

text: TextAISettings = Field(default_factory=TextAISettings)


Expand Down

0 comments on commit 0da9680

Please sign in to comment.