To use the experimental AI API in Chrome, follow these steps:
There is no support yet for:
If it fails, try the following:
Note: Sometimes the model installation may take a while. Be patient and repeat the process if necessary.
To activate the models, enable the following flags in Chrome:
This is the simplest model, used for general tasks. When you send it a prompt, it tries to return a response. Here is a basic example:
const session = await ai.assistant.create(); const result = await session.prompt("Explain what JavaScript is");
You can also use systemPrompt to pass additional instructions to it:
const session = await ai.assistant.create({ systemPrompt: "You are an expert in JavaScript, providing helpful code best practices." });
This API detects the language of a text, supporting more than 100 languages and variants.
Example:
const detector = await translation.createDetector(); const results = await detector.detect("Bonjour le monde"); for (const result of results) { console.log(result.detectedLanguage, result.confidence); }
Writer API: Create new content.
Example: writing a draft of an application to the bank.
const writer = await ai.writer.create(); const result = await writer.write("Write a email asking for feedback");
Rewriter API: Improves or restructures an existing text.
const rewriter = await ai.rewriter.create(); const result = await rewriter.rewrite("La inteligencia artificial es...", { context: "Use simple words." });
All these APIs are in the experimental phase, so it is normal to find errors or inconsistencies. All feedback is welcome. If you are interested in being aware of the changes, you can fill out this form to access the documentation and receive updates.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3