02 Skills Lirabry
Function: save¶
Stores a CodeSkill instance either to a local path or a Huggingface repository. In default just use save(skill) and it will store the skill into the default path. Only save the skill when the user asks to do so.
Parameters:¶
skill(CodeSkill): The skill instance to be saved.huggingface_repo_id(Optional[str]): Identifier for a Huggingface repository.skill_path(Optional[str]): Local path where the skill should be saved.
Returns:¶
- None
Usage:¶
The save function allows for the persistent storage of a CodeSkill instance by saving it either locally or to a specified Huggingface repository.
- Save to Huggingface Repository:
save(skill=skill, huggingface_repo_id="YourRepo/skill_library")
- Save Locally:
save(skill=skill, skill_path="/path/to/save")
Notes:¶
- At least one of
huggingface_repo_idorskill_pathmust be provided to execute the function, otherwise aValueErrorwill be raised. - Ensure provided paths and repository identifiers are accurate and accessible.
Let's create a skill object first
In [1]:
Copied!
from creator import create
from creator import create
In [2]:
Copied!
skill = create(file_path="./data/create_api.md")
skill = create(file_path="./data/create_api.md")
In [3]:
Copied!
skill.show()
skill.show()
Skill Details:
• Name: create
• Description: This function generates a CodeSkill instance using different input sources. It can take in a
request string detailing the skill functionality, messages or a path to a JSON file containing messages, a
string of file content or path to a code/API doc file, a directory path with skill name as stem or file path
with skill.json as stem, an identifier for a Huggingface repository, or a path to the skill within the
Huggingface repository.
• Version: 1.0.0
• Usage:
from creator import create
skill = create(request='...', messages=[...], file_content='...', file_path='...', skill_path='...',
skill_json_path='...', huggingface_repo_id='...', huggingface_skill_path='...')
• Parameters:
• request (string): String detailing the skill functionality.
• messages (array): Messages as a list of dictionaries.
• messages_json_path (string): Path to a JSON file containing messages.
• file_content (string): String of file content.
• file_path (string): Path to a code/API doc file.
• skill_path (string): Directory path with skill name as stem.
• skill_json_path (string): File path with skill.json as stem.
• huggingface_repo_id (string): Identifier for a Huggingface repository.
• huggingface_skill_path (string): Path to the skill within the Huggingface repository.
• Returns:
• CodeSkill (object): The created skill.
In [4]:
Copied!
skill.save()
skill.save()
▌ saved to /Users/gongjunmin/.cache/open_creator/skill_library/create
In [5]:
Copied!
skill.save(huggingface_repo_id="ChuxiJ/skill_library")
skill.save(huggingface_repo_id="ChuxiJ/skill_library")
/Users/gongjunmin/.cache/open_creator/remote/ChuxiJ/skill_library/create
▌ saved to /Users/gongjunmin/.cache/open_creator/skill_library/create
In [6]:
Copied!
!ls ~/.cache/open_creator/skill_library/
!ls ~/.cache/open_creator/skill_library/
ask_run_code_confirm extract_pdf_section solve_24 count_prime_numbers extract_section_from_pdf solve_game_of_24 create filter_prime_numbers solve_quadratic_equation create_api game_of_24 solve_random_maze create_scatter_plot game_of_24_solver display_markdown_message list_python_functions
Let's load a skill from remote
In [7]:
Copied!
skill = create(huggingface_repo_id="ChuxiJ/skill_library", huggingface_skill_path="create_api")
skill.show()
skill = create(huggingface_repo_id="ChuxiJ/skill_library", huggingface_skill_path="create_api")
skill.show()
▌ saved to /Users/gongjunmin/.cache/open_creator/skill_library/create_api
Skill Details:
• Name: create_api
• Description: Generates a CodeSkill instance using different input sources.
• Version: 1.0.0
• Usage:
create_api(request, messages=messages, messages_json_path=messages_json_path, file_content=file_content,
file_path=file_path, skill_path=skill_path, skill_json_path=skill_json_path,
huggingface_repo_id=huggingface_repo_id, huggingface_skill_path=huggingface_skill_path)
• Parameters:
• request (string): String detailing the skill functionality.
• Required: True
• messages (array): Messages as a list of dictionaries.
• messages_json_path (string): Path to a JSON file containing messages.
• file_content (string): String of file content.
• file_path (string): Path to a code/API doc file.
• skill_path (string): Directory path with skill name as stem.
• skill_json_path (string): File path with skill.json as stem.
• huggingface_repo_id (string): Identifier for a Huggingface repository.
• huggingface_skill_path (string): Path to the skill within the Huggingface repository.
• Returns:
• CodeSkill (object): The created skill.
Function: create¶
Generates a CodeSkill instance using different input sources.
Parameters:¶
huggingface_repo_id: Identifier for a Huggingface repository.huggingface_skill_path: Path to the skill within the Huggingface repository.
Returns:¶
CodeSkill: The created skill.
Usage:¶
Creating Skill using Huggingface Repository ID and Skill Path: If a skill is hosted in a Huggingface repository, you can create it by specifying the repository ID and the skill path within the repository.
skill = create(huggingface_repo_id="YourRepo/skill-library", huggingface_skill_path="specific_skill")
Also we support create a skill from community
In [8]:
Copied!
skill = create(huggingface_repo_id="Sayoyo/skill-library", huggingface_skill_path="extract_pdf_section")
skill = create(huggingface_repo_id="Sayoyo/skill-library", huggingface_skill_path="extract_pdf_section")
▌ saved to /Users/gongjunmin/.cache/open_creator/skill_library/extract_pdf_section
In [9]:
Copied!
skill.show()
skill.show()
Skill Details:
• Name: extract_pdf_section
• Description: Extracts a specified section from a PDF file and saves it as a new PDF.
• Version: 1.0.0
• Usage:
extract_pdf_section('input.pdf', 2, 5, 'output.pdf')
• Parameters:
• pdf_path (string): The path to the PDF file.
• Required: True
• start_page (integer): The starting page of the section to extract.
• Required: True
• end_page (integer): The ending page of the section to extract.
• Required: True
• output_path (string): The path to save the extracted section as a new PDF file.
• Required: True
• Returns:
• output_path (string): The path to the extracted section PDF file.
In [ ]:
Copied!
Last update:
October 31, 2023
Created: October 18, 2023
Created: October 18, 2023