60 const { ValTown } = await import("npm:@valtown/sdk");
61 const vt = new ValTown();
62 const { email: authorEmail, profileImageUrl, username } = await vt.me.profile.retrieve();
63 // const authorEmail = me.email;
64
128
129 c.set("email", email);
130 c.set("profile", { profileImageUrl, username });
131 await next();
132};
437 {profile && (
438 <div className="flex items-center space-x-4">
439 <img src={profile.profileImageUrl} alt="Profile" className="w-8 h-8 rounded-full" />
440 <span>{profile.username}</span>
441 <a href="/auth/logout" className="text-blue-400 hover:text-blue-300">Logout</a>
580 alt="Blob content"
581 className="max-w-full h-auto"
582 onError={() => console.error("Error loading image")}
583 />
584 </div>
630 <li>Create public shareable links for blobs</li>
631 <li>View and manage public folder</li>
632 <li>Preview images directly in the interface</li>
633 </ul>
634 </div>
9 let response;
10 try {
11 response = await blob.get("pondiverse_image" + id);
12 } catch (e) {
13 return new Response(null, { status: 404 });
9 // - data (string)
10 // - type (string)
11 // - image (data url string)
12 // sanity checks:
13 // - title, not toooo long
14 // - data, hmm this needs to be long i guess.. maybe some crazy upper limit sanity check though
15 // - type, not too long
16 // - image, not toooo large a file size
17 let body;
18 try {
25 const data = body.data;
26 const type = body.type;
27 const image = body.image;
28
29 // Sanity checks
37 }
38
39 if (image && image.length > 20 * 1024 * 1024) {
40 return Response.json({ ok: false, error: "Thumbnail too large" });
41 }
57 );
58
59 // only creates blob if there is indeed an image and updates the image column to represent that
60 if (image) {
61 const imageName = "pondiverse_image" + id.lastInsertRowid;
62 const imageAddr = `${Deno.env.get("PONDIVERSE_STORE_BASE_PATH")}/get-creation-image?id=${id.lastInsertRowid}`;
63 await blob.set(imageName, image);
64 await sqlite.execute(
65 `UPDATE ${TABLE_NAME} SET image = "${imageAddr}" WHERE id = ${id.lastInsertRowid}`,
66 );
67 }
68
69 return Response.json({ ok: true, image: image });
70}
21 data TEXT,
22 type TEXT,
23 image TEXT,
24 time DATETIME NOT NULL
25 )`,
20 }
21
22 const { messages, project, branchId, anthropicApiKey, selectedFiles, images } = await c.req.json();
23 // console.log("Original messages:", JSON.stringify(messages, null, 2));
24 // console.log("Images received:", JSON.stringify(images, null, 2));
25
26 const apiKey = anthropicApiKey || Deno.env.get("ANTHROPIC_API_KEY");
39 let coreMessages = convertToCoreMessages(messages);
40
41 // If there are images, we need to add them to the last user message
42 if (images && Array.isArray(images) && images.length > 0) {
43 // Find the last user message
44 const lastUserMessageIndex = coreMessages.findIndex(
62 };
63
64 // Add each image to the content array using the correct ImagePart format
65 for (const image of images) {
66 if (image && image.url) {
67 // Extract mime type from data URL if available
68 let mimeType = undefined;
69 if (image.url.startsWith("data:")) {
70 const matches = image.url.match(/^data:([^;]+);/);
71 if (matches && matches.length > 1) {
72 mimeType = matches[1];
75
76 newUserMessage.content.push({
77 type: "image",
78 image: image.url,
79 mimeType,
80 });
163 branch_id: branchId,
164 val_id: project.id,
165 num_images: images?.length || 0,
166 model,
167 finish_reason: result.finishReason,
74 SUM(cache_write_tokens) as total_cache_write_tokens,
75 SUM(price) as total_price,
76 SUM(num_images) as total_images
77 FROM ${USAGE_TABLE}
78 WHERE our_api_token = 1
207 <th>Cache Write</th>
208 <th>Total Price</th>
209 <th>Images</th>
210 </tr>
211 </thead>
222 <td>${formatNumber(row.total_cache_write_tokens)}</td>
223 <td class="price">${formatPrice(row.total_price)}</td>
224 <td>${formatNumber(row.total_images)}</td>
225 </tr>
226 `).join("")
255 <th>Price</th>
256 <th>Finish</th>
257 <th>Images</th>
258 <th>Our API</th>
259 </tr>
275 <td class="price">${formatPrice(row.price)}</td>
276 <td>${row.finish_reason}</td>
277 <td>${formatNumber(row.num_images)}</td>
278 <td>${formatBoolean(row.our_api_token)}</td>
279 </tr>
16 price: number;
17 finish_reason: string;
18 num_images: number;
19 our_api_token: boolean;
20}
36 price REAL,
37 finish_reason TEXT,
38 num_images INTEGER,
39 our_api_token INTEGER NOT NULL
40 )
54 model,
55 finish_reason,
56 num_images,
57 our_api_token,
58}: {
66 model: string;
67 finish_reason: string;
68 num_images: number;
69 our_api_token: boolean;
70}) {
90 price,
91 finish_reason,
92 num_images,
93 our_api_token
94 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
107 price,
108 finish_reason,
109 num_images,
110 our_api_token ? 1 : 0,
111 ],
1export default async function(req: Request): Promise<Response> {
2 return Response.json({
3 image_url: "https://jon.bo/IMG_9387.png",
4 video_url: "https://brainrot.i12bp8.xyz/videos/reddit_video_54000.mp4",
5 audio_url: "https://res.cloudinary.com/dzkwltgyd/video/upload/v1746471301/glif-app/s43eeo9zs7ecxloj6mcr.webm",