26
27 try {
28 const response = await fetch("/", {
29 method: "POST",
30 headers: { "authorization": "Bearer " + bearerToken },
26
27export async function generateCodeAnthropic(messages: Message[]): Promise<ValResponse | null> {
28 const system = await (await fetch(`${import.meta.url.split("/").slice(0, -1).join("/")}/system_prompt.txt`)).text();
29
30 const openai = new OpenAI({
5 if (url.pathname == "/js/entry.client.js") {
6 const moduleUrl = new URL("./entry.client.tsx", import.meta.url);
7 return fetch(moduleUrl);
8 }
9 return handler(request);
155 * The main App component is rendered on the client.
156 * No server-side-specific code should be included in the App.
157 * Use fetch to communicate with the backend server portion.
158 */
159function App() {
178 * Server-only code
179 * Any code that is meant to run on the server should be included in the server function.
180 * This can include endpoints that the client side component can send fetch requests to.
181 */
182export default async function server(request: Request): Promise<Response> {
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
13 if (working) {
14 return Response.json({
15 error: "Sorry, another embedding is being fetched, wait a moment and try again",
16 })
17 }
9
10 useEffect(() => {
11 fetchTodos();
12 }, []);
13
14 const fetchTodos = async () => {
15 const response = await fetch("/todos");
16 const data = await response.json();
17 setTodos(data);
21 e.preventDefault();
22 if (!newTodo.trim()) return;
23 await fetch("/todos", {
24 method: "POST",
25 headers: { "Content-Type": "application/json" },
27 });
28 setNewTodo("");
29 fetchTodos();
30 };
31
32 const toggleTodo = async (id) => {
33 await fetch(`/todos/${id}`, { method: "PATCH" });
34 fetchTodos();
35 };
36
37 const deleteTodo = async (id) => {
38 await fetch(`/todos/${id}`, { method: "DELETE" });
39 fetchTodos();
40 };
41
1export async function importProjectFile(moduleUrl: string, path: string) {
2 const url = new URL(path, moduleUrl);
3 const resp = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${Deno.env.get("valtown")}` } });
4 if (!resp.ok) return undefined;
5 const text = await resp.text();
24
25 try {
26 const response = await fetch('/identify', {
27 method: 'POST',
28 body: formData
100 result.textContent = 'Generating schema...';
101 try {
102 const response = await fetch(window.location.href, {
103 method: 'POST',
104 headers: { 'Content-Type': 'application/json' },