shu/removeSettingsManager.get_settings (#1305)
This commit is contained in:
@@ -6,7 +6,7 @@ import aioboto3
|
||||
import structlog
|
||||
from aiobotocore.client import AioBaseClient
|
||||
|
||||
from skyvern.forge.sdk.settings_manager import SettingsManager
|
||||
from skyvern.config import settings
|
||||
|
||||
LOG = structlog.get_logger()
|
||||
|
||||
@@ -22,7 +22,7 @@ def execute_with_async_client(client_type: AWSClientType) -> Callable:
|
||||
self = args[0]
|
||||
assert isinstance(self, AsyncAWSClient)
|
||||
session = aioboto3.Session()
|
||||
async with session.client(client_type, region_name=SettingsManager.get_settings().AWS_REGION) as client:
|
||||
async with session.client(client_type, region_name=settings.AWS_REGION) as client:
|
||||
return await f(*args, client=client, **kwargs)
|
||||
|
||||
return wrapper
|
||||
@@ -95,7 +95,7 @@ class AsyncAWSClient:
|
||||
url = await client.generate_presigned_url(
|
||||
"get_object",
|
||||
Params={"Bucket": parsed_uri.bucket, "Key": parsed_uri.key},
|
||||
ExpiresIn=SettingsManager.get_settings().PRESIGNED_URL_EXPIRATION,
|
||||
ExpiresIn=settings.PRESIGNED_URL_EXPIRATION,
|
||||
)
|
||||
presigned_urls.append(url)
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ import aiohttp
|
||||
import structlog
|
||||
from multidict import CIMultiDictProxy
|
||||
|
||||
from skyvern.config import settings
|
||||
from skyvern.constants import REPO_ROOT_DIR
|
||||
from skyvern.exceptions import DownloadFileMaxSizeExceeded
|
||||
from skyvern.forge.sdk.api.aws import AsyncAWSClient
|
||||
from skyvern.forge.sdk.settings_manager import SettingsManager
|
||||
|
||||
LOG = structlog.get_logger()
|
||||
|
||||
@@ -169,7 +169,7 @@ def create_folder_if_not_exist(dir: str) -> None:
|
||||
|
||||
|
||||
def get_skyvern_temp_dir() -> str:
|
||||
temp_dir = SettingsManager.get_settings().TEMP_PATH
|
||||
temp_dir = settings.TEMP_PATH
|
||||
create_folder_if_not_exist(temp_dir)
|
||||
return temp_dir
|
||||
|
||||
@@ -178,13 +178,13 @@ def make_temp_directory(
|
||||
suffix: str | None = None,
|
||||
prefix: str | None = None,
|
||||
) -> str:
|
||||
temp_dir = SettingsManager.get_settings().TEMP_PATH
|
||||
temp_dir = settings.TEMP_PATH
|
||||
create_folder_if_not_exist(temp_dir)
|
||||
return tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=temp_dir)
|
||||
|
||||
|
||||
def create_named_temporary_file(delete: bool = True) -> tempfile._TemporaryFileWrapper:
|
||||
temp_dir = SettingsManager.get_settings().TEMP_PATH
|
||||
temp_dir = settings.TEMP_PATH
|
||||
create_folder_if_not_exist(temp_dir)
|
||||
return tempfile.NamedTemporaryFile(dir=temp_dir, delete=delete)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from typing import Any
|
||||
import litellm
|
||||
import structlog
|
||||
|
||||
from skyvern.config import settings
|
||||
from skyvern.forge import app
|
||||
from skyvern.forge.sdk.api.llm.config_registry import LLMConfigRegistry
|
||||
from skyvern.forge.sdk.api.llm.exceptions import (
|
||||
@@ -19,7 +20,6 @@ from skyvern.forge.sdk.api.llm.models import LLMAPIHandler, LLMConfig, LLMRouter
|
||||
from skyvern.forge.sdk.api.llm.utils import llm_messages_builder, parse_api_response
|
||||
from skyvern.forge.sdk.artifact.models import ArtifactType
|
||||
from skyvern.forge.sdk.models import Step
|
||||
from skyvern.forge.sdk.settings_manager import SettingsManager
|
||||
|
||||
LOG = structlog.get_logger()
|
||||
|
||||
@@ -50,7 +50,7 @@ class LLMAPIHandlerFactory:
|
||||
allowed_fails=llm_config.allowed_fails,
|
||||
allowed_fails_policy=llm_config.allowed_fails_policy,
|
||||
cooldown_time=llm_config.cooldown_time,
|
||||
set_verbose=(False if SettingsManager.get_settings().is_cloud_environment() else llm_config.set_verbose),
|
||||
set_verbose=(False if settings.is_cloud_environment() else llm_config.set_verbose),
|
||||
enable_pre_call_checks=True,
|
||||
)
|
||||
main_model_group = llm_config.main_model_group
|
||||
@@ -213,7 +213,7 @@ class LLMAPIHandlerFactory:
|
||||
response = await litellm.acompletion(
|
||||
model=llm_config.model_name,
|
||||
messages=messages,
|
||||
timeout=SettingsManager.get_settings().LLM_CONFIG_TIMEOUT,
|
||||
timeout=settings.LLM_CONFIG_TIMEOUT,
|
||||
**active_parameters,
|
||||
)
|
||||
LOG.info("LLM API call successful", llm_key=llm_key, model=llm_config.model_name)
|
||||
@@ -263,7 +263,7 @@ class LLMAPIHandlerFactory:
|
||||
def get_api_parameters(llm_config: LLMConfig | LLMRouterConfig) -> dict[str, Any]:
|
||||
return {
|
||||
"max_tokens": llm_config.max_output_tokens,
|
||||
"temperature": SettingsManager.get_settings().LLM_CONFIG_TEMPERATURE,
|
||||
"temperature": settings.LLM_CONFIG_TEMPERATURE,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import structlog
|
||||
|
||||
from skyvern.config import settings
|
||||
from skyvern.forge.sdk.api.llm.exceptions import (
|
||||
DuplicateLLMConfigError,
|
||||
InvalidLLMConfigError,
|
||||
@@ -7,7 +8,6 @@ from skyvern.forge.sdk.api.llm.exceptions import (
|
||||
NoProviderEnabledError,
|
||||
)
|
||||
from skyvern.forge.sdk.api.llm.models import LiteLLMParams, LLMConfig, LLMRouterConfig
|
||||
from skyvern.forge.sdk.settings_manager import SettingsManager
|
||||
|
||||
LOG = structlog.get_logger()
|
||||
|
||||
@@ -46,17 +46,17 @@ class LLMConfigRegistry:
|
||||
# if none of the LLM providers are enabled, raise an error
|
||||
if not any(
|
||||
[
|
||||
SettingsManager.get_settings().ENABLE_OPENAI,
|
||||
SettingsManager.get_settings().ENABLE_ANTHROPIC,
|
||||
SettingsManager.get_settings().ENABLE_AZURE,
|
||||
SettingsManager.get_settings().ENABLE_AZURE_GPT4O_MINI,
|
||||
SettingsManager.get_settings().ENABLE_BEDROCK,
|
||||
settings.ENABLE_OPENAI,
|
||||
settings.ENABLE_ANTHROPIC,
|
||||
settings.ENABLE_AZURE,
|
||||
settings.ENABLE_AZURE_GPT4O_MINI,
|
||||
settings.ENABLE_BEDROCK,
|
||||
]
|
||||
):
|
||||
raise NoProviderEnabledError()
|
||||
|
||||
|
||||
if SettingsManager.get_settings().ENABLE_OPENAI:
|
||||
if settings.ENABLE_OPENAI:
|
||||
LLMConfigRegistry.register_config(
|
||||
"OPENAI_GPT4_TURBO",
|
||||
LLMConfig(
|
||||
@@ -103,7 +103,7 @@ if SettingsManager.get_settings().ENABLE_OPENAI:
|
||||
)
|
||||
|
||||
|
||||
if SettingsManager.get_settings().ENABLE_ANTHROPIC:
|
||||
if settings.ENABLE_ANTHROPIC:
|
||||
LLMConfigRegistry.register_config(
|
||||
"ANTHROPIC_CLAUDE3",
|
||||
LLMConfig(
|
||||
@@ -151,7 +151,7 @@ if SettingsManager.get_settings().ENABLE_ANTHROPIC:
|
||||
),
|
||||
)
|
||||
|
||||
if SettingsManager.get_settings().ENABLE_BEDROCK:
|
||||
if settings.ENABLE_BEDROCK:
|
||||
# Supported through AWS IAM authentication
|
||||
LLMConfigRegistry.register_config(
|
||||
"BEDROCK_ANTHROPIC_CLAUDE3_OPUS",
|
||||
@@ -209,11 +209,11 @@ if SettingsManager.get_settings().ENABLE_BEDROCK:
|
||||
)
|
||||
|
||||
|
||||
if SettingsManager.get_settings().ENABLE_AZURE:
|
||||
if settings.ENABLE_AZURE:
|
||||
LLMConfigRegistry.register_config(
|
||||
"AZURE_OPENAI",
|
||||
LLMConfig(
|
||||
f"azure/{SettingsManager.get_settings().AZURE_DEPLOYMENT}",
|
||||
f"azure/{settings.AZURE_DEPLOYMENT}",
|
||||
[
|
||||
"AZURE_DEPLOYMENT",
|
||||
"AZURE_API_KEY",
|
||||
@@ -225,11 +225,11 @@ if SettingsManager.get_settings().ENABLE_AZURE:
|
||||
),
|
||||
)
|
||||
|
||||
if SettingsManager.get_settings().ENABLE_AZURE_GPT4O_MINI:
|
||||
if settings.ENABLE_AZURE_GPT4O_MINI:
|
||||
LLMConfigRegistry.register_config(
|
||||
"AZURE_OPENAI_GPT4O_MINI",
|
||||
LLMConfig(
|
||||
f"azure/{SettingsManager.get_settings().AZURE_GPT4O_MINI_DEPLOYMENT}",
|
||||
f"azure/{settings.AZURE_GPT4O_MINI_DEPLOYMENT}",
|
||||
[
|
||||
"AZURE_GPT4O_MINI_DEPLOYMENT",
|
||||
"AZURE_GPT4O_MINI_API_KEY",
|
||||
@@ -237,9 +237,9 @@ if SettingsManager.get_settings().ENABLE_AZURE_GPT4O_MINI:
|
||||
"AZURE_GPT4O_MINI_API_VERSION",
|
||||
],
|
||||
litellm_params=LiteLLMParams(
|
||||
api_base=SettingsManager.get_settings().AZURE_GPT4O_MINI_API_BASE,
|
||||
api_key=SettingsManager.get_settings().AZURE_GPT4O_MINI_API_KEY,
|
||||
api_version=SettingsManager.get_settings().AZURE_GPT4O_MINI_API_VERSION,
|
||||
api_base=settings.AZURE_GPT4O_MINI_API_BASE,
|
||||
api_key=settings.AZURE_GPT4O_MINI_API_KEY,
|
||||
api_version=settings.AZURE_GPT4O_MINI_API_VERSION,
|
||||
model_info={"model_name": "azure/gpt-4o-mini"},
|
||||
),
|
||||
supports_vision=True,
|
||||
|
||||
Reference in New Issue
Block a user