344<style>${css}</style>
345<meta name="viewport" content="width=device-width, initial-scale=1.0">
346<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
347</head>
348<body>
381`;
382383const response = await fetch("https://api.github.com/graphql", {
384method: "POST",
385headers: {
js_auth_authenticatemain.tsx2 matches
1import { authenticate, getCoreApiBaseEndpoint, jwtVerify } from "jsr:@commercelayer/js-auth";
23const auth = await authenticate("client_credentials", {
12if ("organization" in decodedJWT.payload) {
13console.log("organization slug is", decodedJWT.payload.organization.slug);
14console.log("base endpoint is", getCoreApiBaseEndpoint(auth.accessToken));
15}
freesoundSearchmain.tsx3 matches
7import * as qs from "https://deno.land/x/querystring@v1.0.2/mod.js";
89const FREESOUND_API_KEY = Deno.env.get("FREESOUND_API_KEY");
10const BASE_URL = "https://freesound.org/apiv2";
1112interface FreeSoundResponse {
28const queryString = qs.stringify({
29query: query,
30token: FREESOUND_API_KEY,
31fields: "id,name,previews",
32page_size: 1,
iframeGridInfinitemain.tsx4 matches
142setIsLoading(true);
143try {
144const response = await fetch('/api/submit-url', {
145method: 'POST',
146headers: {
162const loadUrlDatabase = async () => {
163try {
164const response = await fetch('/api/load-urls');
165if (!response.ok) throw new Error('Failed to load URLs');
166const loadedUrls = await response.json();
256257async function server(request: Request): Promise<Response> {
258if (request.method === 'POST' && new URL(request.url).pathname === '/api/submit-url') {
259return handleSubmitUrl(request);
260}
261262if (request.method === 'GET' && new URL(request.url).pathname === '/api/load-urls') {
263return handleLoadUrls();
264}
drumMachinemain.tsx1 match
1// A web audio drum machine that pulls samples from the Freesound search API.
2// A 16-step step sequencer with 4 sampled voices. Each sample is the first two
3// seconds of a Freesound search result. Tweaking the search string a little bit
githubreposearchmain.tsx3 matches
7const order = "desc";
89const url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&order=${order}`;
1011const response = await fetch(url, {
12headers: {
13"Accept": "application/vnd.github.v3+json",
14"User-Agent": "Deno-GitHub-Repo-Fetcher", // GitHub API requires a user-agent header
15},
16});
1718if (!response.ok) {
19throw new Error(`GitHub API responded with status: ${response.status}`);
20}
21
gptMemoryManagerREADME.md20 matches
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
23# Demonstration
7
89What GPT sent do the API:
1011```json
24# Setup
2526There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
3132## Deploying the API on Val Town
3334Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
3536In the code configure the appropriate values:
3738- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
4344## Create API keys
4546The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
4748The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
5556The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
6566## Adding the prompt section
gptMemoryManagermain.tsx24 matches
1import * as uuid from "https://deno.land/std/uuid/mod.ts";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "npm:hono@3";
56export const handleMemoryApiRequest = async (
7req: Request,
8apiName: string,
9contactEmail: string,
10lastPolicyUpdate: string,
11blobKeyPrefix: string,
12apiKeyPrefix: string,
13) => {
14// ==== HELPERS ====
2728const verifyRequest = (c): { memoriesKey: string; error: any } => {
29// Verify API key coming as a Bearer header
30const authHeader = c.req.headers.get("Authorization");
31if (!authHeader || !authHeader.startsWith("Basic ")) {
43return { memoriesKey: "", error: c.text("Forbidden", 403) };
44}
45const expectedKey = Deno.env.get(apiKeyPrefix + key) ?? null;
46if (token !== expectedKey) {
47console.error("Invalid API KEY header");
48return { memoriesKey: "", error: c.text("Forbidden", 403) };
49}
51};
5253// API
5455const app = new Hono();
209// PRIVACY POLICY
210app.get("/privacy", async (c) => {
211const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
212c.header("Content-Type", "text/html");
213return c.html(policy);
214});
215216app.get("/openapi", async (c) => {
217const specification = `
218{
219"openapi": "3.1.0",
220"info": {
221"title": "Memories API",
222"description": "API for managing and storing long-term memories.",
223"version": "1.0.0"
224},
225"servers": [
226{
227"url": "<APIURL>"
228}
229],
238},
239"401": {
240"description": "Unauthorized - Missing or invalid API key."
241},
242"403": {
243"description": "Forbidden - Invalid API key."
244}
245},
272},
273"401": {
274"description": "Unauthorized - Missing or invalid API key."
275},
276"403": {
277"description": "Forbidden - Invalid API key."
278}
279},
328},
329"401": {
330"description": "Unauthorized - Missing or invalid API key."
331},
332"403": {
333"description": "Forbidden - Invalid API key."
334}
335},
375},
376"401": {
377"description": "Unauthorized - Missing or invalid API key."
378},
379"403": {
380"description": "Forbidden - Invalid API key."
381}
382},
406},
407"401": {
408"description": "Unauthorized - Missing or invalid API key."
409},
410"403": {
411"description": "Forbidden - Invalid API key."
412}
413},
gpt_memoryREADME.md20 matches
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
23# Demonstration
7
89What GPT sent do the API:
1011```json
24# Setup
2526There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
3132## Deploying the API on Val Town
3334Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
3536In the code configure the appropriate values:
3738- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
4344## Create API keys
4546The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
4748The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
5556The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
6566## Adding the prompt section
bookReservationOnResymain.tsx7 matches
30}) => {
31const { z } = await import("npm:zod");
32const RESY_API_URL = "https://api.resy.com";
33const RESY_DEFAULT_HEADERS = {
34accept: "application/json, text/plain, */*",
35"accept-encoding": "gzip, deflate, br",
36"accept-language": "en-US,en;q=0.9",
37authorization: "ResyAPI api_key=\"VbWk7s3L4KiK5fzlO7JD3Q5EYolJI7n5\"",
38"x-origin": "https://resy.com",
39origin: "https://resy.com/",
145)
146}&password=${encodeURIComponent(params.password)}`;
147const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148method: "POST",
149body: body,
166seats: number;
167}) => {
168const url = `${RESY_API_URL}/3/details`;
169const response = await fetch(url.toString(), {
170method: "POST",
185seats: number;
186}) => {
187const url = `${RESY_API_URL}/4/find`;
188const searchParams = new URLSearchParams();
189searchParams.set("lat", "0");
208city: string;
209}) => {
210const url = `${RESY_API_URL}/3/venue`;
211const searchParams = new URLSearchParams();
212searchParams.set("url_slug", params.slug);
224authToken: string;
225}) => {
226const response = await fetch(`${RESY_API_URL}/3/book`, {
227method: "POST",
228headers: {