webLLM
This is a configuration section of Custom MT. The webLLM method allows interaction with web-based Large Language Models (LLMs) by automating browser interactions and capturing streaming responses.
Parameters
method:
string- Set to "web_llm"callback:
string- Callback method for handling responses ("dataSync")url:
string- Set to null when using webLLM methodinitialUrl:
string- The initial URL of the web-based LLM interface to loadinputEvent:
array of objects- Sequence of browser interaction events:Selector: Set element property <selector: string, property: string, value: string>
Selector with Event: Trigger element event <selector: string, property: string, newEvent?: string, options?: object>
Sleep: Wait for specified duration <sleep: number> (duration in milliseconds)
streamAdapter:
string- Type of network adapter to intercept:"xhr" - XMLHttpRequest
"fetch" - Fetch API
streamOverrideDelay:
number- Delay in milliseconds before overriding stream responsesstreamType:
string- How to handle streaming data:append- Append new data to existing contentreplace- Replace content with new data
streamFormat:
string- Expected format of streaming data:"json" - JSON format
"string" - Plain text format
streamFilter:
object- Filter criteria for capturing network requests:url:
array of strings- Filter by URL patternsmethod:
array of strings- Filter by HTTP methods (["GET", "POST"])contentType:
array of strings- Filter by content type headers
streamCompleted:
object- Conditions to determine when streaming is complete:setTimeout:
number- Maximum wait time in milliseconds after last data receivedrequestReadyState:
number- XMLHttpRequest ready state value indicating completionrequestException:
string- Exception name that indicates stream completion
streamParser:
array of arrays- Pipeline of parsing operations applied to each stream chunk. Each pipeline is an array of parser objects with the following available operations:Validation Operations:
{"act": "isString"}- Check if value is a string{"act": "isArray"}- Check if value is an array{"act": "isObject"}- Check if value is an object{"act": "isNotNull"}- Check if value is not null{"act": "isNotEq", "value": string}- Check if value is not equal to specified value{"act": "minChar", "value": number}- Check if string length is at least the specified value{"act": "maxChar", "value": number}- Check if string length is at most the specified value
String Operations:
{"act": "trim"}- Remove whitespace from both ends{"act": "split", "separator": string, "limit": number, "index": number}- Split string and get element at index{"act": "replace", "find": string, "replace": string}- Replace first occurrence{"act": "replaceAll", "find": string, "replace": string}- Replace all occurrences{"act": "search", "text": string}- Check if text exists in string{"act": "indexOf", "text": string}- Get index of text in string{"act": "regexpMatch", "regexp": string, "global": boolean}- Match using regular expression{"act": "regexpReplace", "regexp": string, "global": boolean, "replace": string}- Replace using regular expression
Conversion Operations:
{"act": "toJSON"}- Parse string as JSON{"act": "toString"}- Convert value to string
Object Operations:
{"act": "getValue", "key": string}- Extract value from object by key
{
"request": {
"method": "web_llm",
"callback": "dataSync",
"initialUrl": "https://chatgpt.com/",
"url": null,
"inputEvent": [
{"selector": "#textarea", "property": "value", "value": "$SOURCE_TEXT"},
{"sleep": 100},
{"selector": "button", "property": "click"},
],
"streamAdapter": "fetch",
"streamOverrideDelay": 0,
"streamFilter": {},
"streamFormat": "string",
"streamType": "append",
"streamCompleted": {
"setTimeout": 2500,
"requestException": "AbortError"
},
"streamParser": [
[
{"act": "isString"},
{"act": "search", "text": "data:"},
{"act": "replace", "find": "data:", "replace": ""},
{"act": "toJSON"},
{"act": "isObject"},
{"act": "getValue", "key": "v"},
{"act": "isString"},
{"act": "isNotNull"}
],
[...],
[...]
]
}
}