Given a user input describing the task they wish to accomplish, return a list of Pack IDs that the given LLM thinks will be suitable for this task. This is good for a "pre-processing" step after receiving the task but before trying to solve it. This allows you to benefit from the wide t
(
task_description: str,
llm: Union[BaseChatModel, Callable],
function_request: Optional[str] = None,
config: PackConfig = PackConfig.global_config(),
)
| 66 | |
| 67 | |
| 68 | def select_packs( |
| 69 | task_description: str, |
| 70 | llm: Union[BaseChatModel, Callable], |
| 71 | function_request: Optional[str] = None, |
| 72 | config: PackConfig = PackConfig.global_config(), |
| 73 | ) -> list[type[Pack]]: |
| 74 | """Given a user input describing the task they wish to accomplish, return a list of Pack IDs that the given LLM |
| 75 | thinks will be suitable for this task. |
| 76 | |
| 77 | This is good for a "pre-processing" step after receiving the task but before trying to solve it. This allows you |
| 78 | to benefit from the wide tool selection while keeping your token usage low. |
| 79 | |
| 80 | You can then further filter, install the packs if desired, and then fetch them using get_pack(). |
| 81 | |
| 82 | # TODO: Include user-provided packs into selection |
| 83 | |
| 84 | Args: |
| 85 | task_description (str): A description of the task to be used when selecting tools |
| 86 | llm (BaseChatModel): An LLM which will be used to evaluate the selection |
| 87 | function_request (Optional[str]): A specific type of function asked for (e.g. a `get_more_tools` function) |
| 88 | config (PackConfig): Custom config to use |
| 89 | |
| 90 | Returns: |
| 91 | list[str]: A list of selected Pack IDs |
| 92 | """ |
| 93 | |
| 94 | if config.installer_style == InstallerStyle.manual: |
| 95 | selection_pool = get_all_installed_packs() |
| 96 | else: |
| 97 | selection_pool = get_all_pack_info() |
| 98 | |
| 99 | prompt = select_packs_prompt(selection_pool, task_description, function_request) |
| 100 | |
| 101 | response = call_llm(prompt, llm) |
| 102 | |
| 103 | return parse_selection_response(response) |
| 104 | |
| 105 | |
| 106 | def parse_selection_response(response: str) -> list[type[Pack]]: |