You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/altk_json_processor/README.md
+25-5Lines changed: 25 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,16 @@
5
5
6
6
Uses JSON Processor from ALTK to extract data from long JSON responses. See the [ALTK](https://altk.ai/) and the [JSON Processor component in the ALTK repo](https://github.com/AgentToolkit/agent-lifecycle-toolkit/tree/main/altk/post_tool/code_generation) for more details on how the component works.
7
7
8
+
Note that this plugin will require calling an LLM and will therefore require configuring an LLM provider as described below. This plugin will also incure some cost in terms of time and money to do its LLM calls. This can be adjusted via the length threshold in the configuration, such that the plugin only activates and calls an LLM on JSON responses of a particular length (default: 100,000 characters).
9
+
8
10
## Hooks
9
11
-`tool_post_invoke` - Detects long JSON responses and processes as necessary
10
12
11
13
## Installation
12
14
13
-
1. Copy .env.example .env
14
-
2. Enable plugins in `.env`
15
-
3. Enable the "ALTKJsonProcessor" plugin in `plugins/config.yaml`.
16
-
4. Install the optional dependency `altk` (i.e. `pip install mcp-context-forge[altk]`)
15
+
1. Enable the "ALTKJsonProcessor" plugin in `plugins/config.yaml`.
16
+
2. Install the optional dependency `altk` (i.e. `pip install mcp-context-forge[altk]`)
17
+
3. Configure a LLM provider as described below.
17
18
18
19
## Configuration
19
20
@@ -29,7 +30,7 @@ Uses JSON Processor from ALTK to extract data from long JSON responses. See the
29
30
config:
30
31
jsonprocessor_query: ""
31
32
llm_provider: "watsonx"# one of watsonx, ollama, openai, anthropic
32
-
watsonx:
33
+
watsonx:# each section of providers is optional
33
34
wx_api_key: ""# optional, can define WX_API_KEY instead
34
35
wx_project_id: ""# optional, can define WX_PROJECT_ID instead
35
36
wx_url: "https://us-south.ml.cloud.ibm.com"
@@ -45,3 +46,22 @@ Uses JSON Processor from ALTK to extract data from long JSON responses. See the
45
46
46
47
- `length_threshold` is the minimum number of characters before activating this component
47
48
- `jsonprocessor_query` is a natural language statement of what the long response should be processed for. For an example of a long response for a musical artist: "get full metadata for all albums from the artist's discography in json format"
49
+
50
+
### LLM Provider Configuration
51
+
52
+
In the configuration, select an LLM Provider via `llm_provider`, the current options are WatsonX, Ollama, OpenAI, or Anthropic.
53
+
Then fill out the corresponding provider section in the plugin config. For many of the api key-related fields, an environment variable
54
+
can also be used instead. If the field is set in both the plugin config and in an environment variable, the plugin config takes priority.
55
+
56
+
### JSON Processor Query
57
+
58
+
To guide the JSON Processor, an optional but recommended `jsonprocessor_query` can be provided that is a natural language statement of what the long response should be processed for.
59
+
60
+
Example queries:
61
+
62
+
- For an API endpoint such as [this Spotify artist overview](https://rapidapi.com/DataFanatic/api/spotify-scraper/playground/apiendpoint_fd33b4eb-d258-437e-af85-c244904acefc) that returns a large response, if you only want the discography of the artist, use a query such as: "get full metadata for all albums from the artist's discography in json format"
63
+
- For a shopping API endpoint that returns a [response like this](https://raw.githubusercontent.com/AgentToolkit/agent-lifecycle-toolkit/refs/heads/main/examples/codegen_long_response_example.json), if you only want the sizes of hte sneakers, use a query such as: "get the sizes for all products"
64
+
65
+
## Testing
66
+
67
+
Unit tests: `tests/unit/mcpgateway/plugins/plugins/altk_json_processor/test_json_processor.py`
0 commit comments