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/support form in conversation #9980

Merged
merged 8 commits into from
Oct 29, 2024
Merged

Conversation

crazywoola
Copy link
Member

@crazywoola crazywoola commented Oct 29, 2024

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

// This defines the response structure of the submit action
enum DATA_FORMAT {
  TEXT = 'text',
  JSON = 'json',
}

// This defines supported tags in a form item for now :)
enum SUPPORTED_TAGS {
  LABEL = 'label',
  INPUT = 'input',
  TEXTAREA = 'textarea',
  BUTTON = 'button',
}

// This defines supported types of a input element
enum SUPPORTED_TYPES {
  TEXT = 'text',
  PASSWORD = 'password',
  EMAIL = 'email',
  NUMBER = 'number',
}
<form data-format="json"> // Default to text
  <label for="username">Username:</label>
  <input type="text" name="username" />
  <label for="password">Password:</label>
  <input type="password" name="password" />
  <div>This tag is not supported</div>
  <input type="random" name="password" /> // This is not supported as well
  <label for="content">Content:</label>
  <textarea name="content"></textarea>
  <button data-size="small" data-variant="primary">Login</button>
</form>
Response type: Text Response type: Json

Example DSL: Form in conversation.yml.zip

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. ☕️ typescript Pull request that update TypeScript code. 💪 enhancement New feature or request labels Oct 29, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 29, 2024
@crazywoola crazywoola merged commit fc37e65 into main Oct 29, 2024
7 checks passed
@crazywoola crazywoola deleted the feat/support-form-in-markdown branch October 29, 2024 05:32
@obadakhalili
Copy link

@crazywoola @zxhlyh is their docs that explain how to use this?

@crazywoola
Copy link
Member Author

crazywoola commented Oct 29, 2024

@crazywoola @zxhlyh is their docs that explain how to use this?

I will add it later. You can explore it with the provided DSL.

@obadakhalili
Copy link

yeah, it turned out that the issue I encountered that made me need the docs was due to using the wrong version (0.10.2). I used the code from the main branch and it worked.

@svcvit
Copy link
Contributor

svcvit commented Nov 12, 2024

Add an example to help everyone understand how to use this feature.
FormDemo.zip

idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files. ☕️ typescript Pull request that update TypeScript code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants