Skip to content

Runware: new action component #14380

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

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

jcortes
Copy link
Collaborator

@jcortes jcortes commented Oct 22, 2024

WHY

Resolves #14361

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a module for requesting tasks via the Runware API, allowing users to specify various task parameters.
    • Added constants for task types related to image processing, enhancing clarity and organization.
    • Enhanced configuration options for API interactions, including detailed property definitions for task requests.
  • Bug Fixes

    • Improved error handling for API requests to ensure more robust performance.
  • Chores

    • Updated package version to 0.1.0 and added new dependencies to support the latest features.

@jcortes jcortes added the action New Action Request label Oct 22, 2024
@jcortes jcortes self-assigned this Oct 22, 2024
Copy link

vercel bot commented Oct 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Oct 24, 2024 5:44pm

Copy link

vercel bot commented Oct 22, 2024

@jcortes is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

A new module has been added to the Runware component, enabling task requests to the Runware API. This includes defining constants for API interaction and enhancing the runware.app.mjs file with detailed property definitions for task parameters. The package.json file has been updated to reflect a new version and additional dependencies. Overall, these changes improve the configurability and functionality of the API interactions.

Changes

File Path Change Summary
components/runware/actions/request-task/request-task.mjs Introduced a new module for task requests with properties and methods for API interaction.
components/runware/common/constants.mjs Added constants for API URL and task types related to image processing.
components/runware/package.json Updated version to 0.1.0 and added dependencies for @pipedream/platform and uuid.
components/runware/runware.app.mjs Enhanced property definitions for API parameters and improved request handling methods.

Assessment against linked issues

Objective Addressed Explanation
Create a task to be processed by the Runware API (14361)

Possibly related PRs

  • New Components - specific #12926: The main PR introduces a new module for requesting tasks, which may relate to the "create-conversation" action in the retrieved PR that also defines a structured action for handling requests.
  • New Components - v7_go #12949: The main PR's focus on task requests could connect with the "create-entity" action in this PR, as both involve structured requests to an API.
  • New Components - hubstaff #13040: The main PR's task request functionality may relate to the "create-task" action in this PR, as both involve creating structured requests for processing.
  • CustomJS: Add Run Puppoteer and HTML to PNG actions #14117: The main PR's introduction of a task request module could be related to the "create-employee" action in this PR, as both involve structured actions that require specific parameters.
  • [Components] ollama: new action components #14278: The main PR's focus on task requests could relate to the "generate-chat-completion" action in this PR, as both involve structured interactions with an API for processing requests.

Suggested reviewers

  • michelle0927

Poem

🐰 In the garden of code, we hop and play,
New tasks to request, come join the fray!
With constants and methods, our API's bright,
Let's dance with the data, from morning till night!
So gather 'round, friends, let’s make it a blast,
For the changes we've made, will surely last! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (3)
components/runware/package.json (1)

15-18: Dependencies added correctly.

The addition of "@pipedream/platform" and "uuid" dependencies is appropriate for the new features being implemented. However, consider the following suggestion:

Consider pinning the "uuid" dependency to a specific version (e.g., "10.0.0" instead of "^10.0.0") to ensure consistent behavior across different environments.

components/runware/common/constants.mjs (2)

1-2: LGTM! Consider environment-specific configuration.

The BASE_URL and VERSION_PATH constants are correctly defined and align with the Runware API mentioned in the PR objectives.

Consider using environment variables for these values to allow for easier configuration across different environments (e.g., development, staging, production).


4-29: LGTM! Consider using an enum-like structure for better maintainability.

The TASK_TYPE object is well-structured and aligns with the image inference capabilities mentioned in the PR objectives. The naming conventions are consistent and clear.

For improved maintainability and type safety, consider using an enum-like structure. Here's an example using Object.freeze():

const TASK_TYPE = Object.freeze({
  IMAGE_INFERENCE: {
    value: "imageInference",
    label: "Image Inference",
  },
  // ... other task types ...
});

This approach prevents accidental modifications to the TASK_TYPE object.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6da9785 and f0aae2f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/runware/actions/request-task/request-task.mjs (1 hunks)
  • components/runware/common/constants.mjs (1 hunks)
  • components/runware/package.json (2 hunks)
  • components/runware/runware.app.mjs (1 hunks)
🧰 Additional context used
🔇 Additional comments (5)
components/runware/package.json (2)

3-3: Version update looks good.

The version bump from 0.0.1 to 0.1.0 correctly reflects the addition of new features (Runware API integration) without breaking changes, adhering to semantic versioning principles.


Line range hint 1-19: package.json structure and content are well-formed.

The file contains all necessary fields for a Node.js package, including appropriate metadata and configuration. The public access setting in "publishConfig" is correct for a package in the @pipedream organization.

components/runware/common/constants.mjs (2)

31-35: LGTM! Export structure is clean and appropriate.

The default export includes all defined constants, which is correct and allows for easy import and use in other parts of the application.


1-35: Overall, excellent implementation of constants for Runware API.

This new file effectively defines the necessary constants for interacting with the Runware API, including various task types for image processing. The structure is clean, consistent, and aligns well with the PR objectives. The minor suggestions provided earlier are for potential improvements in flexibility and maintainability, but the current implementation is solid and ready for use.

components/runware/runware.app.mjs (1)

148-150: Verify the error handling in the makeRequest method.

Currently, the code checks for response.errors, but Axios typically throws errors for non-2xx responses. Ensure that this check accurately captures API errors as intended.

Would you like assistance in updating the error handling to correctly handle API and network errors?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
components/runware/actions/request-task/request-task.mjs (1)

10-120: LGTM: Props are well-defined using app instance.

The props are comprehensively defined using propDefinitions from the app instance, which promotes consistency and reusability. The wide range of parameters aligns well with the Runware API's capabilities as described in the PR objectives.

Consider adding comments or grouping related props to improve readability, especially for developers who might not be familiar with all the Runware API parameters.

components/runware/runware.app.mjs (1)

140-157: Consider enhancing error handling in makeRequest method.

The makeRequest method correctly checks for errors in the response. However, consider providing more context in the error message to aid in debugging. For example:

if (response.errors) {
  throw new Error(`Runware API error: ${JSON.stringify(response.errors)}`);
}

This change would make it clearer that the error is coming from the Runware API.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f0aae2f and 1e68e23.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/runware/actions/request-task/request-task.mjs (1 hunks)
  • components/runware/common/constants.mjs (1 hunks)
  • components/runware/package.json (2 hunks)
  • components/runware/runware.app.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/runware/common/constants.mjs
  • components/runware/package.json
🧰 Additional context used
🔇 Additional comments (6)
components/runware/actions/request-task/request-task.mjs (2)

1-9: LGTM: Imports and metadata are well-defined.

The imports and metadata for the Runware API task request action are appropriately set up. The use of uuid for generating unique task identifiers and the clear description with a link to the documentation are good practices.


176-179: LGTM: Summary export and response return.

The summary export and full response return are good practices, providing useful information to the user and allowing for further processing if needed.

As mentioned in a previous review, there's a typo in the summary message. "reuested" should be "requested". Please apply the following fix:

-    $.export("$summary", `Successfully reuested task with UUID \`${response.data[0].taskUUID}\`.`);
+    $.export("$summary", `Successfully requested task with UUID \`${response.data[0].taskUUID}\`.`);
components/runware/runware.app.mjs (4)

1-6: LGTM: Imports and app definition are appropriate.

The imports and app definition are correctly set up for a Runware API integration.


7-128: LGTM: Comprehensive property definitions for Runware API.

The property definitions are extensive, well-documented, and cover a wide range of parameters for the Runware API. Good job on providing detailed descriptions and appropriate options for each property.


130-139: LGTM: URL and header construction methods are well-implemented.

The getUrl and getHeaders methods are correctly implemented to construct the API URL and add necessary headers, including authentication.


14-34: 🛠️ Refactor suggestion

Consider defining options as constants for outputType and outputFormat.

As suggested in a previous review, consider defining the options for outputType and outputFormat as constants in constants.mjs to improve maintainability and ensure consistency across the codebase.

luancazarine
luancazarine previously approved these changes Oct 22, 2024
Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jcortes, LGTM! Ready for QA!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (4)
components/runware/runware.app.mjs (4)

54-58: Add minLength and maxLength validations to positivePrompt

To enforce the length constraints mentioned in the description (between 4 and 2000 characters), add minLength and maxLength validations.

Apply this diff to add validation:

 positivePrompt: {
   type: "string",
   label: "Positive Prompt",
   description: "A positive prompt is a text instruction to guide the model on generating the image. It is usually a sentence or a paragraph that provides positive guidance for the task. This parameter is essential to shape the desired results. For example, if the positive prompt is `dragon drinking coffee`, the model will generate an image of a dragon drinking coffee. The more detailed the prompt, the more accurate the results. The length of the prompt must be between 4 and 2000 characters.",
+  minLength: 4,
+  maxLength: 2000,
 },

59-64: Add minLength and maxLength validations to negativePrompt

Similarly, to enforce length constraints, add minLength and maxLength validations to the negativePrompt property.

Apply this diff:

 negativePrompt: {
   type: "string",
   label: "Negative Prompt",
   description: "A negative prompt is a text instruction to guide the model on generating the image. It is usually a sentence or a paragraph that provides negative guidance for the task. This parameter helps to avoid certain undesired results. For example, if the negative prompt is `red dragon, cup`, the model will follow the positive prompt but will avoid generating an image of a red dragon or including a cup. The more detailed the prompt, the more accurate the results. The length of the prompt must be between 4 and 2000 characters.",
   optional: true,
+  minLength: 4,
+  maxLength: 2000,
 },

65-70: Implement conditional requirement for seedImage based on taskType

When taskType is Image-to-Image, Inpainting, or Outpainting, the seedImage parameter is required. Consider adding validation to enforce this conditional requirement.

Would you like assistance in implementing this validation?


71-76: Implement conditional requirement for maskImage based on taskType

Similarly, when performing Inpainting or Outpainting, the maskImage parameter is required. Adding validation will ensure users provide necessary inputs based on the selected taskType.

Would you like help in adding this validation?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1e68e23 and 09e441f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/runware/actions/request-task/request-task.mjs (1 hunks)
  • components/runware/common/constants.mjs (1 hunks)
  • components/runware/package.json (2 hunks)
  • components/runware/runware.app.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/runware/actions/request-task/request-task.mjs
  • components/runware/common/constants.mjs
  • components/runware/package.json
🧰 Additional context used
🔇 Additional comments (3)
components/runware/runware.app.mjs (3)

19-23: Previous suggestion on using constants for outputType options is still applicable

Defining outputType options using constants from constants.mjs improves maintainability and consistency.


30-34: Previous suggestion on using constants for outputFormat options is still applicable

Similarly, consider using constants for outputFormat options to enhance code consistency.


83-96: Validation to ensure height and width are divisible by 64 is still missing

The earlier recommendation to add validation for height and width being divisible by 64 remains valid.

@jcortes jcortes force-pushed the runware-new-components branch from 09e441f to bbb620f Compare October 24, 2024 14:38
@jcortes
Copy link
Collaborator Author

jcortes commented Oct 24, 2024

/approve

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 09e441f and bbb620f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/runware/actions/request-task/request-task.mjs (1 hunks)
  • components/runware/common/constants.mjs (1 hunks)
  • components/runware/package.json (2 hunks)
  • components/runware/runware.app.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/runware/actions/request-task/request-task.mjs
  • components/runware/common/constants.mjs
  • components/runware/package.json

@jcortes jcortes force-pushed the runware-new-components branch from bbb620f to 7f6c413 Compare October 24, 2024 17:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bbb620f and 7f6c413.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/runware/actions/request-task/request-task.mjs (1 hunks)
  • components/runware/common/constants.mjs (1 hunks)
  • components/runware/package.json (2 hunks)
  • components/runware/runware.app.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/runware/actions/request-task/request-task.mjs
  • components/runware/common/constants.mjs
  • components/runware/package.json

Comment on lines +65 to +70
seedImage: {
type: "string",
label: "Seed Image",
description: "When doing Image-to-Image, Inpainting or Outpainting, this parameter is **required**. Specifies the seed image to be used for the diffusion process. The image can be specified in one of the following formats:\n - An UUID v4 string of a [previously uploaded image](https://docs.runware.ai/en/getting-started/image-upload) or a [generated image](https://docs.runware.ai/en/image-inference/api-reference).\n - A data URI string representing the image. The data URI must be in the format `data:<mediaType>;base64,` followed by the base64-encoded image. For example: `data:image/png;base64,iVBORw0KGgo...`.\n - A base64 encoded image without the data URI prefix. For example: `iVBORw0KGgo...`.\n - A URL pointing to the image. The image must be accessible publicly. Supported formats are: PNG, JPG and WEBP.",
optional: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency: seedImage is marked optional but described as required

The description states that seedImage is required when performing Image-to-Image, Inpainting, or Outpainting tasks, but the property is marked as optional: true. To ensure consistency and proper validation, consider adjusting the property definition to conditionally require seedImage based on the taskType.

Comment on lines +71 to +76
maskImage: {
type: "string",
label: "Mask Image",
description: "When doing Inpainting or Outpainting, this parameter is **required**. Specifies the mask image to be used for the inpainting process. The image can be specified in one of the following formats:\n - An UUID v4 string of a [previously uploaded image](https://docs.runware.ai/en/getting-started/image-upload) or a [generated image](https://docs.runware.ai/en/image-inference/api-reference).\n - A data URI string representing the image. The data URI must be in the format `data:<mediaType>;base64,` followed by the base64-encoded image. For example: `data:image/png;base64,iVBORw0KGgo...`.\n - A base64 encoded image without the data URI prefix. For example: `iVBORw0KGgo...`.\n - A URL pointing to the image. The image must be accessible publicly. Supported formats are: PNG, JPG and WEBP.",
optional: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency: maskImage is marked optional but described as required

Similar to seedImage, the maskImage property is marked as optional: true, but the description indicates it is required for Inpainting or Outpainting tasks. Ensure the property accurately reflects its required status based on the taskType to prevent potential runtime errors due to missing parameters.

height: {
type: "integer",
label: "Height",
description: "Used to define the height dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, eg: `512`, `576`, `640` ... `2048`.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Standardize abbreviation in height and width descriptions

In the descriptions for the height and width properties, "eg" should be standardized to "e.g.," for consistency and correctness.

Apply this diff to correct the abbreviation:

// For the `height` property
- description: "Used to define the height dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, eg: `512`, `576`, `640` ... `2048`.",
+ description: "Used to define the height dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, e.g., `512`, `576`, `640` ... `2048`.",

// For the `width` property
- description: "Used to define the width dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, eg: `512`, `576`, `640` ... `2048`.",
+ description: "Used to define the width dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, e.g., `512`, `576`, `640` ... `2048`.",

Also applies to: 93-93

scheduler: {
type: "string",
label: "Scheduler",
description: "An scheduler is a component that manages the inference process. Different schedulers can be used to achieve different results like more detailed images, faster inference, or more accurate results. The default scheduler is the one that the model was trained with, but you can choose a different one to get different results. Schedulers are explained in more detail in the [Schedulers page](https://docs.runware.ai/en/image-inference/schedulers).",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Typographical error in scheduler description

In the description for the scheduler property, "An scheduler" should be "A scheduler" to improve readability.

Apply this diff to correct the typo:

- description: "An scheduler is a component that manages the inference process..."
+ description: "A scheduler is a component that manages the inference process..."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: "An scheduler is a component that manages the inference process. Different schedulers can be used to achieve different results like more detailed images, faster inference, or more accurate results. The default scheduler is the one that the model was trained with, but you can choose a different one to get different results. Schedulers are explained in more detail in the [Schedulers page](https://docs.runware.ai/en/image-inference/schedulers).",
description: "A scheduler is a component that manages the inference process. Different schedulers can be used to achieve different results like more detailed images, faster inference, or more accurate results. The default scheduler is the one that the model was trained with, but you can choose a different one to get different results. Schedulers are explained in more detail in the [Schedulers page](https://docs.runware.ai/en/image-inference/schedulers).",

@jcortes jcortes merged commit 31906cf into PipedreamHQ:master Oct 25, 2024
10 of 11 checks passed
malexanderlim pushed a commit that referenced this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action New Action Request
Projects
Development

Successfully merging this pull request may close these issues.

[Components] runware
2 participants