gpt4free/g4f/typing.py
hlohaus c083f85206 feat: improve file handling and streamline provider implementations
- Added file upload usage example with bucket_id in docs/file.md
- Fixed ARTA provider by refactoring error handling with a new raise_error function
- Simplified aspect_ratio handling in ARTA with proper default
- Improved AllenAI provider by cleaning up image handling logic
- Fixed Blackbox provider's media handling to properly process images
- Updated file tools to handle URL downloads correctly
- Fixed bucket_id pattern matching in ToolHandler.process_bucket_tool
- Cleaned up imports in typing.py by removing unnecessary sys import
- Fixed inconsistent function parameters in g4f/tools/files.py
- Fixed return value of upload_and_process function to return bucket_id
2025-04-08 19:00:44 +02:00

42 lines
985 B
Python

import os
from typing import Any, AsyncGenerator, Generator, AsyncIterator, Iterator, NewType, Tuple, Union, List, Dict, Type, IO, Optional, TypedDict
try:
from PIL.Image import Image
except ImportError:
class Image:
pass
from .providers.response import ResponseType
SHA256 = NewType('sha_256_hash', str)
CreateResult = Iterator[Union[str, ResponseType]]
AsyncResult = AsyncIterator[Union[str, ResponseType]]
Messages = List[Dict[str, Union[str, List[Dict[str, Union[str, Dict[str, str]]]]]]]
Cookies = Dict[str, str]
ImageType = Union[str, bytes, IO, Image, os.PathLike]
MediaListType = List[Tuple[ImageType, Optional[str]]]
__all__ = [
'Any',
'AsyncGenerator',
'Generator',
'AsyncIterator',
'Iterator'
'Tuple',
'Union',
'List',
'Dict',
'Type',
'IO',
'Optional',
'TypedDict',
'SHA256',
'CreateResult',
'AsyncResult',
'Messages',
'Cookies',
'Image',
'ImageType',
'MediaListType'
]