13
14const clientCode = () => {
15 document.getElementById("input").addEventListener("submit", async function(event) {
16 event.preventDefault();
17
45 + `&assistantId=${input.getAttribute("data-assistant-id")}`,
46 );
47 eventSource.onmessage = function(event) {
48 console.log(event);
49 responseDiv.innerText += JSON.parse(event.data);
50 };
51
52 eventSource.onerror = function() {
53 eventSource.close();
54 };
16const sema = new Sema(5); // Adjust the number based on your desired concurrency
17
18export async function addLinksToSheet(links) {
19 let counter = 0;
20 for (const link of links) {
43}
44
45export async function getSidebar(limit = 1, start = 0) {
46 const gql = {
47 "operationName": "posts",
112
113
114// Function to escape double quotes in a CSV field
115function escapeCSVField(field) {
116 if(!field) return '""';
117 return `"${field.replace(/"/g, '""')}"`;
118}
119
120// Function to convert links to CSV
121function convertToCSV(links) {
122 const header = ["Title", "Body", "URL", "PostedAt", "CreatedAt", "Data"];
123 const rows = links.map(link => [
132}
133
134async function getAllLinks(totalLimit, offset=0) {
135 let allLinks = [];
136 const limit = 1000; // Adjust this according to the server's limit
9
10const clientCode = () => {
11 document.getElementById("input").addEventListener("submit", function(event) {
12 event.preventDefault();
13
33 + `&assistantId=${input.getAttribute("data-assistant-id")}`,
34 );
35 eventSource.onmessage = function(event) {
36 console.log(event);
37 responseDiv.innerText += JSON.parse(event.data);
38 };
39
40 eventSource.onerror = function() {
41 eventSource.close();
42 };
27const openai = new OpenAI();
28
29export async function twitterAlert({ lastRunAt }: Interval) {
30 let results = [];
31 for (const username of usernames) {
36 }
37
38 async function filterTweets(tweets) {
39 const completion = await openai.chat.completions.create({
40 messages: [
27const openai = new OpenAI();
28
29export async function twitterAlert({ lastRunAt }: Interval) {
30 let results = [];
31 for (const username of usernames) {
36 }
37
38 async function filterTweets(tweets) {
39 const completion = await openai.chat.completions.create({
40 messages: [
1import lunr from 'https://cdn.skypack.dev/lunr';
2
3const idx = lunr(function () {
4 this.field('content');
5 this.add({ id: 1, content: 'Banana Apples and Oranges' });
16}
17
18// Function to fetch tweets from a user
19export async function getTweets(username: string) {
20 const userUrl = `https://api.twitter.com/2/users/by/username/${username}`;
21 const userResponse = await fetch(userUrl, {
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
37
6);
7
8export async function uptimeCheck(url: string) {
9 let ok = true;
10 let reason: string;
166 border-radius: 50%;
167 animation: rise infinite;
168 animation-timing-function: linear;
169 }
170
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",