Skip to content

Commit 5cd554d

Browse files
committed
Fix up ai-plugin spec to meet OpenAI standards
1 parent 79baefe commit 5cd554d

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

lib/gateway.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ class Gateway extends EventEmitter {
13411341
}
13421342
let plugin;
13431343
try {
1344-
plugin = wellKnowns.validatePlugin(data.plugin);
1344+
plugin = wellKnowns.validatePlugin(data.plugin, data.origin);
13451345
} catch (e) {
13461346
return this.__wellKnownError__(req, res, `Failed to validate plugin: ${e.message}`, 502);
13471347
}

lib/well-knowns.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,6 @@ const wellKnowns = {
253253
plugin.name = rawPlugin.name || '(No name provided)';
254254
plugin.description = rawPlugin.description || '(No description provided)';
255255
plugin.version = rawPlugin.version || 'local';
256-
plugin.enabled = rawPlugin.hasOwnProperty('enabled')
257-
? rawPlugin.enabled
258-
: false;
259256
plugin.image_url = rawPlugin.image_url || null;
260257
if (
261258
typeof plugin.image_url === 'string' &&
@@ -269,6 +266,13 @@ const wellKnowns = {
269266
plugin.forModel.description = plugin.forModel.description || plugin.description;
270267

271268
plugin.termsOfService = rawPlugin.termsOfService || null;
269+
if (
270+
typeof plugin.termsOfService === 'string' &&
271+
plugin.termsOfService.startsWith('/')
272+
) {
273+
plugin.termsOfService = `${origin}${plugin.termsOfService}`;
274+
}
275+
272276
plugin.contact = rawPlugin.contact || {};
273277

274278
const checkPluginValue = (name, isRequired = false) => {
@@ -289,10 +293,6 @@ const wellKnowns = {
289293
}
290294
};
291295

292-
if (typeof plugin.enabled !== 'boolean') {
293-
throw new Error(`plugin.enabled must be a boolean`);
294-
}
295-
296296
[
297297
'name',
298298
'description',
@@ -331,14 +331,20 @@ const wellKnowns = {
331331

332332
const AIPlugin = {};
333333
AIPlugin.schema_version = 'v1';
334-
AIPlugin.name_for_human = plugin.name;
335-
AIPlugin.name_for_model = plugin.forModel.name;
336-
AIPlugin.description_for_human = plugin.description;
337-
AIPlugin.description_for_model = plugin.forModel.description;
334+
AIPlugin.name_for_human = plugin.name.slice(0, 20);
335+
AIPlugin.name_for_model = plugin.forModel.name.slice(0, 50);
336+
AIPlugin.description_for_human = plugin.description.slice(0, 100);
337+
AIPlugin.description_for_model = plugin.forModel.description.slice(0, 8000);
338+
AIPlugin.auth = {
339+
type: 'none'
340+
};
338341
AIPlugin.api = {
339342
type: 'openapi',
340343
url: `${origin}/.well-known/openapi.yaml`
341344
};
345+
AIPlugin.logo_url = `${origin}/logo.png`;
346+
AIPlugin.contact_email = `noreply@${origin.replace(/^https?\:\/\/(.*)(:\d+)/gi, '$1')}`;
347+
AIPlugin.legal_info_url = `${origin}/tos.txt`;
342348
if (plugin.image_url) {
343349
AIPlugin.logo_url = plugin.image_url;
344350
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "functionscript",
3-
"version": "2.10.0",
3+
"version": "2.10.1",
44
"description": "An API gateway and framework for turning functions into web services",
55
"author": "Keith Horwood <keithwhor@gmail.com>",
66
"main": "index.js",

0 commit comments

Comments
 (0)