mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
LiteLLM Contributor PRs (02/18/2025). (#8643)
* fix: prisma migration script logging #6991 (#8617) * fix: prisma migration script logging #6991 * chore: refactor usng proxy logger * remove noqa and move import below abs path * Fix(litellm-vetexai-gemini): adding the supported files as per gemini documentation (#8559) * bugfix(litellm-vetexai-gemini): adding the supported files as per gemini documentations * fix(files.py): correct file type constant from 'text' to 'TXT' * test: handle internal server error --------- Co-authored-by: Justin Law <81255462+justinthelaw@users.noreply.github.com> Co-authored-by: alymedhat10 <48028013+alymedhat10@users.noreply.github.com>
This commit is contained in:
parent
cc77138b37
commit
982ee4b96b
2 changed files with 31 additions and 12 deletions
|
@ -10,6 +10,7 @@ sys.path.insert(
|
|||
0, os.path.abspath("./")
|
||||
) # Adds the parent directory to the system path
|
||||
from litellm.secret_managers.aws_secret_manager import decrypt_env_var
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
|
||||
if os.getenv("USE_AWS_KMS", None) is not None and os.getenv("USE_AWS_KMS") == "True":
|
||||
## V2 IMPLEMENTATION OF AWS KMS - USER WANTS TO DECRYPT MULTIPLE KEYS IN THEIR ENV
|
||||
|
@ -21,6 +22,7 @@ if os.getenv("USE_AWS_KMS", None) is not None and os.getenv("USE_AWS_KMS") == "T
|
|||
# Check if DATABASE_URL is not set
|
||||
database_url = os.getenv("DATABASE_URL")
|
||||
if not database_url:
|
||||
verbose_proxy_logger.info("Constructing DATABASE_URL from environment variables")
|
||||
# Check if all required variables are provided
|
||||
database_host = os.getenv("DATABASE_HOST")
|
||||
database_username = os.getenv("DATABASE_USERNAME")
|
||||
|
@ -30,12 +32,14 @@ if not database_url:
|
|||
if database_host and database_username and database_password and database_name:
|
||||
# Construct DATABASE_URL from the provided variables
|
||||
database_url = f"postgresql://{database_username}:{database_password}@{database_host}/{database_name}"
|
||||
os.environ["DATABASE_URL"] = database_url
|
||||
os.environ["DATABASE_URL"] = database_url # Log the constructed URL
|
||||
else:
|
||||
print( # noqa
|
||||
verbose_proxy_logger.error(
|
||||
"Error: Required database environment variables are not set. Provide a postgres url for DATABASE_URL." # noqa
|
||||
)
|
||||
exit(1)
|
||||
else:
|
||||
verbose_proxy_logger.info("Using existing DATABASE_URL environment variable") # Log existing DATABASE_URL
|
||||
|
||||
# Set DIRECT_URL to the value of DATABASE_URL if it is not set, required for migrations
|
||||
direct_url = os.getenv("DIRECT_URL")
|
||||
|
@ -49,29 +53,40 @@ exit_code = 1
|
|||
|
||||
disable_schema_update = os.getenv("DISABLE_SCHEMA_UPDATE")
|
||||
if disable_schema_update is not None and disable_schema_update == "True":
|
||||
print("Skipping schema update...") # noqa
|
||||
verbose_proxy_logger.info("Skipping schema update...")
|
||||
exit(0)
|
||||
|
||||
while retry_count < max_retries and exit_code != 0:
|
||||
retry_count += 1
|
||||
print(f"Attempt {retry_count}...") # noqa
|
||||
verbose_proxy_logger.info(f"Attempt {retry_count}...")
|
||||
|
||||
# run prisma generate
|
||||
result = subprocess.run(["prisma", "generate"], capture_output=True)
|
||||
verbose_proxy_logger.info("Running 'prisma generate'...")
|
||||
result = subprocess.run(["prisma", "generate"], capture_output=True, text=True)
|
||||
verbose_proxy_logger.info(f"'prisma generate' stdout: {result.stdout}") # Log stdout
|
||||
exit_code = result.returncode
|
||||
|
||||
# Run the Prisma db push command
|
||||
result = subprocess.run(
|
||||
["prisma", "db", "push", "--accept-data-loss"], capture_output=True
|
||||
)
|
||||
exit_code = result.returncode
|
||||
|
||||
if exit_code != 0 and retry_count < max_retries:
|
||||
print("Retrying in 10 seconds...") # noqa
|
||||
time.sleep(10)
|
||||
|
||||
if exit_code != 0:
|
||||
print(f"Unable to push database changes after {max_retries} retries.") # noqa
|
||||
verbose_proxy_logger.info(f"'prisma generate' failed with exit code {exit_code}.")
|
||||
verbose_proxy_logger.error(f"'prisma generate' stderr: {result.stderr}") # Log stderr
|
||||
|
||||
# Run the Prisma db push command
|
||||
verbose_proxy_logger.info("Running 'prisma db push --accept-data-loss'...")
|
||||
result = subprocess.run(
|
||||
["prisma", "db", "push", "--accept-data-loss"], capture_output=True, text=True
|
||||
)
|
||||
verbose_proxy_logger.info(f"'prisma db push' stdout: {result.stdout}") # Log stdout
|
||||
exit_code = result.returncode
|
||||
|
||||
if exit_code != 0:
|
||||
verbose_proxy_logger.info(f"'prisma db push' stderr: {result.stderr}") # Log stderr
|
||||
verbose_proxy_logger.error(f"'prisma db push' failed with exit code {exit_code}.")
|
||||
if retry_count < max_retries:
|
||||
verbose_proxy_logger.info("Retrying in 10 seconds...")
|
||||
time.sleep(10)
|
||||
|
||||
if retry_count == max_retries and exit_code != 0:
|
||||
verbose_proxy_logger.error(f"Unable to push database changes after {max_retries} retries.")
|
||||
exit(1)
|
||||
|
||||
print("Database push successful!") # noqa
|
||||
verbose_proxy_logger.info("Database push successful!")
|
||||
|
|
|
@ -251,15 +251,18 @@ GEMINI_1_5_ACCEPTED_FILE_TYPES: Set[FileType] = {
|
|||
# Image
|
||||
FileType.PNG,
|
||||
FileType.JPEG,
|
||||
FileType.WEBP,
|
||||
# Audio
|
||||
FileType.AAC,
|
||||
FileType.FLAC,
|
||||
FileType.MP3,
|
||||
FileType.MPA,
|
||||
FileType.MPEG,
|
||||
FileType.MPGA,
|
||||
FileType.OPUS,
|
||||
FileType.PCM,
|
||||
FileType.WAV,
|
||||
FileType.WEBM,
|
||||
# Video
|
||||
FileType.FLV,
|
||||
FileType.MOV,
|
||||
|
@ -272,6 +275,7 @@ GEMINI_1_5_ACCEPTED_FILE_TYPES: Set[FileType] = {
|
|||
FileType.THREE_GPP,
|
||||
# PDF
|
||||
FileType.PDF,
|
||||
FileType.TXT,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue