marvin.settings
Settings for configuring marvin
.
AssistantSettings
¶
Settings for the assistant API.
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
The default assistant model to use |
AudioSettings
¶
Settings for the audio API.
ImageSettings
¶
Settings for OpenAI's image API.
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
The default image model to use, defaults to |
size |
Literal['1024x1024', '1792x1024', '1024x1792']
|
The default image size to use, defaults to |
response_format |
Literal['url', 'b64_json']
|
The default response format to use, defaults to |
style |
Literal['vivid', 'natural']
|
The default style to use, defaults to |
OpenAISettings
¶
Settings for the OpenAI API.
Attributes:
Name | Type | Description |
---|---|---|
api_key |
Optional[SecretStr]
|
Your OpenAI API key. |
organization |
Optional[str]
|
Your OpenAI organization ID. |
llms |
Optional[str]
|
Settings for the chat API. |
images |
ImageSettings
|
Settings for the images API. |
audio |
AudioSettings
|
Settings for the audio API. |
assistants |
AssistantSettings
|
Settings for the assistants API. |
Example
Set the OpenAI API key:
Settings
¶
Settings for marvin
.
This is the main settings object for marvin
.
Attributes:
Name | Type | Description |
---|---|---|
openai |
OpenAISettings
|
Settings for the OpenAI API. |
log_level |
str
|
The log level to use, defaults to |
Example
Set the log level to INFO
:
SpeechSettings
¶
Settings for OpenAI's speech API.
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
The default speech model to use, defaults to |
voice |
Literal['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer']
|
The default voice to use, defaults to |
response_format |
Literal['mp3', 'opus', 'aac', 'flac']
|
The default response format to use, defaults to |
speed |
float
|
The default speed to use, defaults to |
temporary_settings
¶
Temporarily override Marvin setting values, including nested settings objects.
To override nested settings, use __
to separate nested attribute names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
The settings to override, including nested settings. |
{}
|
Example
Temporarily override log level and OpenAI API key:
import marvin
from marvin.settings import temporary_settings
# Override top-level settings
with temporary_settings(log_level="INFO"):
assert marvin.settings.log_level == "INFO"
assert marvin.settings.log_level == "DEBUG"
# Override nested settings
with temporary_settings(openai__api_key="new-api-key"):
assert marvin.settings.openai.api_key.get_secret_value() == "new-api-key"
assert marvin.settings.openai.api_key.get_secret_value().startswith("sk-")