-
Notifications
You must be signed in to change notification settings - Fork 412
Feat: support subfolder for skill_id #788
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
Changes from all commits
67b63c5
edac766
f442790
b0bd7d6
9bd8a5d
0a30e4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -195,6 +195,11 @@ if __name__ == '__main__': | |||||
| main() | ||||||
| ``` | ||||||
|
|
||||||
| - skill_id_or_dir: 支持传入本地技能目录路径,或从ModelScope Hub加载技能ID。 | ||||||
| - 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`) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There appears to be a typo in the example skill ID. It should likely be
Suggested change
|
||||||
| - 参考 [AgentSkillExamples](https://modelscope.cn/models/ms-agent/skill_examples) | ||||||
|
|
||||||
|
|
||||||
| * 本地执行 | ||||||
| - 若 `use_sandbox=False`,技能脚本将在本地环境中直接执行 | ||||||
| - 请确保您信任该技能脚本,以避免潜在的安全风险 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,7 +143,17 @@ def _preprocess_skills( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skill_cache_dirs: List[str] = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for skill_id in skills: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skill_dir: str = snapshot_download(repo_id=skill_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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}') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+146
to
158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation reassigns the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skill_cache_dirs.append(skill_dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -83,7 +83,7 @@ def main(): | |||||
| """ | ||||||
| work_dir: str = str(_PATH / 'temp_workspace') | ||||||
| # Refer to `https://github.com/modelscope/ms-agent/tree/main/projects/agent_skills/skills` | ||||||
| skills_dir: str = str(_PATH / 'skills') | ||||||
| skill_id_or_dir: str = str(_PATH / 'skills') | ||||||
| use_sandbox: bool = True | ||||||
|
|
||||||
| ## Configuration for ModelScope API-Inference, or set your own model with OpenAI API compatible format | ||||||
|
|
@@ -93,7 +93,7 @@ def main(): | |||||
| base_url: str = 'https://api-inference.modelscope.cn/v1/' | ||||||
|
|
||||||
| agent = create_agent_skill( | ||||||
| skills=skills_dir, | ||||||
| skills=skill_id_or_dir, | ||||||
| model=model, | ||||||
| api_key=os.getenv('OPENAI_API_KEY', api_key), | ||||||
| base_url=os.getenv('OPENAI_BASE_URL', base_url), | ||||||
|
|
@@ -115,6 +115,11 @@ if __name__ == '__main__': | |||||
| main() | ||||||
| ``` | ||||||
|
|
||||||
| - 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`) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There appears to be a typo in the example skill ID. It should likely be
Suggested change
|
||||||
| - Refer to [AgentSkillExamples](https://modelscope.cn/models/ms-agent/skill_examples) for more details on skill publishing and sharing. | ||||||
|
|
||||||
|
|
||||||
| **Result:** | ||||||
|
|
||||||
| <div align="center"> | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be a typo in the example skill ID. It should likely be
ms-agentinstead ofma-agentto maintain consistency with other examples and the pull request description.