Skip to content

Conversation

@wangxingjun778
Copy link
Collaborator

  1. In the form of: owner/skill_name/subfolder, e.g. ms-agent/skill_examples/pdf (refer to: https://modelscope.cn/models/ms-agent/skill_examples)

@gemini-code-assist
Copy link

Summary of Changes

Hello @wangxingjun778, 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 a significant feature that allows users to specify a subfolder within a skill repository when referencing skill_ids. This enhancement provides greater flexibility and efficiency by enabling the system to download only the necessary sub-parts of a skill, rather than the entire repository. The change involves updating the core skill processing logic to parse the new skill_id format, modifying repository ID validation, and updating relevant documentation and examples to guide users on its adoption.

Highlights

  • Subfolder Support for Skill IDs: The system now recognizes skill_ids in the format owner/skill_name/subfolder, allowing for more granular skill referencing from the ModelScope Hub.
  • Targeted Skill Downloads: When a subfolder is specified in the skill_id, the snapshot_download function is now configured to download only the content within that specific subfolder, improving efficiency and reducing unnecessary data transfer.
  • Documentation Updates: Both English and Chinese documentation, along with the agent_skills example README, have been updated to clearly explain the new skill_id format and its usage.
  • Repository ID Validation Enhancement: The valid_repo_id utility function has been modified to correctly validate the new owner/skill_name/subfolder format, ensuring consistency across the system.
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 specifying a subfolder in a skill_id, allowing for more granular skill loading from ModelScope Hub. The changes include updating the valid_repo_id function, modifying the skill preprocessing logic to handle the new format, and updating documentation.

My review found a few issues:

  • There are typos in the example skill IDs in the documentation files.
  • In agent_skill.py, the logic for handling skill IDs could be improved for clarity and to fix a bug in logging. The skill_id variable is being reassigned, which makes the code harder to follow and causes the log message to be incorrect.

I've provided suggestions to fix these issues. Overall, the changes look good and implement the intended feature.

```

- skill_id_or_dir: Path to the local skill directory or skill ID from The ModelScope hub.
- skill_id_or_dir (str): e.g. 'path/to/skill-directory', 'ms-agent/skill_examples', 'ma-agent/skill_examples/pdf' (in the form of `owner/skill_name` or `owner/skill_name/subfolder`)

Choose a reason for hiding this comment

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

medium

There appears to be a typo in the example skill ID. It should likely be ms-agent instead of ma-agent to maintain consistency with other examples and the pull request description.

Suggested change
- skill_id_or_dir (str): e.g. 'path/to/skill-directory', 'ms-agent/skill_examples', 'ma-agent/skill_examples/pdf' (in the form of `owner/skill_name` or `owner/skill_name/subfolder`)
- skill_id_or_dir (str): e.g. 'path/to/skill-directory', 'ms-agent/skill_examples', 'ms-agent/skill_examples/pdf' (in the form of `owner/skill_name` or `owner/skill_name/subfolder`)

Choose a reason for hiding this comment

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

medium

There appears to be a typo in the example skill ID. It should likely be ms-agent instead of ma-agent to maintain consistency with other examples.

Suggested change
- skill_id_or_dir (str): 示例: 'path/to/skill-directory', 'ms-agent/skill_examples', 'ma-agent/skill_examples/pdf' (格式为 `owner/skill_name` or `owner/skill_name/subfolder`)
- skill_id_or_dir (str): 示例: 'path/to/skill-directory', 'ms-agent/skill_examples', 'ms-agent/skill_examples/pdf' (格式为 `owner/skill_name` or `owner/skill_name/subfolder`)

Comment on lines +146 to 158
skill_id_parts: List[str] = skill_id.split('/')
subfolder = skill_id_parts[-1] if len(
skill_id_parts) == 3 else None
allow_pattern: str = f'{subfolder}/*' if subfolder else None
skill_id = '/'.join(
skill_id_parts[:2]) if subfolder else skill_id

skill_dir: str = snapshot_download(
repo_id=skill_id,
allow_patterns=allow_pattern,
)
logger.info(
f'Downloaded skill from hub: {skill_id} to {skill_dir}')

Choose a reason for hiding this comment

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

medium

The current implementation reassigns the skill_id variable. This can be confusing and leads to an incorrect log message, as the modified skill_id (the repository path without the subfolder) is logged instead of the original full skill ID. It's better to use a new variable for the repository ID to improve clarity and fix the logging.

Suggested change
skill_id_parts: List[str] = skill_id.split('/')
subfolder = skill_id_parts[-1] if len(
skill_id_parts) == 3 else None
allow_pattern: str = f'{subfolder}/*' if subfolder else None
skill_id = '/'.join(
skill_id_parts[:2]) if subfolder else skill_id
skill_dir: str = snapshot_download(
repo_id=skill_id,
allow_patterns=allow_pattern,
)
logger.info(
f'Downloaded skill from hub: {skill_id} to {skill_dir}')
skill_id_parts: List[str] = skill_id.split('/')
subfolder = skill_id_parts[-1] if len(
skill_id_parts) == 3 else None
allow_pattern: str = f'{subfolder}/*' if subfolder else None
repo_id = '/'.join(
skill_id_parts[:2]) if subfolder else skill_id
skill_dir: str = snapshot_download(
repo_id=repo_id,
allow_patterns=allow_pattern,
)
logger.info(
f'Downloaded skill from hub: {skill_id} to {skill_dir}')

```

- skill_id_or_dir: Path to the local skill directory or skill ID from The ModelScope hub.
- skill_id_or_dir (str): e.g. 'path/to/skill-directory', 'ms-agent/skill_examples', 'ma-agent/skill_examples/pdf' (in the form of `owner/skill_name` or `owner/skill_name/subfolder`)

Choose a reason for hiding this comment

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

medium

There appears to be a typo in the example skill ID. It should likely be ms-agent instead of ma-agent to maintain consistency with other examples and the pull request description.

Suggested change
- skill_id_or_dir (str): e.g. 'path/to/skill-directory', 'ms-agent/skill_examples', 'ma-agent/skill_examples/pdf' (in the form of `owner/skill_name` or `owner/skill_name/subfolder`)
- skill_id_or_dir (str): e.g. 'path/to/skill-directory', 'ms-agent/skill_examples', 'ms-agent/skill_examples/pdf' (in the form of `owner/skill_name` or `owner/skill_name/subfolder`)

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