Add a unified way to send images in chat: inline base64 data URLs (passed through natively) or auto-upload via image_input_mode="upload", which replaces inline data URLs with hosted URLs using upload_chat_image. - New fastgpt_client/images.py with content-part / data-URL helpers - image_input_mode + appId/outLinkAuthData params on create_chat_completion (sync and async); upload failures fall back to inline base64 - Tests covering helpers, both modes, validation, and fallback Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
"""FastGPT Python SDK
|
|
|
|
A Python client library for interacting with FastGPT's OpenAPI.
|
|
"""
|
|
|
|
from fastgpt_client.async_client import (
|
|
AsyncAppClient,
|
|
AsyncChatClient,
|
|
AsyncFastGPTClient,
|
|
)
|
|
from fastgpt_client.client import AppClient, ChatClient, FastGPTClient
|
|
from fastgpt_client.exceptions import (
|
|
APIError,
|
|
AuthenticationError,
|
|
FastGPTError,
|
|
RateLimitError,
|
|
StreamParseError,
|
|
ValidationError,
|
|
)
|
|
from fastgpt_client.images import (
|
|
decode_data_url,
|
|
encode_image_data_url,
|
|
image_part_from_bytes,
|
|
image_part_from_path,
|
|
image_url_part,
|
|
is_data_url,
|
|
)
|
|
from fastgpt_client.streaming import aiter_stream_events, iter_stream_events
|
|
from fastgpt_client.stream_types import FastGPTInteractiveEvent, FastGPTStreamEvent
|
|
|
|
__all__ = [
|
|
# Synchronous clients
|
|
"FastGPTClient",
|
|
"ChatClient",
|
|
"AppClient",
|
|
# Asynchronous clients
|
|
"AsyncFastGPTClient",
|
|
"AsyncChatClient",
|
|
"AsyncAppClient",
|
|
# Exceptions
|
|
"FastGPTError",
|
|
"APIError",
|
|
"AuthenticationError",
|
|
"RateLimitError",
|
|
"ValidationError",
|
|
"StreamParseError",
|
|
# Streaming helpers
|
|
"iter_stream_events",
|
|
"aiter_stream_events",
|
|
"FastGPTStreamEvent",
|
|
"FastGPTInteractiveEvent",
|
|
# Image helpers
|
|
"encode_image_data_url",
|
|
"decode_data_url",
|
|
"is_data_url",
|
|
"image_url_part",
|
|
"image_part_from_bytes",
|
|
"image_part_from_path",
|
|
]
|
|
|
|
__version__ = "0.1.0"
|