-
Notifications
You must be signed in to change notification settings - Fork 760
add docs for plugin_only #180
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --- | ||
| id: plugin_only | ||
| description: The Plugin Only Mode | ||
| slug: /plugin/plugin_only | ||
| --- | ||
|
|
||
| # The Plugin-Only Mode | ||
|
|
||
| ## What is the plugin-only mode? | ||
| The plugin-only mode is a restricted mode of TaskWeaver that only allows you to use plugins. | ||
| Compared to the full mode, the plugin-only mode has the following restrictions: | ||
|
|
||
| 1. The generated code only contains the calls to the plugins. | ||
| For example, the following code only calls the `ascii_render` plugin and does not contain any "free-form" code. | ||
| ```python | ||
| r1=ascii_render(text="Hello") | ||
| r1 | ||
| ``` | ||
|
|
||
| 2. Only the plugins with `plugin_only: true` in the yaml file will be loaded. | ||
| For example, the following plugin will be loaded in the plugin-only mode: | ||
| ```yaml | ||
| name: ascii_render | ||
| code: ascii_render | ||
| plugin_only: true | ||
| ... | ||
| ``` | ||
| If this field is not specified, the default value is `false`. | ||
| For plugins in the plugin-only mode, the argument type can only be `str`, `int`, `boolean`, or `float`. | ||
| Other types such as `DataFrame` are not allowed. | ||
| Essentially, we consider these plugins only produce "text-like" output that can be directly consumed by the LLM. | ||
|
|
||
| To enable the plugin-only mode, you can add the configuration `"session.plugin_only_mode": true` | ||
| in the project configuration file `taskweaver_config.json`. | ||
|
|
||
| ## Why do we need the plugin-only mode? | ||
liqul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Although the plugin-only mode is restricted, it is still useful in some scenarios. | ||
| For example, you may want to use TaskWeaver to only generate the code to call a certain plugin, | ||
| and you want to get the response from the plugin directly, without generating any other code | ||
| for safety reasons. | ||
|
|
||
| ## How is the plugin-only mode implemented? | ||
|
|
||
| The plugin-only mode is implemented based on the [function calling](https://platform.openai.com/docs/guides/function-calling) mode of LLMs. | ||
| In this mode, the LLM is trained to generate a JSON object that contains the function name and the arguments. | ||
| For example, the following JSON object is generated by the LLM: | ||
| ```json | ||
| { | ||
| "function": "ascii_render", | ||
| "arguments": { | ||
| "text": "Hello" | ||
| } | ||
| } | ||
| ``` | ||
| With this JSON object, we assemble the code to call the plugin: | ||
| ```python | ||
| r1=ascii_render(text="Hello") | ||
| r1 | ||
| ``` | ||
| Then, we execute the code and get the response from the plugin. | ||
| Therefore, the code is not directly generated by the LLM in the plugin-only mode. | ||
|
|
||
| ## Which models support the plugin-only mode? | ||
|
|
||
| Currently, the plugin-only mode is only supported by | ||
|
|
||
| - [OpenAI models](https://platform.openai.com/docs/guides/function-calling) | ||
| - [ZhipuAI models](https://open.bigmodel.cn/dev/api) | ||
|
|
||
| Likely other models that are compatible with the OpenAI models will also support the plugin-only mode. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.