Use AI
Before using AI in script, it is required to enter Settings
from extension navbar then set:
- Select default AI provider.
- Set API key. More configures are optional.
jiant.parse.aiPrompt
will work in script.
Privacy and Security
Never use API keys in task script, set them in settings on extension.
All API keys and defaults settings will only be saved locally in browser storage. They will never be uploaded to anywhere. They are not accessible by custom script code.
They will not be edited or deleted automatically, even after logging in/out. Do it manually.
Reference
jiant.parse.aiPrompt(prompt: string, configs: object) -> Promise
@param: refer to configs
With AI settings settled correctly, you can use jiant.parse.aiPrompt
in script.
- param:
configs
is an object of custom params of request. Priority:configs in script
>defaults in user settings
>defaults built-in
let text = '兼听则明'
let res = await jiant.parse.aiPrompt('translate to English: ' + text)
console.log(res)
// output: {
// result: 'To listen to all sides makes one wise',
// raw: {...}, // raw response from selected AI provider.
// error: null,
// }
configs
: API request params defaults
You can set API request params defaults (JSON) for each AI provider.
Besides options params for their own, other common option keys are:
url
- GPT: default is
https://api.openai.com/v1/chat/completions
- Gemini: default is
https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent
- Baidu Yiyan: default is
https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions
- Replace base request URL for API.
TIP
When you want to use other provider which is compatible with GPT's API, just set url
to replace GPT's default.
model
- GPT: default is
gpt-3.5-turbo
- Replace base model name.