xkonti-gptapitemplate.web.val.run
Readme

This Val is a template for creating GPT actions. To have a full explanation on how to use it or create your own, you can check out the Creating GPT Actions with ValTown tutorial:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { blob } from "https://esm.town/v/std/blob";
import { extractHttpEndpoint } from "https://esm.town/v/xkonti/extractHttpEndpoint?v=2";
import { GptApi } from "https://esm.town/v/xkonti/gptApiFramework?v=67";
import { z } from "npm:zod";
// Configure API
const api = new GptApi({
url: extractHttpEndpoint(import.meta.url).toLowerCase(),
title: "API Name",
description: "The API for submitting fun Video Game Ideas",
version: "1.0.0",
policyGetter: async () => {
const { markdownToPrettyPage } = await import("https://esm.town/v/xkonti/markdownToHtmlPage?v=5");
return await markdownToPrettyPage(privacyPolicy);
},
});
// ENDPOINT /example
const InputSchema = z.object({
inputField1: z.string().describe("Description of the input field"),
}).describe("Description of the input");
const OutputSchema = z.object({
outputField1: z.string().describe("Description of the output field"),
}).describe("Description of the output");
api.jsonToJson({
verb: "post",
path: "/example",
operationId: "example",
desc: "Description of the example action",
requestSchema: InputSchema,
responseSchema: OutputSchema,
}, async (ctx, input, apiKey) => {
// Implementation of the /example endpoint
return {
outputField1: input.inputField1,
};
});
// Serve the API
export default api.serve();
// Privacy policy template in Markdown
const privacyPolicy = `# <apiName> Privacy Policy
Last Updated: <lastUpdated>
## 1. Introduction
Welcome to <apiName>. This privacy policy outlines our practices regarding the collection, use, and sharing of information through <apiName>.
## 2. Data Collection and Use
<apiName> allows users to store, retrieve, list, and delete data. The data stored can be of any type as inputted by the user. We do not restrict or control the content of the data stored. The API operates as a public database, where data can be accessed by
## 3. Data Security
<apiName> is protected by an API key. Users should be aware that any data they input can be accessed, modified, or deleted by other users with access to the API key. Users are advised not to store sensitive, personal, or confidential information. We assume
## 4. Changes to This Policy
We reserve the right to modify this privacy policy at any time. Any changes will be effective immediately upon posting on our website.
## 5. Contact Us
For any questions or concerns regarding this privacy policy, please contact us at <contactEmail>.
`;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v5
May 29, 2024