2import { email } from "https://esm.town/v/std/email";
3
4export async function main() {
5 const areas: Area[] = [
6 {
9
10
11export async function fetchCongressTradeReports(callback) {
12 const res = await fetchJSON(
13 "https://bff.capitoltrades.com/trades?sortBy=-pubDate"
15 const trades = res.data;
16
17 function isToday(d) {
18 const now = new Date();
19 return (
1```
2export default async function main(req: Request): Promise<Response> {
3 const html = `
4 <!DOCTYPE html>
1```
2// This function returns an HTML response with a "Hello, World!" message styled using CSS
3// to have crazy colors and gradien
4
5export default async function main(req: Request) {
6 const body = `
7 <!DOCTYPE html>
1```
2export default async function main(req: Request): Promise<Response> {
3 // Return a basic HTML response with "Hello, World!" message
4 return new Response("<h1>Hello, World!</h1>", {
27the simplest way to achieve the goal, though you can add some inline comments to explain your
28reasoning (not for every line, but for major groups of lines). Don't use any environment variables
29unless strictly necessary, for example use APIs that don't require a key, prefer internal function
30imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
31functions where possible. Unless specified, don't add error handling,
32make sure that errors bubble up to the caller.
33There should be no comments like "more content here", it should be complete and directly runnable.
34The val should create a "export default async function main" which is the main function that gets
35executed on every HTTP request.
36`.replace("\n", " ");
37
38// Your response should start with \`\`\`ts and end with \`\`\`.
39// The val should create a "export default async function main() {" which
40// is the main function that gets executed, without any arguments. Don't return a Response object,
41// just return a plain Javascript object, array, or string.
42
70 const writer = writable.getWriter();
71 const textEncoder = new TextEncoder();
72 function write(text: string) {
73 writer.write(textEncoder.encode(text));
74 }
113 </div>
114 <script>
115 function openTab(tab) {
116 const tabButtonCode = document.getElementById("tab-button-code");
117 const tabButtonPreview = document.getElementById("tab-button-preview");
137 (() => {
138 const scrollingElement = document.getElementById("conversation-container");
139 const callback = function (mutationsList, observer) {
140 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
141 };
218 document.getElementById("code-textarea").value = "";
219 let fullStr = "";
220 window.addToken = function(str) {
221 fullStr += str;
222 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
26the simplest way to achieve the goal, though you can add some inline comments to explain your
27reasoning (not for every line, but for major groups of lines). Don't use any environment variables
28unless strictly necessary, for example use APIs that don't require a key, prefer internal function
29imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
30functions where possible. Unless specified, don't add error handling,
31make sure that errors bubble up to the caller.
32There should be no comments like "more content here", it should be complete and directly runnable.
33The val should create a "export default async function main" which is the main function that gets
34executed on every HTTP request.
35`.replace("\n", " ");
66 const writer = writable.getWriter();
67 const textEncoder = new TextEncoder();
68 function write(text) {
69 writer.write(textEncoder.encode(text));
70 }
101 </div>
102 <script>
103 function openTab(tab) {
104 const tabButtonCode = document.getElementById("tab-button-code");
105 const tabButtonPreview = document.getElementById("tab-button-preview");
125 (() => {
126 const scrollingElement = document.getElementById("conversation-container");
127 const callback = function (mutationsList, observer) {
128 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
129 };
192 document.getElementById("code-textarea").value = "";
193 let fullStr = "";
194 window.addToken = function(str) {
195 fullStr += str;
196 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
1Sure, I'll focus on cleaning up some repeated code, improve code readability, and add some enhancements while keeping the existing functionality intact. Here's the improved version:
2
3ts
22};
23
24const systemPrompt = `The conversation below is your recent interaction with the user. Your entire response should only be TypeScript. Your response should start with \`\`\`ts and end with \`\`\`. Make an HTTP val (other vals are currently not supported to run, even though we have examples for them). Start your response with a comment explaining how your approach will work, what libraries or API calls you will use, and any tradeoffs you're making. Then write the code in a concise way, the simplest way to achieve the goal, though you can add some inline comments to explain your reasoning (not for every line, but for major groups of lines). Don't use any environment variables unless strictly necessary, for example use APIs that don't require a key, prefer internal function imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno functions where possible. Unless specified, don't add error handling, make sure that errors bubble up to the caller. There should be no comments like "more content here", it should be complete and directly runnable. The val should create a "export default async function main" which is the main function that gets executed on every HTTP request.`.replace("\n", " ");
25
26const additionalPrompt = `Since your last response the user might have changed the code. The current version of the code is below. Keep your response as close to their current code as possible, only changing things that are strictly necessary to change.`.replace("\n", "");
54 const textEncoder = new TextEncoder();
55
56 function write(text) {
57 writer.write(textEncoder.encode(text));
58 }
84 </div>
85 <script>
86 function openTab(tab) {
87 const tabButtonCode = document.getElementById("tab-button-code");
88 const tabButtonPreview = document.getElementById("tab-button-preview");
108 (() => {
109 const scrollingElement = document.getElementById("conversation-container");
110 const callback = function (mutationsList, observer) {
111 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
112 };
158 document.getElementById("code-textarea").value = "";
159 let fullStr = "";
160 window.addToken = function(str) {
161 fullStr += str;
162 const code = fullStr.replace(/ts\\n/g, "").replace(//g, "");
19};
20
21const systemprompt = `The conversation below is your recent interaction with the user. Your entire response should only be TypeScript. Your response should start with \`\`\`ts and end with \`\`\`. Make an HTTP val (other vals are currently not supported to run, even though we have examples for them). Start your response with a comment explaining how your approach will work, what libraries or API calls you will use, and any tradeoffs you're making. Then write the code in a consise way, the simplest way to achieve the goal, though you can add some inline comments to explain your reasoning (not for every line, but for major groups of lines). Don't use any environment variables unless strictly necessary, for example use APIs that don't require a key, prefer internal function imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno functions where possible. Unless specified, don't add error handling, make sure that errors bubble up to the caller. There should be no comments like "more content here", it should be complete and directly runnable. The val should create a "export default async function main" which is the main function that gets executed on every HTTP request. `.replace("\n", " ");
22
23// Your response should start with \`\`\`ts and end with \`\`\`. The val should create a "export default async function main() {" which is the main function that gets executed, without any arguments. Don't return a Response object, just return a plain Javascript object, array, or string.
24
25const systemprompt2 = `Since your last response the user might have changed the code. The current version of the code is below. Keep your response as close to their current code as possible, only changing things that are strictly necessary to change.`.replace("\n", "");
50 const writer = writable.getWriter();
51 const textEncoder = new TextEncoder();
52 function write(text) {
53 writer.write(textEncoder.encode(text));
54 }
91 </div>
92 <script>
93 function openTab(tab) {
94 const tabButtonCode = document.getElementById("tab-button-code");
95 const tabButtonPreview = document.getElementById("tab-button-preview");
115 (() => {
116 const scrollingElement = document.getElementById("conversation-container");
117 const callback = function (mutationsList, observer) {
118 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
119 };
185 document.getElementById("code-textarea").value = "";
186 let fullStr = "";
187 window.addToken = function(str) {
188 fullStr += str;
189 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
25the simplest way to achieve the goal, though you can add some inline comments to explain your
26reasoning (not for every line, but for major groups of lines). Don't use any environment variables
27unless strictly necessary, for example use APIs that don't require a key, prefer internal function
28imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
29functions where possible. Unless specified, don't add error handling,
30make sure that errors bubble up to the caller.
31There should be no comments like "more content here", it should be complete and directly runnable.
32The val should create a "export default async function main" which is the main function that gets
33executed on every HTTP request.
34`.replace("\n", " ");
64 const textEncoder = new TextEncoder();
65
66 function write(text) {
67 writer.write(textEncoder.encode(text));
68 }
101 </div>
102 <script>
103 function openTab(tab) {
104 const tabButtonCode = document.getElementById("tab-button-code");
105 const tabButtonPreview = document.getElementById("tab-button-preview");
125 (() => {
126 const scrollingElement = document.getElementById("conversation-container");
127 const callback = function (mutationsList, observer) {
128 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
129 };
199 document.getElementById("code-textarea").value = "";
200 let fullStr = "";
201 window.addToken = function(str) {
202 fullStr += str;
203 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");