< ai-taxonomist >
Demo · AI Taxonomist Server · Pl@ntNet API · Cos4Cloud
<ai-taxonomist>
A WebComponent within AI-Taxonomist project to identify plants|frog|anything in any web pages.
This WebComponent follows the open-wc recommendation.
Demo
DEMO: plantnet.org/ai-taxonomist-demo/
Recommended usage
- Get an API Key for Pl@ntNet here.
- Allow the domains on your Pl@ntNet account, for
http://localhost:8000
for local development orhttps://example.com
for production website here. - There are several ways to use the web components:
- Within a web page in HTML (example: a WordPress or a static website)
<script src="https://unpkg.com/ai-taxonomist/dist/src/index.js?module" type="module"></script> <ai-taxonomist apiKey="YOUR_API_KEY"></ai-taxonomist>
- Within a JavaScript project (React, Vue, Svelte, Angular, etc):
- a. Install the package:
npm i ai-taxonomist
- b. Import the package:
import 'ai-taxonomist';
- c. Add the component:
<ai-taxonomist apiKey="YOUR_API_KEY"></ai-taxonomist>
- a. Install the package:
Advanced usage
You can also use your own server, for this you can specify the server endpoint like so:
<ai-taxonomist apiUrl="https://api.example.com/v2/identify" apiKey="XXXXXXXXX"></ai-taxonomist>
Options
apiUrl
: (default:https://my-api.plantnet.org/v2/identify/all
) the server url to call, either local or remote
Example with a Local url (the server will need to add the API key):<ai-taxonomist apiUrl="http://localhost:3000"></ai-taxonomist>
apiKey
: the API key to use, if not added by the server. On Pl@ntNet API you currently cannot use the apiKey directly due to CORS being checked (so you need to add a proxy at least, cfserver
nginx config).
Example for Pl@ntNet:<ai-taxonomist apiUrl="https://my-api.plantnet.org/v2/identify/all" apiKey="XXXXXXXXX"></ai-taxonomist>
backendFormat
: (default:pn
) backend format of the API:pn
(PlantNet),c4c
(Cos4Cloud) orcarp
(CARPESO)maxImages
: The number of images the user can upload for a single identification, default to 5.removePlantNetBranding
: (default: false) if true, the component will not display the PlantNet logo and the link to the PlantNet website.- Attachments: You can attach HTML elements to each result, for example if you want to let the user select the correct taxon. This can be achieve using an HTML
<template>
as follows:You should NOT attach a click listener on your side. The AiTaxonomist component will listen for the click and fire a new event named<template id="aitaxonomist-attachments-template"> <style> button { border: 1px solid #8888FF; background: transparent; } button:hover { filter: brightness(1.2); } </style> <button>SELECT SPECIES</button> </template> <ai-taxonomist> </ai-taxonomist>
aiTaxonomistAttachmentsClick
which contain the selected taxon details inevent.detail
:The detail will contain the properties listed ondocument.addEventListener('aiTaxonomistAttachmentsClick', (e) => { alert('Attachments clicked: ' + e.detail.taxonName) })
ResultType
.
Styling
- Dark Mode: you can override dark mode by specifying either
prefer-dark
orprefer-light
in the<ai-taxonomist>
class element. Doing so will either force the dark/light mode to stay in dark/light mode no matter what the user preference is.
Development / contributions
Start the development server
npm start
This should open http://localhost:8000 in your browser.
Linting and formatting
To scan the project for linting and formatting errors, run npm run lint
To automatically fix linting and formatting errors, run npm run format
Release
Update the version:
npm version major|minor|patch
Publish the version pn NPM:
npm publish