2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
43 `{% if and_or %}{{ and_or }}{% endif %} ${id ? "id = ?" : "" } ${key ? "json_extract(body, '$.${key}') ${predicate} ?" : ""} {% if tree %}AND json_tree.key='{{ key }}' AND {% endif %}json_extract(body, '$.{{ key }}') {{ predicate }} ?{% endif %} {% if tree %}{% if key %}(json_tree.key='{{ key }}' AND {% endif %}json_tree.value {{ predicate }} ?{% if key %}){% endif %}{% endif %}`;
44
45async function executeStatement(statement, args = []) {
46 return await sqlite.execute({
47 sql: statement,
50}
51
52async function init() {
53 await sqlite.batch(schema);
54}
14}
15
16export default async function main(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18
104 mdc.autoInit();
105
106 function filterByDate(date) {
107 var parts = date.split('-');
108 var formattedDate = parts[2] + '/' + parts[1] + '/' + parts[0];
110}
111
112 async function deleteEntry(index) {
113 const response = await fetch('/log', {
114 method: 'DELETE',
121 }
122
123 async function clearAll() {
124 if (confirm('Are you sure you want to delete all entries?')) {
125 const response = await fetch('/log', { method: 'DELETE' });
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");
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.