Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toolkit): input types #380

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

feat(toolkit): input types #380

wants to merge 4 commits into from

Conversation

badayvedat
Copy link
Contributor

@badayvedat badayvedat commented Jan 9, 2025

Proposed Interface

import os
from pydantic import BaseModel


from fal.toolkit.types import FileInput, ImageInput

class Input(BaseModel):
    image: ImageInput
    file: FileInput

input = Input(
    image="https://storage.googleapis.com/falserverless/model_tests/remove_background/elephant.jpg",
    file="https://raw.githubusercontent.com/fal-ai/fal/refs/heads/main/README.md"
)

with input.image.as_file() as file_path:
    # Path("/tmp/...")
    print(file_path)

with input.image.as_pil_image() as pil_image:
    # PIL.JpegImagePlugin.JpegImageFile ...
    print(pil_image)

with input.file.as_file() as file_path:
    # Path("/tmp/...")
    print(file_path)

@efiop efiop force-pushed the vedat/input-types branch 2 times, most recently from a35a293 to 24f88d4 Compare January 12, 2025 12:42
@efiop efiop force-pushed the vedat/input-types branch from 24f88d4 to ebdae0e Compare January 12, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants