1Migrated from folder: Archive/memoryApiExample
1import { handleMemoryApiRequest } from "https://esm.town/v/xkonti/gptMemoryManager";
2
3const apiName = "Memory API";
4const contactEmail = "some@email.com";
5const lastPolicyUpdate = "2023-11-28";
6const blobKeyPrefix = "gpt:memories:";
7const apiKeyPrefix = "GPTMEMORYAPI_KEY_";
8
9export const memoryApiExample = async (req: Request) => {
10 return await handleMemoryApiRequest(
11 req,
12 apiName,
13 contactEmail,
14 lastPolicyUpdate,
15 blobKeyPrefix,
16 apiKeyPrefix,
17 );
18};
33 // Verify this webhook came from our bot
34 if (
35 req.headers.get("x-telegram-bot-api-secret-token")
36 !== process.env.telegramWebhookSecret
37 ) {
5 try {
6 const soRes = await fetch(
7 `https://api.stackexchange.com/2.3/questions?fromdate=${startDate}&todate=${endDate}&order=desc&sort=creation&tagged=pinata&site=stackoverflow`,
8 {
9 method: "GET",
24
25 const seRes = await fetch(
26 `https://api.stackexchange.com/2.3/questions?fromdate=${startDate}&todate=${endDate}&order=desc&sort=creation&tagged=pinata&site=ethereum`,
27 {
28 method: "GET",
1export async function crux_add(name: string, content: string) {
2 const res = await fetch("https://crux.land/api/add", {
3 method: "POST",
4 headers: { "content-type": "application/json" },
14 const json = await res.json();
15 if (json.error) throw new Error(json.error);
16 return `https://crux.land/api/get/${json.id}`;
17}
6 const { default: axios } = await import("npm:axios");
7 const url =
8 "https://sapphire.api.microsoftapp.net/config/api/v1/get?setmkt=en-us&setplatform=android&setchannel=production&settenant=sapphire-bing";
9 try {
10 const response = await fetch(url, {
6 const { default: axios } = await import("npm:axios");
7 const url =
8 "https://sapphire.api.microsoftapp.net/config/api/v1/get?setmkt=en-us&setplatform=android&setchannel=production&settenant=sapphire-bing";
9 try {
10 const response = await fetch(url, {
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();
7export async function getReplicatePrediction({
8 /** https://replicate.com/account */
9 apiKey,
10 predictionId,
11}: {
12 apiKey: string;
13 predictionId: string;
14}) {
15 if (!apiKey) {
16 throw new Error("missing apiKey; visit https://replicate.com/account");
17 } else if (!predictionId) {
18 throw new Error("missing predictionId");
19 }
20 const result = await fetchJSON(
21 `https://api.replicate.com/v1/predictions/${encodeURIComponent(predictionId)}`,
22 {
23 headers: {
24 Authorization: `Token ${apiKey}`,
25 },
26 },
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();