03 Skills Search
Function: search
¶
Retrieve skills related to a specified query from the available pool of skills.
Parameters:¶
query
(str): Search query string.top_k
(Optional[int]): Maximum number of skills to return. Default is 1.threshold
(Optional[float]): Minimum similarity score to return a skill. Default is 0.8.
Returns:¶
- List[CodeSkill]: A list of retrieved
CodeSkill
objects that match the query.
Usage:¶
The search
function allows users to locate skills related to a particular query string. This is particularly useful for identifying pre-existing skills within a skill library that may fulfill a requirement or for exploring available functionalities.
- Basic Search:
skills = search("extract pages from a pdf")
- Refined Search:
skills = search("extract pages from a pdf", top_k=3, threshold=0.85)
Notes:¶
- The
query
should be descriptive to enhance the accuracy of retrieved results. - Adjust
top_k
andthreshold
to balance between specificity and breadth of results. - Ensure to check the length of the returned list to validate the presence of results before usage.
Now that we have a skill library which contains the skills we are interested in, we can search them by using RAG.
In [1]:
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
In [2]:
Copied!
from creator import search
from creator import search
In [3]:
Copied!
skills = search("I want to solve game of 24")
skills = search("I want to solve game of 24")
▌ loading vector database...
In [4]:
Copied!
from creator.utils import print
from creator.utils import print
In [5]:
Copied!
for skill in skills:
print("---", print_type="markdown")
print(str(skill), print_type="markdown")
for skill in skills:
print("---", print_type="markdown")
print(str(skill), print_type="markdown")
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Skill Details: • Name: solve_game_of_24 • Description: This skill solves the Game of 24 by finding a way to combine four given numbers using basic arithmetic operations to obtain the result of 24. • Version: 1.0.0 • Usage: numbers = [1, 1, 2, 12] solution = solve_game_of_24(numbers) print(solution) • Parameters: • numbers (array): An array of four numbers to be used in the Game of 24. • Required: True • Returns: • solution (string): The solution expression that equals 24, or 'No solution found' if no solution is found.
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Skill Details: • Name: game_of_24 • Description: This skill solves the Game of 24, a popular card game where four numbers are given and the goal is to find a way to manipulate these numbers using any of the four basic arithmetic operations (addition, subtraction, multiplication, and division) so that the end result is 24. The skill generates all possible permutations of the four numbers and for each permutation, generates all possible combinations of the four basic arithmetic operations. For each combination of operations, it calculates the result and checks if it equals 24. If a solution is found, the skill outputs the sequence of operations and numbers that leads to 24. If no solution is found after checking all permutations and combinations, the skill outputs that no solution exists. • Version: 1.0.0 • Usage: numbers = [1, 1, 2, 12] solution = game_of_24(numbers) print(solution) • Parameters: • numbers (array): An array of four numbers to be used in the Game of 24. • Required: True • Returns: • solution (string): A string representing the sequence of operations and numbers that leads to 24, or a message stating that no solution exists.
In [6]:
Copied!
skills = search("I want to seperate a pdf into multiple pieces", top_k=1, threshold=0.75)
skills = search("I want to seperate a pdf into multiple pieces", top_k=1, threshold=0.75)
In [7]:
Copied!
skills[0].show()
skills[0].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