From 514420dbe07a04f1e91b4f25e7068b6ec889655d Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Sat, 4 Nov 2023 18:05:22 -0700 Subject: [PATCH 1/5] feat: add build workflow --- .github/workflows/build.yml | 30 ++++++++++++++ README.md | 78 +++++++++++++++++++++++++------------ 2 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ccdaa6b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ + +name: Build + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Dart SDK + uses: dart-lang/setup-dart@v1 + with: + sdk: stable + + - name: Install dependencies + run: dart pub get + + - name: Build library + run: dart compile exe bin/main.dart + + - name: Build example app + run: dart compile exe example/main.dart diff --git a/README.md b/README.md index 02fe8ec..f56c432 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,67 @@ - +## About the Project -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. +The `fal_client` is a robust and user-friendly library designed for seamless integration of fal serverless functions in Dart and Flutter projects. Developed in pure Dart, it provides developers with simple APIs to interact with AI models and works across all supported Flutter platforms. -## Features +## Getting Started -TODO: List what your package can do. Maybe include images, gifs, or videos. +The `fal_client` library serves as a client for fal serverless Python functions. For guidance on creating your functions, refer to the [quickstart guide](https://fal.ai/docs). -## Getting started +### Client Library -TODO: List prerequisites and provide or point to information on how to -start using the package. +This client library is crafted as a lightweight layer atop platform standards like `http` and `cross_file`. This ensures a hassle-free integration into your existing codebase. Moreover, it addresses platform disparities, guaranteeing flawless operation across various Flutter runtimes. -## Usage +> **Note:** +> Ensure you've reviewed the [fal-serverless getting started guide](https://fal.ai/docs) to acquire your credentials and register your functions. -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. +1. Start by adding `fal_client` as a dependency: + +```sh +flutter pub add fal_client +``` + +2. Setup the client instance: + +```dart +import 'package:fal_client/client.dart'; + +final fal = FalClient.withCredentials("FAL_KEY_ID:FAL_KEY_SECRET"); +``` + +3. Now use `fal.subcribe` to dispatch requests to the model API: ```dart -const like = 'sample'; +final result = await fal.subscribe('text-to-image', input: { + 'prompt': 'a cute shih-tzu puppy', + 'model_name': 'stabilityai/stable-diffusion-xl-base-1.0', +}); ``` -## Additional information +The result type is a `Map` and the entries depend on the API output schema. Types in Python are mapped to their corresponding types in Dart. Check [fal.ai/models](https://fal.ai/models) for all available model APIs. + +## Roadmap + +See the [open feature requests](https://github.com/fal-ai/serverless-client-dart/labels/enhancement) for a list of proposed features and join the discussion. + +## Contributing + +Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. + +1. Make sure you read our [Code of Conduct](https://github.com/fal-ai/serverless-client-dart/blob/main/CODE_OF_CONDUCT.md) +2. Fork the project and clone your fork +3. Setup the local environment with `npm install` +4. Create a feature branch (`git checkout -b feature/add-cool-thing`) or a bugfix branch (`git checkout -b fix/smash-that-bug`) +5. Commit the changes (`git commit -m 'feat(client): added a cool thing'`) - use [conventional commits](https://conventionalcommits.org) +6. Push to the branch (`git push --set-upstream origin feature/add-cool-thing`) +7. Open a Pull Request + +Check the [good first issue queue](https://github.com/fal-ai/serverless-client-dart/labels/good+first+issue), your contribution will be welcome! + +## License -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. +Distributed under the MIT License. See [LICENSE](https://github.com/fal-ai/serverless-client-dart/blob/main/LICENSE) for more information. From ba7f1730b076ea69fb5527cba62a38abea0f1d5a Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Sat, 4 Nov 2023 18:40:13 -0700 Subject: [PATCH 2/5] fix: package build workflow --- .github/workflows/build.yml | 17 ++++++++++++++--- pubspec.yaml | 3 --- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccdaa6b..cb1ea56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,9 +22,20 @@ jobs: - name: Install dependencies run: dart pub get + + - name: Check format + run: dart format --set-exit-if-changed lib/ - - name: Build library - run: dart compile exe bin/main.dart + - name: Analyze code + run: dart analyze lib/ + + - name: Setup Flutter + uses: subosito/flutter-action@v1 + with: + channel: 'stable' - name: Build example app - run: dart compile exe example/main.dart + run: | + cd example/ + flutter pub get + flutter build web --release diff --git a/pubspec.yaml b/pubspec.yaml index c1ec8c9..00b36e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,12 +16,9 @@ topics: environment: sdk: '>=3.1.5 <4.0.0' - flutter: '>=1.17.0' dependencies: cross_file: ^0.3.3+6 - flutter: - sdk: flutter http: ^1.1.0 platform: ^3.1.3 From 6e2e1e19d3a17497f34d432316d9bd88ecf3843b Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Sat, 4 Nov 2023 18:42:54 -0700 Subject: [PATCH 3/5] fix: flutter dependency --- pubspec.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 00b36e2..003d753 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,3 @@ dependencies: platform: ^3.1.3 dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 From f9a89dfc2713bbfdec694780d54f8e5339f65b48 Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Sat, 4 Nov 2023 18:46:53 -0700 Subject: [PATCH 4/5] fix: flutter setup step --- .github/workflows/build.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb1ea56..ab919ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,10 +15,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Dart SDK - uses: dart-lang/setup-dart@v1 + - name: Setup Flutter + uses: subosito/flutter-action@v2 with: - sdk: stable + channel: 'stable' - name: Install dependencies run: dart pub get @@ -29,13 +29,7 @@ jobs: - name: Analyze code run: dart analyze lib/ - - name: Setup Flutter - uses: subosito/flutter-action@v1 - with: - channel: 'stable' - - name: Build example app run: | cd example/ - flutter pub get flutter build web --release From beb84946b992d03138114f435d6ff28e33b59499 Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Sat, 4 Nov 2023 18:49:52 -0700 Subject: [PATCH 5/5] fix: unused import --- lib/runtime.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/runtime.dart b/lib/runtime.dart index bc19e73..ae890b4 100644 --- a/lib/runtime.dart +++ b/lib/runtime.dart @@ -1,4 +1,3 @@ -import 'package:cross_file/cross_file.dart'; import 'package:platform/platform.dart'; // In Dart, we can use the dart:html library to check for browser-specific features