mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
#820 - Update endpoints
This commit is contained in:
@@ -16,13 +16,17 @@ export const WEBSITE_LINKS = {
|
||||
api: {
|
||||
baseUrl: 'https://fontmatter-fncs.azurewebsites.net',
|
||||
endpoints: {
|
||||
ai: '/api/ai',
|
||||
ai: {
|
||||
description: '/api/ai/description',
|
||||
taxonomy: '/api/ai/taxonomy',
|
||||
title: '/api/ai/title'
|
||||
},
|
||||
chat: {
|
||||
init: '/api/ai-init',
|
||||
message: '/api/ai-chat',
|
||||
feedback: '/api/ai-feedback'
|
||||
},
|
||||
backers: '/api/backers'
|
||||
backers: '/api/v2/backers'
|
||||
}
|
||||
},
|
||||
docs: {
|
||||
|
||||
@@ -9,9 +9,6 @@ import { TaxonomyType } from '../models';
|
||||
import * as l10n from '@vscode/l10n';
|
||||
import { LocalizationKey } from '../localization';
|
||||
|
||||
const AI_URL = `${WEBSITE_LINKS.api.baseUrl}${WEBSITE_LINKS.api.endpoints.ai}`;
|
||||
// const AI_URL = 'http://localhost:3000/api/ai';
|
||||
|
||||
export class SponsorAi {
|
||||
/**
|
||||
* Get title suggestions from the AI
|
||||
@@ -28,19 +25,22 @@ export class SponsorAi {
|
||||
}, 10000);
|
||||
const signal = controller.signal;
|
||||
|
||||
const response = await fetch(`${AI_URL}/title`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: title,
|
||||
token: token,
|
||||
nrOfCharacters: Settings.get<number>(SETTING_SEO_TITLE_LENGTH) || 60
|
||||
}),
|
||||
signal: signal as any
|
||||
});
|
||||
const response = await fetch(
|
||||
`${WEBSITE_LINKS.api.baseUrl}${WEBSITE_LINKS.api.endpoints.ai.title}`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: title,
|
||||
token: token,
|
||||
nrOfCharacters: Settings.get<number>(SETTING_SEO_TITLE_LENGTH) || 60
|
||||
}),
|
||||
signal: signal as any
|
||||
}
|
||||
);
|
||||
clearTimeout(timeout);
|
||||
|
||||
const data: string[] = await response.json();
|
||||
@@ -66,20 +66,23 @@ export class SponsorAi {
|
||||
articleContent = articleContent.substring(0, 2000);
|
||||
}
|
||||
|
||||
const response = await fetch(`${AI_URL}/description`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: title,
|
||||
content: articleContent,
|
||||
token: token,
|
||||
nrOfCharacters: Settings.get<number>(SETTING_SEO_DESCRIPTION_LENGTH) || 160
|
||||
}),
|
||||
signal: signal as any
|
||||
});
|
||||
const response = await fetch(
|
||||
`${WEBSITE_LINKS.api.baseUrl}${WEBSITE_LINKS.api.endpoints.ai.description}`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: title,
|
||||
content: articleContent,
|
||||
token: token,
|
||||
nrOfCharacters: Settings.get<number>(SETTING_SEO_DESCRIPTION_LENGTH) || 160
|
||||
}),
|
||||
signal: signal as any
|
||||
}
|
||||
);
|
||||
clearTimeout(timeout);
|
||||
|
||||
const data: string = await response.text();
|
||||
@@ -129,15 +132,18 @@ export class SponsorAi {
|
||||
taxonomy: optionsString
|
||||
});
|
||||
|
||||
const response = await fetch(`${AI_URL}/taxonomy`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body,
|
||||
signal: signal as any
|
||||
});
|
||||
const response = await fetch(
|
||||
`${WEBSITE_LINKS.api.baseUrl}${WEBSITE_LINKS.api.endpoints.ai.taxonomy}`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body,
|
||||
signal: signal as any
|
||||
}
|
||||
);
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user