Skip to content

feat(agent): Add JSON type to kwargs types for Friday#126

Open
hongxicheng wants to merge 3 commits intoagentscope-ai:mainfrom
hongxicheng:GenKwargs
Open

feat(agent): Add JSON type to kwargs types for Friday#126
hongxicheng wants to merge 3 commits intoagentscope-ai:mainfrom
hongxicheng:GenKwargs

Conversation

@hongxicheng
Copy link
Collaborator

Description

image

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with npm run format command in the root directory
  • Docstrings/comments are in appropriate style (TSDoc/JSDoc for TypeScript/JavaScript, Google style for Python)
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@gemini-code-assist
Copy link

Summary of Changes

Hello @hongxicheng, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces comprehensive support for JSON data types within the Friday agent's keyword argument configuration. It enhances the user interface to allow for structured JSON input with validation, and updates the underlying data handling to seamlessly convert JSON strings to objects and vice-versa, improving the flexibility and robustness of argument management.

Highlights

  • JSON Type Support: Added a new 'json' type option for keyword arguments (kwargs) in the Friday agent settings.
  • UI Enhancements: Implemented a dedicated TextArea component for JSON input fields, along with real-time validation to ensure correct JSON format.
  • Backend Conversion Logic: Updated the data conversion functions to correctly handle JSON strings, parsing them into objects when converting to backend format and stringifying objects when converting from backend format.
  • Internationalization: Included new English and Chinese translation strings for JSON-related messages, such as invalid format warnings and placeholder text.
Changelog
  • packages/client/src/i18n/en.json
    • Added new translation keys for 'invalid-json' and 'json-value-placeholder'.
  • packages/client/src/i18n/zh.json
    • Added new Chinese translation keys for 'invalid-json' and 'json-value-placeholder'.
  • packages/client/src/pages/FridayPage/SettingPage/KwargsFormList.tsx
    • Imported TextArea component from Ant Design Input.
    • Modified form field rendering to conditionally use TextArea for 'json' type inputs.
    • Added validation rules for 'json' type fields to check for valid JSON format.
    • Adjusted validateTrigger to always include 'onBlur' and 'onChange'.
  • packages/client/src/pages/FridayPage/SettingPage/index.tsx
    • Updated the KwargsBackendItem type definition to include 'object' for JSON values.
    • Modified convertKwargsToBackendFormat to parse JSON strings into objects for 'json' type arguments, including error handling.
    • Modified convertKwargsFromBackendFormat to detect object values and convert them to 'json' type with pretty-printed JSON strings.
  • packages/client/src/pages/FridayPage/config.tsx
    • Added 'json' as a new option to the inputTypeOptions array.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for a json type for keyword arguments in the Friday agent settings. The changes include updating the UI to provide a TextArea for JSON input with appropriate validation, and modifying the data conversion logic to handle JSON objects. The i18n files are also updated with new messages for JSON validation.

The implementation is mostly solid, but I've left a couple of comments. One is about improving maintainability by reducing code duplication in the form component. The other is a more critical point about error handling during data conversion, where failing fast would be safer than silently proceeding with potentially incorrect data.

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.

1 participant