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

Dify.AI Integration Block #1183

Merged
merged 11 commits into from
Jan 29, 2024
Merged

Dify.AI Integration Block #1183

merged 11 commits into from
Jan 29, 2024

Conversation

abdullahbaa5
Copy link
Contributor

@abdullahbaa5 abdullahbaa5 commented Jan 23, 2024

Implemented Dify.AI Block

  • Dify Features:
    -- Can Create Multiple Chat Bots
    -- Assign Knowledge base/vector database to chat bots
    -- Variables send by client to be used in the prompt
    -- Options of custom and cloud AI LLMs to be changed with on click

  • Dify API Function/Action Implemented
    -- Create Chat Message (Takes in input variables, query, conversation id, user id and returns answer, usage metadata and conversation id)

  • Future Implantations with this block
    -- Streaming response
    -- File Upload for GPT Vision
    -- Speech to text action

Summary by CodeRabbit

  • New Features

    • Introduced the ability to create chat messages within the Dify platform.
    • Added secure authentication for Dify.AI accounts.
    • Implemented a new Dify.AI block with integrated chat message creation and logo display.
    • Enabled Dify.AI block in the repository for user access.
  • Enhancements

    • Enhanced security for API key input by changing it to a password field.
  • Documentation

    • Included new types to support Dify AI service responses.
  • Refactor

    • Updated schema imports and array listings to include the new Dify.AI block.

Copy link

vercel bot commented Jan 23, 2024

@abdullahbaa5 is attempting to deploy a commit to the Typebot Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented Jan 23, 2024

Warning

Rate Limit Exceeded

@baptisteArno has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 54 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between ac1c8ca and 49dff70.

Walkthrough

The updates involve integrating a new block called dify-ai into the Forge ecosystem, which facilitates the creation and management of chat messages within the Dify.AI platform. This includes handling authentication with encrypted credentials, defining response types, and rendering the DifyAI logo. There is also a security enhancement in the CLI for the API key input, and the overall repository and schemas are updated to include the new dify-ai block.

Changes

File Path Change Summary
.../difyAi/actions/createChatMessage.ts
.../difyAi/index.ts
.../difyAi/auth.ts
Introduced functionality to create chat messages, authentication handling, and encrypted credentials for Dify.AI accounts.
.../difyAi/logo.tsx
.../cli/index.ts
Implemented a React component for the DifyAI logo.
Enhanced security for API key input field.
.../difyAi/types.ts
.../repository/index.ts
.../schemas/index.ts
Defined DifyResponse type for handling Dify AI service responses.
Included 'dify-ai' block in enabledBlocks.
Imported dify-ai block and added to forgedBlocks array.

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2c20e96 and 1c7b2d4.
Files ignored due to path filters (4)
  • packages/forge/blocks/difyAi/package.json is excluded by: !**/*.json
  • packages/forge/blocks/difyAi/tsconfig.json is excluded by: !**/*.json
  • packages/forge/schemas/package.json is excluded by: !**/*.json
  • pnpm-lock.yaml is excluded by: !**/*.yaml
Files selected for processing (8)
  • packages/forge/blocks/difyAi/actions/createChatMessage.ts (1 hunks)
  • packages/forge/blocks/difyAi/auth.ts (1 hunks)
  • packages/forge/blocks/difyAi/index.ts (1 hunks)
  • packages/forge/blocks/difyAi/logo.tsx (1 hunks)
  • packages/forge/blocks/difyAi/types.ts (1 hunks)
  • packages/forge/cli/index.ts (1 hunks)
  • packages/forge/repository/index.ts (1 hunks)
  • packages/forge/schemas/index.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • packages/forge/repository/index.ts
Additional comments: 7
packages/forge/blocks/difyAi/types.ts (1)
  • 1-9: The DifyResponse type is well-defined and matches the expected structure from the Dify AI service. It includes all necessary fields such as answer, metadata, and conversation_id.
packages/forge/blocks/difyAi/logo.tsx (1)
  • 1-17: The DifyAiLogo component is correctly implemented as a functional React component with proper SVG properties and an image reference. Ensure that the image URL is valid and that it is intended to be publicly accessible.
packages/forge/blocks/difyAi/index.ts (1)
  • 1-13: The difyAi block is correctly set up with an ID, name, tags, logo, authentication, and actions. Ensure that the tags array includes all relevant tags for the Dify.AI block and that the createChatMessage action is fully implemented and tested.
packages/forge/blocks/difyAi/auth.ts (1)
  • 1-21: The auth object is correctly structured to define encrypted credentials with a detailed schema for apiEndpoint and apiKey. The use of inputType: 'password' for the API key ensures that sensitive information is obscured in the UI. Confirm that the withVariableButton property is intended for both fields and that the apiEndpoint helper text accurately describes the expected input.
packages/forge/schemas/index.ts (1)
  • 1-5: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [2-22]

The import and addition of the difyAi block to the forgedBlocks array are correctly implemented. This change will make the Dify.AI block available for use. Ensure that the @typebot.io/dify-ai-block package is correctly installed and that there are no naming conflicts with other blocks.

packages/forge/blocks/difyAi/actions/createChatMessage.ts (1)
  • 1-79: The createChatMessage action is well-structured with appropriate options and a server-side run function. Ensure that the inputs JSON parsing is safe and that there is error handling in case of invalid JSON. Additionally, confirm that the responseMapping logic correctly maps the response to the variables and that the got library is properly handling network errors.
packages/forge/cli/index.ts (1)
  • 278-278: The change from input: 'password' to inputType: 'password' is correct and enhances the security of the API key input. Ensure that this change is consistently applied across all instances where an API key is required.

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1c7b2d4 and 8c7173b.
Files selected for processing (1)
  • packages/forge/blocks/difyAi/auth.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/forge/blocks/difyAi/auth.ts

@baptisteArno
Copy link
Owner

Great work my friend :)

I'm trying to push an improvement but get hit by that error while pushing:

Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 10 threads
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 1.53 KiB | 390.00 KiB/s, done.
Total 12 (delta 7), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (7/7), completed with 7 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/dify-ai-block.
remote: error: Commits must have verified signatures. Changes must be made through a pull request.
To https://github.com/abdullahbaa5/typebot.io.git
 ! [remote rejected]   dify-ai-block -> dify-ai-block (protected branch hook declined)
error: failed to push some refs to 'https://github.com/abdullahbaa5/typebot.io.git'

Any idea how to remove that restriction?

@abdullahbaa5
Copy link
Contributor Author

Great work my friend :)

I'm trying to push an improvement but get hit by that error while pushing:

Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 10 threads
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 1.53 KiB | 390.00 KiB/s, done.
Total 12 (delta 7), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (7/7), completed with 7 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/dify-ai-block.
remote: error: Commits must have verified signatures. Changes must be made through a pull request.
To https://github.com/abdullahbaa5/typebot.io.git
 ! [remote rejected]   dify-ai-block -> dify-ai-block (protected branch hook declined)
error: failed to push some refs to 'https://github.com/abdullahbaa5/typebot.io.git'

Any idea how to remove that restriction?

ah i disabled it. you should be able to push now.

Copy link

@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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8c7173b and ac1c8ca.
Files ignored due to path filters (4)
  • apps/docs/openapi/builder.json is excluded by: !**/*.json
  • apps/docs/openapi/viewer.json is excluded by: !**/*.json
  • packages/forge/schemas/package.json is excluded by: !**/*.json
  • pnpm-lock.yaml is excluded by: !**/*.yaml
Files selected for processing (7)
  • apps/builder/src/pages/_app.tsx (1 hunks)
  • packages/forge/blocks/difyAi/actions/createChatMessage.ts (1 hunks)
  • packages/forge/blocks/difyAi/auth.ts (1 hunks)
  • packages/forge/blocks/difyAi/constants.ts (1 hunks)
  • packages/forge/core/index.ts (1 hunks)
  • packages/forge/repository/index.ts (1 hunks)
  • packages/forge/schemas/index.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • packages/forge/blocks/difyAi/constants.ts
Files skipped from review as they are similar to previous changes (4)
  • packages/forge/blocks/difyAi/actions/createChatMessage.ts
  • packages/forge/blocks/difyAi/auth.ts
  • packages/forge/repository/index.ts
  • packages/forge/schemas/index.ts
Additional comments: 1
packages/forge/core/index.ts (1)
  • 104-115: The addition of the keyValueList to the option object is correctly implemented with proper type definitions for key and value properties. This change follows TypeScript best practices for defining object shapes and optional fields.

apps/builder/src/pages/_app.tsx Outdated Show resolved Hide resolved
Copy link

vercel bot commented Jan 29, 2024

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

Name Status Preview Comments Updated (UTC)
builder-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 29, 2024 9:46am
landing-page-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 29, 2024 9:46am

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