fix: lint

This commit is contained in:
Nicholas Tindle
2025-01-26 19:06:52 +00:00
parent eddcc97814
commit cebbdde75e
2 changed files with 29 additions and 29 deletions

View File

@@ -4,18 +4,12 @@ from abc import ABC
from enum import Enum, EnumMeta
from json import JSONDecodeError
from types import MappingProxyType
from typing import (
TYPE_CHECKING,
Any,
List,
Literal,
NamedTuple,
)
from typing import TYPE_CHECKING, Any, List, Literal, NamedTuple
from backend.util.file import MediaFile, store_media_file
from pydantic import SecretStr
from backend.integrations.providers import ProviderName
from backend.util.file import MediaFile, store_media_file
if TYPE_CHECKING:
from enum import _EnumMemberT
@@ -217,10 +211,16 @@ MODEL_METADATA = {
ModelProvider.OPENAI, ModelCreator.OPENAI, 16385
),
LlmModel.CLAUDE_3_5_SONNET: ModelMetadata(
ModelProvider.ANTHROPIC, ModelCreator.ANTHROPIC, 200000
ModelProvider.ANTHROPIC,
ModelCreator.ANTHROPIC,
200000,
ModelCapabilities(supports_images=True),
),
LlmModel.CLAUDE_3_HAIKU: ModelMetadata(
ModelProvider.ANTHROPIC, ModelCreator.ANTHROPIC, 200000
ModelProvider.ANTHROPIC,
ModelCreator.ANTHROPIC,
200000,
ModelCapabilities(supports_images=True),
),
LlmModel.LLAMA3_8B: ModelMetadata(ModelProvider.GROQ, ModelCreator.META, 8192),
LlmModel.LLAMA3_70B: ModelMetadata(ModelProvider.GROQ, ModelCreator.META, 8192),

View File

@@ -44,29 +44,29 @@ def store_media_file(
graph_exec_id: str, file: MediaFile, return_content: bool = False
) -> MediaFile:
"""
Safely handle 'file' (a data URI, a URL, or a local path relative to {temp}/exec_file/{exec_id}),
placing or verifying it under:
{tempdir}/exec_file/{exec_id}/...
Safely handle 'file' (a data URI, a URL, or a local path relative to {temp}/exec_file/{exec_id}),
placing or verifying it under:
{tempdir}/exec_file/{exec_id}/...
If 'return_content=True', return a data URI (data:<mime>;base64,<content>).
Otherwise, returns the file media path relative to the exec_id folder.
If 'return_content=True', return a data URI (data:<mime>;base64,<content>).
Otherwise, returns the file media path relative to the exec_id folder.
For each MediaFile type:
- Data URI:
-> decode and store in a new random file in that folder
- URL:
-> download and store in that folder
- Local path:
-> interpret as relative to that folder; verify it exists
(no copying, as it's presumably already there).
We realpath-check so no symlink or '..' can escape the folder.
For each MediaFile type:
- Data URI:
-> decode and store in a new random file in that folder
- URL:
-> download and store in that folder
- Local path:
-> interpret as relative to that folder; verify it exists
(no copying, as it's presumably already there).
We realpath-check so no symlink or '..' can escape the folder.
:param graph_exec_id: The unique ID of the graph execution.
:param file: Data URI, URL, or local (relative) path.
:param return_content: If True, return a data URI of the file content.
If False, return the *relative* path inside the exec_id folder.
:return: The requested result: data URI or relative path of the media.
:param graph_exec_id: The unique ID of the graph execution.
:param file: Data URI, URL, or local (relative) path.
:param return_content: If True, return a data URI of the file content.
If False, return the *relative* path inside the exec_id folder.
:return: The requested result: data URI or relative path of the media.
"""
# Build base path
base_path = Path(get_exec_file_path(graph_exec_id, ""))