| 1 |
import apiFetch from "@wordpress/api-fetch"; |
| 2 |
|
| 3 |
const config = window.betterdocsDocsAI || {}; |
| 4 |
|
| 5 |
export const i18n = config.i18n || {}; |
| 6 |
export const SUPPORTED_TAXONOMIES = config.taxonomies || [ "doc_category", "doc_tag" ]; |
| 7 |
|
| 8 |
/** |
| 9 |
* Request AI-suggested taxonomy terms for the current doc. |
| 10 |
* |
| 11 |
* @return {Promise<Object>} REST response: { success, data: { taxonomy, suggestions, model } } |
| 12 |
*/ |
| 13 |
export function suggestTerms( { taxonomy, postId, content, title, maxSuggestions } ) { |
| 14 |
return apiFetch( { |
| 15 |
url: config.restSuggestTerms, |
| 16 |
method: "POST", |
| 17 |
data: { |
| 18 |
taxonomy, |
| 19 |
post_id: postId, |
| 20 |
content, |
| 21 |
title, |
| 22 |
max_suggestions: maxSuggestions, |
| 23 |
}, |
| 24 |
} ); |
| 25 |
} |
| 26 |
|