31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
48}
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
62}
63
64function createResError(body: string) {
65 try {
66 const e = zLibsqlError.parse(JSON.parse(body));
113 *
114 * The types are currently shown for types declared in a SQL table. For
115 * column types of function calls, for example, an empty string is
116 * returned.
117 */
2import { oceanTheme } from 'https://esm.town/v/iamseeley/oceanTheme';
3
4export async function resumeSetup(resumeConfig) {
5 const {
6 resumeJsonUrl,
18})();
19
20export default async function(req: Request): Promise<Response> {
21 await init;
22 await pg.query(`
7 `https://api.stlouisfed.org/fred/series/observations?series_id=MORTGAGE30US&api_key=${fredApiKey}&file_type=json&sort_order=desc&limit=1`;
8
9export default async function main(req: Request) {
10 try {
11 const response = await fetch(fredApiUrl);
19});
20
21async function getMuxAsset(assetId: string) {
22 if (!assetId) throw "A Mux asset ID is required.";
23
51
52// transform ["Matt", "Nick"] into { "A": "Matt" , "B": "Nick" }
53function createSpeakersObject(speakersArray: string[]) {
54 if (speakersArray.length > 26) {
55 throw new Error("We only support 26 speakers for now");
63
64type MuxCuePoint = { startTime: number; endTime?: number; value: string };
65async function getCuePointsFromMux(asset: Mux.Video.Assets.Asset): Promise<MuxCuePoint[]> {
66 const transcriptTrack = asset.tracks.find(track => track.type === "text");
67 const playbackId = asset.playback_ids.find(playbackId => playbackId.policy === "public");
87
88type AssemblyAICuePoint = { startTime: number; endTime?: number; value: { speaker: string; text: string } };
89async function getCuePointsFromAssemblyAI(
90 asset: Mux.Video.Assets.Asset,
91 speakers: { [key: string]: string },
121}
122
123async function formatTextWithGPT4o(aaiCuePoints: AssemblyAICuePoint[]) {
124 const cues = aaiCuePoints.map(cue => ({
125 speaker: cue.value.speaker,
162}
163
164export default async function(req: Request): Promise<Response> {
165 if (req.method !== "POST") {
166 return Response.json({ nope: "we (currently) just POST in these parts " });
1export function add(a: number, b: number) {
2 return a + b;
3}
5const toolset = new OpenAIToolSet({ apiKey: COMPOSIO_API_KEY });
6
7// Creating an authentication function for the user
8const appName = "github";
9
10async function setupUserConnectionIfNotExists(entityId) {
11 const entity = toolset.client.getEntity(entityId);
12 const connection = await entity.getConnection(appName);
21}
22
23// Execution function
24async function executeAgent(entityName) {
25 const entity = toolset.client.getEntity(entityName);
26 await setupUserConnectionIfNotExists(entity.id);
47}
48
49// Call the execution function
50executeAgent("default");
14 * When hit with a POST, it saves the name _and_ email of the person who has RSVPed.
15 */
16export default async function(req: Request): Promise<Response> {
17 let rsvps = await blob.getJSON("rsvps") as RSVP[];
18 rsvps ??= [];
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 send("text", {
22 * Returns your bot's settings
23 */
24async function getBotSettings(): Promise<BotSettings> {
25 return {
26 allow_attachments: true,
93) => void;
94
95function encodeEvent(event: string, data: any = {}) {
96 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
97}
98
99export default async function(req: Request): Promise<Response> {
100 const reqBody = await req.json()
101 .catch((e) => {
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.