From 8f9486b28c8e43c0fd1b1940762f60753efc6a5f Mon Sep 17 00:00:00 2001 From: Kush Thaker Date: Tue, 23 Jul 2024 10:58:46 +0530 Subject: [PATCH 01/40] feat: add thread support for twitter; add segregation in types of chunks and methods to process those chunks --- apps/cf-ai-backend/src/helper.ts | 194 ++++++++++++++---- apps/cf-ai-backend/src/index.ts | 57 +++-- apps/cf-ai-backend/src/types.ts | 30 +++ .../src/utils/chunkPageOrNotes.ts | 13 ++ apps/cf-ai-backend/src/utils/chunkTweet.ts | 39 ++++ apps/cf-ai-backend/src/utils/kvBulkInsert.ts | 43 ++++ apps/web/app/actions/doers.ts | 42 +++- apps/web/cf-env.d.ts | 3 + 8 files changed, 367 insertions(+), 54 deletions(-) create mode 100644 apps/cf-ai-backend/src/utils/chunkPageOrNotes.ts create mode 100644 apps/cf-ai-backend/src/utils/chunkTweet.ts create mode 100644 apps/cf-ai-backend/src/utils/kvBulkInsert.ts diff --git a/apps/cf-ai-backend/src/helper.ts b/apps/cf-ai-backend/src/helper.ts index c54dde9f..04058653 100644 --- a/apps/cf-ai-backend/src/helper.ts +++ b/apps/cf-ai-backend/src/helper.ts @@ -1,5 +1,5 @@ import { Context } from "hono"; -import { Env, vectorObj } from "./types"; +import { Env, vectorObj, Chunks } from "./types"; import { CloudflareVectorizeStore } from "@langchain/cloudflare"; import { OpenAIEmbeddings } from "./utils/OpenAIEmbedder"; import { createOpenAI } from "@ai-sdk/openai"; @@ -7,6 +7,7 @@ import { createGoogleGenerativeAI } from "@ai-sdk/google"; import { createAnthropic } from "@ai-sdk/anthropic"; import { z } from "zod"; import { seededRandom } from "./utils/seededRandom"; +import { bulkInsertKv } from "./utils/kvBulkInsert"; export async function initQuery( c: Context<{ Bindings: Env }>, @@ -135,7 +136,7 @@ export async function batchCreateChunksAndEmbeddings({ }: { store: CloudflareVectorizeStore; body: z.infer; - chunks: string[]; + chunks: Chunks; context: Context<{ Bindings: Env }>; }) { //! NOTE that we use #supermemory-web to ensure that @@ -150,7 +151,6 @@ export async function batchCreateChunksAndEmbeddings({ const allIds = await context.env.KV.list({ prefix: uuid }); - let pageContent = ""; // If some chunks for that content already exist, we'll just update the metadata to include // the user. if (allIds.keys.length > 0) { @@ -169,51 +169,169 @@ export async function batchCreateChunksAndEmbeddings({ return acc; }, {}), }; - const content = - vector.metadata.content.toString().split("Content: ")[1] || - vector.metadata.content; - pageContent += `<---chunkId: ${vector.id}\n${content}\n---->`; return vector; }); await context.env.VECTORIZE_INDEX.upsert(newVectors); - return pageContent; //Return the page content that goes to d1 db + return; } - for (let i = 0; i < chunks.length; i++) { - const chunk = chunks[i]; - const chunkId = `${uuid}-${i}`; + switch (chunks.type) { + case "tweet": + { + const commonMetaData = { + type: body.type ?? "tweet", + title: body.title, + description: body.description ?? "", + url: body.url, + [sanitizeKey(`user-${body.user}`)]: 1, + }; + const spaceMetadata = body.spaces?.reduce((acc, space) => { + acc[`space-${body.user}-${space}`] = 1; + return acc; + }, {}); - const newPageContent = `Title: ${body.title}\nDescription: ${body.description}\nURL: ${body.url}\nContent: ${chunk}`; + const ids = []; + const preparedDocuments = chunks.chunks + .map((tweet, i) => { + return tweet.chunkedTweet.map((chunk) => { + const id = `${uuid}-${i}`; + ids.push(id); + const { tweetLinks, tweetVids, tweetId } = tweet.metadata; + return { + pageContent: chunk, + metadata: { + links: tweetLinks, + videos: tweetVids, + tweetId: tweetId, + ...commonMetaData, + ...spaceMetadata, + }, + }; + }); + }) + .flat(); - const docs = await store.addDocuments( - [ - { - pageContent: newPageContent, - metadata: { - title: body.title?.slice(0, 50) ?? "", - description: body.description ?? "", - url: body.url, - type: body.type ?? "page", - content: newPageContent, - - [sanitizeKey(`user-${body.user}`)]: 1, - ...body.spaces?.reduce((acc, space) => { - acc[`space-${body.user}-${space}`] = 1; - return acc; - }, {}), - }, - }, - ], + const docs = await store.addDocuments(preparedDocuments, { + ids: ids, + }); + console.log("these are the doucment ids", ids); + console.log("Docs added:", docs); + const { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID } = + context.env; + await bulkInsertKv( + { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID }, + { chunkIds: ids, urlid: ourID }, + ); + } + break; + case "page": { - ids: [chunkId], - }, - ); + const commonMetaData = { + type: body.type ?? "page", + title: body.title, + description: body.description ?? "", + url: body.url, + [sanitizeKey(`user-${body.user}`)]: 1, + }; + const spaceMetadata = body.spaces?.reduce((acc, space) => { + acc[`space-${body.user}-${space}`] = 1; + return acc; + }, {}); - console.log("Docs added: ", docs); + const ids = []; + const preparedDocuments = chunks.chunks.map((chunk, i) => { + const id = `${uuid}-${i}`; + ids.push(id); + return { + pageContent: chunk, + metadata: { + ...commonMetaData, + ...spaceMetadata, + }, + }; + }); - await context.env.KV.put(chunkId, ourID); - pageContent += `<---chunkId: ${chunkId}\n${chunk}\n---->`; + const docs = await store.addDocuments(preparedDocuments, { ids: ids }); + console.log("Docs added:", docs); + const { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID } = + context.env; + await bulkInsertKv( + { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID }, + { chunkIds: ids, urlid: ourID }, + ); + } + break; + case "note": + { + const commonMetaData = { + type: body.type ?? "page", + description: body.description ?? "", + url: body.url, + [sanitizeKey(`user-${body.user}`)]: 1, + }; + const spaceMetadata = body.spaces?.reduce((acc, space) => { + acc[`space-${body.user}-${space}`] = 1; + return acc; + }, {}); + + const ids = []; + const preparedDocuments = chunks.chunks.map((chunk, i) => { + const id = `${uuid}-${i}`; + ids.push(id); + return { + pageContent: chunk, + metadata: { + ...commonMetaData, + ...spaceMetadata, + }, + }; + }); + + const docs = await store.addDocuments(preparedDocuments, { ids: ids }); + console.log("Docs added:", docs); + const { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID } = + context.env; + await bulkInsertKv( + { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID }, + { chunkIds: ids, urlid: ourID }, + ); + } + break; + case "image": { + const commonMetaData = { + type: body.type ?? "image", + title: body.title, + description: body.description ?? "", + url: body.url, + [sanitizeKey(`user-${body.user}`)]: 1, + }; + const spaceMetadata = body.spaces?.reduce((acc, space) => { + acc[`space-${body.user}-${space}`] = 1; + return acc; + }, {}); + + const ids = []; + const preparedDocuments = chunks.chunks.map((chunk, i) => { + const id = `${uuid}-${i}`; + ids.push(id); + return { + pageContent: chunk, + metadata: { + ...commonMetaData, + ...spaceMetadata, + }, + }; + }); + + const docs = await store.addDocuments(preparedDocuments, { ids: ids }); + console.log("Docs added:", docs); + const { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID } = context.env; + await bulkInsertKv( + { CF_KV_AUTH_TOKEN, CF_ACCOUNT_ID, KV_NAMESPACE_ID }, + { chunkIds: ids, urlid: ourID }, + ); + } } - return pageContent; // Return the pageContent that goes to the d1 db + return; } diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 413d6d63..bf0741b6 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -1,7 +1,15 @@ import { z } from "zod"; import { Hono } from "hono"; import { CoreMessage, generateText, streamText, tool } from "ai"; -import { chatObj, Env, vectorObj } from "./types"; +import { + chatObj, + Chunks, + Env, + ImageChunks, + PageOrNoteChunks, + TweetChunks, + vectorObj, +} from "./types"; import { batchCreateChunksAndEmbeddings, deleteDocument, @@ -15,6 +23,8 @@ import { zValidator } from "@hono/zod-validator"; import chunkText from "./utils/chonker"; import { systemPrompt, template } from "./prompts/prompt1"; import { swaggerUI } from "@hono/swagger-ui"; +import { chunkThread } from "./utils/chunkTweet"; +import { chunkNote, chunkPage } from "./utils/chunkPageOrNotes"; const app = new Hono<{ Bindings: Env }>(); @@ -64,26 +74,41 @@ app.post("/api/add", zValidator("json", vectorObj), async (c) => { const { store } = await initQuery(c); console.log(body.spaces); - + let chunks: TweetChunks | PageOrNoteChunks; // remove everything in tags const newPageContent = body.pageContent?.replace(/.*?<\/raw>/g, ""); - const chunks = chunkText(newPageContent, 1536); - if (chunks.length > 20) { + switch (body.type) { + case "tweet": + chunks = chunkThread(newPageContent); + break; + + case "page": + chunks = chunkPage(newPageContent); + break; + + case "note": + chunks = chunkNote(newPageContent); + break; + } + + console.log(JSON.stringify(chunks)); + + if (chunks.chunks.length > 20) { return c.json({ status: "error", message: "We are unable to process documents this size just yet, try something smaller", }); } - const chunkedInput = await batchCreateChunksAndEmbeddings({ + await batchCreateChunksAndEmbeddings({ store, body, chunks: chunks, context: c, }); - return c.json({ status: "ok", chunkedInput }); + return c.json({ status: "ok" }); }); app.post( @@ -136,6 +161,13 @@ app.post( ); const imageDescriptions = await Promise.all(imagePromises); + const chunks: ImageChunks = { + type: "image", + chunks: [ + imageDescriptions, + ...(body.text ? chunkText(body.text, 1536) : []), + ].flat(), + }; await batchCreateChunksAndEmbeddings({ store, @@ -151,10 +183,7 @@ app.post( pageContent: imageDescriptions.join("\n"), title: "Image content from the web", }, - chunks: [ - imageDescriptions, - ...(body.text ? chunkText(body.text, 1536) : []), - ].flat(), + chunks: chunks, context: c, }); @@ -252,7 +281,7 @@ app.post( // This is a "router". this finds out if the user wants to add a document, or chat with the AI to get a response. const routerQuery = await generateText({ model: model, - system: `You are Supermemory chatbot. You can either add a document to the supermemory database, or return a chat response. Based on this query, + system: `You are Supermemory chatbot. You can either add a document to the supermemory database, or return a chat response. Based on this query, You must determine what to do. Basically if it feels like a "question", then you should intiate a chat. If it feels like a "command" or feels like something that could be forwarded to the AI, then you should add a document. You must also extract the "thing" to add and what type of thing it is.`, prompt: `Question from user: ${query}`, @@ -278,7 +307,9 @@ app.post( if ((task as string) === "add") { // addString is the plaintext string that the user wants to add to the database + //chunk the note let addString: string = addContent; + let vectorContent: Chunks = chunkNote(addContent); if (thingToAdd === "page") { // TODO: Sometimes this query hangs, and errors out. we need to do proper error management here. @@ -289,6 +320,7 @@ app.post( }); addString = await response.text(); + vectorContent = chunkPage(addString); } // At this point, we can just go ahead and create the embeddings! @@ -301,7 +333,7 @@ app.post( pageContent: addString, title: `${addString.slice(0, 30)}... (Added from chatbot)`, }, - chunks: chunkText(addString, 1536), + chunks: vectorContent, context: c, }); @@ -494,7 +526,6 @@ app.post( ); const metadata = normalizedData.map((datapoint) => datapoint.metadata); - return c.json({ ids: storedContent, metadata, normalizedData }); } } diff --git a/apps/cf-ai-backend/src/types.ts b/apps/cf-ai-backend/src/types.ts index 4db568a1..5ef81f20 100644 --- a/apps/cf-ai-backend/src/types.ts +++ b/apps/cf-ai-backend/src/types.ts @@ -1,5 +1,6 @@ import { sourcesZod } from "@repo/shared-types"; import { z } from "zod"; +import { ThreadTweetData } from "./utils/chunkTweet"; export type Env = { VECTORIZE_INDEX: VectorizeIndex; @@ -7,6 +8,9 @@ export type Env = { SECURITY_KEY: string; OPENAI_API_KEY: string; GOOGLE_AI_API_KEY: string; + CF_KV_AUTH_TOKEN: string; + KV_NAMESPACE_ID: string; + CF_ACCOUNT_ID: string; MY_QUEUE: Queue; KV: KVNamespace; MYBROWSER: unknown; @@ -23,6 +27,32 @@ export interface TweetData { saveToUser: string; } +interface BaseChunks { + type: "tweet" | "page" | "note" | "image"; +} + +export interface TweetChunks extends BaseChunks { + type: "tweet"; + chunks: Array; +} + +export interface PageOrNoteChunks extends BaseChunks { + type: "page" | "note"; + chunks: string[]; +} +export interface ImageChunks extends BaseChunks { + type: "image"; + chunks: string[]; +} + +export type Chunks = TweetChunks | PageOrNoteChunks | ImageChunks; + +export interface KVBulkItem { + key: string; + value: string; + base64: boolean; +} + export const contentObj = z.object({ role: z.string(), parts: z diff --git a/apps/cf-ai-backend/src/utils/chunkPageOrNotes.ts b/apps/cf-ai-backend/src/utils/chunkPageOrNotes.ts new file mode 100644 index 00000000..f04ed0c5 --- /dev/null +++ b/apps/cf-ai-backend/src/utils/chunkPageOrNotes.ts @@ -0,0 +1,13 @@ +import chunkText from "./chonker"; +import { PageOrNoteChunks } from "../types"; +export function chunkPage(pageContent: string): PageOrNoteChunks { + const chunks = chunkText(pageContent, 1536); + + return { type: "page", chunks: chunks }; +} + +export function chunkNote(noteContent: string): PageOrNoteChunks { + const chunks = chunkText(noteContent, 1536); + + return { type: "note", chunks: chunks }; +} diff --git a/apps/cf-ai-backend/src/utils/chunkTweet.ts b/apps/cf-ai-backend/src/utils/chunkTweet.ts new file mode 100644 index 00000000..43d82317 --- /dev/null +++ b/apps/cf-ai-backend/src/utils/chunkTweet.ts @@ -0,0 +1,39 @@ +import { TweetChunks } from "../types"; +import chunkText from "./chonker"; + +interface Tweet { + id: string; + text: string; + links: Array; + images: Array; + videos: Array; +} +interface Metadata { + tweetId: string; + tweetLinks: any[]; + tweetVids: any[]; +} + +export interface ThreadTweetData { + chunkedTweet: string[]; + metadata: Metadata; +} + + +export function chunkThread(threadText: string): TweetChunks { + const thread = JSON.parse(threadText); + + const chunkedTweets = thread.map((tweet: Tweet) => { + const chunkedTweet = chunkText(tweet.text, 1536); + + const metadata = { + tweetId: tweet.id, + tweetLinks: tweet.links, + tweetVids: tweet.videos, + }; + + return { chunkedTweet, metadata }; + }); + + return { type: "tweet", chunks: chunkedTweets }; +} diff --git a/apps/cf-ai-backend/src/utils/kvBulkInsert.ts b/apps/cf-ai-backend/src/utils/kvBulkInsert.ts new file mode 100644 index 00000000..62236412 --- /dev/null +++ b/apps/cf-ai-backend/src/utils/kvBulkInsert.ts @@ -0,0 +1,43 @@ +import { KVBulkItem } from "../types"; + +export const bulkInsertKv = async ( + credentials: { + CF_KV_AUTH_TOKEN: string; + KV_NAMESPACE_ID: string; + CF_ACCOUNT_ID: string; + }, + keyData: { + chunkIds: Array; + urlid: string; + }, +) => { + const data: Array = keyData.chunkIds.map((chunkId) => ({ + key: chunkId, + value: keyData.urlid, + base64: false, + })); + + try { + const response = await fetch( + `https://api.cloudflare.com/client/v4/accounts/${credentials.CF_ACCOUNT_ID}/storage/kv/namespaces/${credentials.KV_NAMESPACE_ID}/bulk`, + { + method: "PUT", + headers: { + Authorization: `Bearer ${credentials.CF_KV_AUTH_TOKEN}`, + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }, + ); + + if (!response.ok) { + throw new Error( + `can't insert bulk to kv because ${response.status} ${response.statusText} ${JSON.stringify(response.body)}`, + ); + } + return await response.json(); + } catch (e) { + //dosomething + throw e; + } +}; diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts index a2cdb4f5..f3677f4c 100644 --- a/apps/web/app/actions/doers.ts +++ b/apps/web/app/actions/doers.ts @@ -60,7 +60,7 @@ export const createSpace = async ( } }; -const typeDecider = (content: string) => { +const typeDecider = (content: string): "page" | "tweet" | "note" => { // if the content is a URL, then it's a page. if its a URL with https://x.com/user/status/123, then it's a tweet. else, it's a note. // do strict checking with regex if (content.match(/https?:\/\/(x\.com|twitter\.com)\/[\w]+\/[\w]+\/[\d]+/)) { @@ -171,6 +171,7 @@ export const createMemory = async (input: { let pageContent = input.content; let metadata: Awaited>; + let vectorData: string; if (!(await limit(data.user.id, type))) { return { @@ -189,7 +190,7 @@ export const createMemory = async (input: { }, }); pageContent = await response.text(); - + vectorData = pageContent; try { metadata = await getMetaData(input.content); } catch (e) { @@ -199,8 +200,42 @@ export const createMemory = async (input: { }; } } else if (type === "tweet") { + //Request the worker for the entire thread + + let thread: string; + let errorOccurred: boolean = false; + + try { + const cf_thread_endpoint = process.env.THREAD_CF_WORKER; + const authKey = process.env.THREAD_CF_AUTH; + + const threadRequest = await fetch(cf_thread_endpoint, { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: authKey, + }, + body: JSON.stringify({ url: input.content }), + }); + + if (threadRequest.status !== 200) { + throw new Error( + `Failed to fetch the thread: ${input.content}, Reason: ${threadRequest.statusText}`, + ); + } + + thread = await threadRequest.text(); + } catch (e) { + console.log("[THREAD FETCHING SERVICE] Failed to fetch the thread", e); + errorOccurred = true; + } + const tweet = await getTweetData(input.content.split("/").pop() as string); + pageContent = tweetToMd(tweet); + console.log("THis ishte page content!!", pageContent); + //@ts-ignore + vectorData = errorOccurred ? pageContent : thread; metadata = { baseUrl: input.content, description: tweet.text.slice(0, 200), @@ -209,6 +244,7 @@ export const createMemory = async (input: { }; } else if (type === "note") { pageContent = input.content; + vectorData = pageContent; noteId = new Date().getTime(); metadata = { baseUrl: `https://supermemory.ai/note/${noteId}`, @@ -235,7 +271,7 @@ export const createMemory = async (input: { { method: "POST", body: JSON.stringify({ - pageContent, + pageContent: vectorData, title: metadata.title, description: metadata.description, url: metadata.baseUrl, diff --git a/apps/web/cf-env.d.ts b/apps/web/cf-env.d.ts index 7381d63e..2c77d4fb 100644 --- a/apps/web/cf-env.d.ts +++ b/apps/web/cf-env.d.ts @@ -18,6 +18,9 @@ declare global { CLOUDFLARE_DATABASE_ID: string; CLOUDFLARE_D1_TOKEN: string; + THREAD_CF_WORKER: string; + THREAD_CF_AUTH: string; + MOBILE_TRUST_TOKEN: string; } } From dde7f21c5e07277d87b5f3b62140d5e4ba3dc0a5 Mon Sep 17 00:00:00 2001 From: Kush Thaker Date: Tue, 23 Jul 2024 19:01:35 +0530 Subject: [PATCH 02/40] feat: Improve batch processing for vector metadata updates; Support long form content --- apps/cf-ai-backend/src/helper.ts | 33 +++++++++++++++++++--- apps/cf-ai-backend/src/index.ts | 8 ------ apps/cf-ai-backend/src/utils/chunkTweet.ts | 3 +- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/apps/cf-ai-backend/src/helper.ts b/apps/cf-ai-backend/src/helper.ts index 04058653..3a15ac4d 100644 --- a/apps/cf-ai-backend/src/helper.ts +++ b/apps/cf-ai-backend/src/helper.ts @@ -155,10 +155,21 @@ export async function batchCreateChunksAndEmbeddings({ // the user. if (allIds.keys.length > 0) { const savedVectorIds = allIds.keys.map((key) => key.name); - const vectors = await context.env.VECTORIZE_INDEX.getByIds(savedVectorIds); - + const vectors = []; + //Search in a batch of 20 + for (let i = 0; i < savedVectorIds.length; i += 20) { + const batch = savedVectorIds.slice(i, i + 20); + const batchVectors = await context.env.VECTORIZE_INDEX.getByIds(batch); + vectors.push(...batchVectors); + } + console.log( + vectors.map((vector) => { + return vector.id; + }), + ); // Now, we'll update all vector metadatas with one more userId and all spaceIds const newVectors = vectors.map((vector) => { + console.log(JSON.stringify(vector.metadata)); vector.metadata = { ...vector.metadata, [`user-${body.user}`]: 1, @@ -172,7 +183,18 @@ export async function batchCreateChunksAndEmbeddings({ return vector; }); - await context.env.VECTORIZE_INDEX.upsert(newVectors); + // upsert in batch of 20 + const results = []; + for (let i = 0; i < newVectors.length; i += 20) { + results.push(newVectors.slice(i, i + 20)); + console.log(JSON.stringify(newVectors[1].id)); + } + + await Promise.all( + results.map((result) => { + return context.env.VECTORIZE_INDEX.upsert(result); + }), + ); return; } @@ -186,6 +208,7 @@ export async function batchCreateChunksAndEmbeddings({ url: body.url, [sanitizeKey(`user-${body.user}`)]: 1, }; + const spaceMetadata = body.spaces?.reduce((acc, space) => { acc[`space-${body.user}-${space}`] = 1; return acc; @@ -197,13 +220,15 @@ export async function batchCreateChunksAndEmbeddings({ return tweet.chunkedTweet.map((chunk) => { const id = `${uuid}-${i}`; ids.push(id); - const { tweetLinks, tweetVids, tweetId } = tweet.metadata; + const { tweetLinks, tweetVids, tweetId, tweetImages } = + tweet.metadata; return { pageContent: chunk, metadata: { links: tweetLinks, videos: tweetVids, tweetId: tweetId, + tweetImages: tweetImages, ...commonMetaData, ...spaceMetadata, }, diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index bf0741b6..675039fa 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -92,15 +92,7 @@ app.post("/api/add", zValidator("json", vectorObj), async (c) => { break; } - console.log(JSON.stringify(chunks)); - if (chunks.chunks.length > 20) { - return c.json({ - status: "error", - message: - "We are unable to process documents this size just yet, try something smaller", - }); - } await batchCreateChunksAndEmbeddings({ store, body, diff --git a/apps/cf-ai-backend/src/utils/chunkTweet.ts b/apps/cf-ai-backend/src/utils/chunkTweet.ts index 43d82317..224c6c05 100644 --- a/apps/cf-ai-backend/src/utils/chunkTweet.ts +++ b/apps/cf-ai-backend/src/utils/chunkTweet.ts @@ -12,6 +12,7 @@ interface Metadata { tweetId: string; tweetLinks: any[]; tweetVids: any[]; + tweetImages: any[]; } export interface ThreadTweetData { @@ -19,7 +20,6 @@ export interface ThreadTweetData { metadata: Metadata; } - export function chunkThread(threadText: string): TweetChunks { const thread = JSON.parse(threadText); @@ -30,6 +30,7 @@ export function chunkThread(threadText: string): TweetChunks { tweetId: tweet.id, tweetLinks: tweet.links, tweetVids: tweet.videos, + tweetImages: tweet.images, }; return { chunkedTweet, metadata }; From d267a8d436dbd8d7e8f9fc16522ae7c1aa2bd6a4 Mon Sep 17 00:00:00 2001 From: Kush Thaker Date: Tue, 23 Jul 2024 19:19:36 +0530 Subject: [PATCH 03/40] add try catch in api/add for better error handling --- apps/cf-ai-backend/src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 675039fa..cf6507c2 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -69,6 +69,7 @@ app.get("/api/health", (c) => { }); app.post("/api/add", zValidator("json", vectorObj), async (c) => { + try{ const body = c.req.valid("json"); const { store } = await initQuery(c); @@ -101,6 +102,10 @@ app.post("/api/add", zValidator("json", vectorObj), async (c) => { }); return c.json({ status: "ok" }); +}catch(error){ + console.error("Error processing request:", error); + return c.json({ status: "error", message: error.message }, 500); +} }); app.post( From c7b98a39b8024c96f1230a513a6d64d763b74277 Mon Sep 17 00:00:00 2001 From: codetorso Date: Thu, 25 Jul 2024 10:56:32 +0530 Subject: [PATCH 04/40] let's go boys!! canvas --- apps/web/app/(canvas)/canvas/page.tsx | 22 - .../web/app/(canvas)/canvas/search&create.tsx | 45 --- apps/web/app/(canvas)/canvas/thinkPad.tsx | 276 ------------- apps/web/app/(canvas)/canvas/thinkPads.tsx | 32 -- apps/web/app/(canvas)/layout.tsx | 30 -- apps/web/app/(dash)/menu.tsx | 10 +- .../{(canvas) => (thinkpad)}/canvasStyles.css | 2 + apps/web/app/(thinkpad)/layout.tsx | 22 + .../thinkpad}/[id]/page.tsx | 13 +- apps/web/app/(thinkpad)/thinkpad/image.tsx | 47 +++ apps/web/app/(thinkpad)/thinkpad/page.tsx | 115 ++++++ apps/web/app/actions/doers.ts | 6 +- apps/web/app/actions/fetchers.ts | 6 + apps/web/app/api/canvasai/route.ts | 43 +- apps/web/app/api/unfirlsite/route.ts | 156 -------- apps/web/components/canvas/canvas.tsx | 96 ----- .../canvas/custom_nodes/textcard.tsx | 99 +++++ .../twittercard.tsx} | 0 .../components/canvas/draggableComponent.tsx | 56 --- apps/web/components/canvas/dropComponent.tsx | 206 ---------- .../canvas/{enabledComp.tsx => enabled.tsx} | 2 +- .../components/canvas/enabledComp copy.tsx | 22 - .../web/components/canvas/resizableLayout.tsx | 177 --------- .../web/components/canvas/resizablelayout.tsx | 46 +++ apps/web/components/canvas/savesnap.tsx | 4 +- apps/web/components/canvas/sidepanel.tsx | 101 +++++ apps/web/components/canvas/sidepanelcard.tsx | 69 ++++ apps/web/components/canvas/textCard.tsx | 47 --- .../web/components/canvas/tldrawComponent.tsx | 84 ++++ apps/web/components/canvas/tldrawDrop.tsx | 67 ++++ apps/web/lib/ExternalDroppedContent.ts | 284 +++++++++++++ apps/web/lib/createEmbeds.ts | 236 ----------- apps/web/lib/loadSnap.ts | 5 +- apps/web/lib/unfirlsite.ts | 41 ++ apps/web/public/embed-icons/codepen.png | Bin 1782 -> 0 bytes apps/web/public/embed-icons/codesandbox.png | Bin 237 -> 0 bytes apps/web/public/embed-icons/desmos.png | Bin 1425 -> 0 bytes apps/web/public/embed-icons/excalidraw.png | Bin 786 -> 0 bytes apps/web/public/embed-icons/felt.png | Bin 896 -> 0 bytes apps/web/public/embed-icons/figma.png | Bin 1299 -> 0 bytes apps/web/public/embed-icons/github_gist.png | Bin 900 -> 0 bytes .../public/embed-icons/google_calendar.png | Bin 826 -> 0 bytes apps/web/public/embed-icons/google_maps.png | Bin 1726 -> 0 bytes apps/web/public/embed-icons/google_slides.png | Bin 1435 -> 0 bytes apps/web/public/embed-icons/observable.png | Bin 721 -> 0 bytes apps/web/public/embed-icons/replit.png | Bin 526 -> 0 bytes apps/web/public/embed-icons/scratch.png | Bin 3109 -> 0 bytes apps/web/public/embed-icons/spotify.png | Bin 1732 -> 0 bytes apps/web/public/embed-icons/tldraw.png | Bin 600 -> 0 bytes apps/web/public/embed-icons/val_town.png | Bin 494 -> 0 bytes apps/web/public/embed-icons/vimeo.png | Bin 864 -> 0 bytes apps/web/public/embed-icons/youtube.png | Bin 846 -> 0 bytes .../web/public/fonts/IBMPlexMono-Medium.woff2 | Bin 40396 -> 0 bytes .../web/public/fonts/IBMPlexSans-Medium.woff2 | Bin 63940 -> 0 bytes .../public/fonts/IBMPlexSerif-Medium.woff2 | Bin 59496 -> 0 bytes .../fonts/Shantell_Sans-Tldrawish.woff2 | Bin 152980 -> 0 bytes apps/web/public/icons/icon/align-bottom.svg | 1 - .../icons/icon/align-center-horizontal.svg | 1 - .../icons/icon/align-center-vertical.svg | 1 - apps/web/public/icons/icon/align-left.svg | 1 - apps/web/public/icons/icon/align-right.svg | 1 - apps/web/public/icons/icon/align-top.svg | 1 - apps/web/public/icons/icon/arrow-left.svg | 1 - .../web/public/icons/icon/arrowhead-arrow.svg | 1 - apps/web/public/icons/icon/arrowhead-bar.svg | 1 - .../public/icons/icon/arrowhead-diamond.svg | 1 - apps/web/public/icons/icon/arrowhead-dot.svg | 1 - apps/web/public/icons/icon/arrowhead-none.svg | 1 - .../public/icons/icon/arrowhead-square.svg | 1 - .../icon/arrowhead-triangle-inverted.svg | 1 - .../public/icons/icon/arrowhead-triangle.svg | 1 - apps/web/public/icons/icon/blob.svg | 1 - apps/web/public/icons/icon/bring-forward.svg | 1 - apps/web/public/icons/icon/bring-to-front.svg | 1 - apps/web/public/icons/icon/broken.svg | 1 - apps/web/public/icons/icon/check-circle.svg | 1 - apps/web/public/icons/icon/check.svg | 1 - apps/web/public/icons/icon/chevron-down.svg | 1 - apps/web/public/icons/icon/chevron-left.svg | 1 - apps/web/public/icons/icon/chevron-right.svg | 1 - apps/web/public/icons/icon/chevron-up.svg | 1 - apps/web/public/icons/icon/chevrons-ne.svg | 1 - apps/web/public/icons/icon/chevrons-sw.svg | 1 - .../public/icons/icon/clipboard-copied.svg | 1 - apps/web/public/icons/icon/clipboard-copy.svg | 1 - apps/web/public/icons/icon/color.svg | 1 - apps/web/public/icons/icon/cross-2.svg | 1 - apps/web/public/icons/icon/cross-circle.svg | 1 - apps/web/public/icons/icon/dash-dashed.svg | 1 - apps/web/public/icons/icon/dash-dotted.svg | 1 - apps/web/public/icons/icon/dash-draw.svg | 1 - apps/web/public/icons/icon/dash-solid.svg | 1 - apps/web/public/icons/icon/disconnected.svg | 1 - apps/web/public/icons/icon/discord.svg | 1 - .../icons/icon/distribute-horizontal.svg | 1 - .../public/icons/icon/distribute-vertical.svg | 1 - apps/web/public/icons/icon/dot.svg | 1 - .../web/public/icons/icon/dots-horizontal.svg | 1 - apps/web/public/icons/icon/dots-vertical.svg | 1 - .../public/icons/icon/drag-handle-dots.svg | 1 - apps/web/public/icons/icon/duplicate.svg | 1 - apps/web/public/icons/icon/edit.svg | 1 - apps/web/public/icons/icon/external-link.svg | 1 - apps/web/public/icons/icon/fill-none.svg | 1 - apps/web/public/icons/icon/fill-pattern.svg | 1 - apps/web/public/icons/icon/fill-semi.svg | 1 - apps/web/public/icons/icon/fill-solid.svg | 1 - apps/web/public/icons/icon/follow.svg | 1 - apps/web/public/icons/icon/following.svg | 1 - apps/web/public/icons/icon/font-draw.svg | 1 - apps/web/public/icons/icon/font-mono.svg | 1 - apps/web/public/icons/icon/font-sans.svg | 1 - apps/web/public/icons/icon/font-serif.svg | 1 - apps/web/public/icons/icon/geo-arrow-down.svg | 1 - apps/web/public/icons/icon/geo-arrow-left.svg | 1 - .../web/public/icons/icon/geo-arrow-right.svg | 1 - apps/web/public/icons/icon/geo-arrow-up.svg | 1 - apps/web/public/icons/icon/geo-check-box.svg | 1 - apps/web/public/icons/icon/geo-cloud.svg | 1 - apps/web/public/icons/icon/geo-diamond.svg | 1 - apps/web/public/icons/icon/geo-ellipse.svg | 1 - apps/web/public/icons/icon/geo-heart.svg | 1 - apps/web/public/icons/icon/geo-hexagon.svg | 1 - apps/web/public/icons/icon/geo-octagon.svg | 1 - apps/web/public/icons/icon/geo-oval.svg | 1 - apps/web/public/icons/icon/geo-pentagon.svg | 1 - apps/web/public/icons/icon/geo-rectangle.svg | 1 - apps/web/public/icons/icon/geo-rhombus-2.svg | 1 - apps/web/public/icons/icon/geo-rhombus.svg | 1 - apps/web/public/icons/icon/geo-star.svg | 1 - apps/web/public/icons/icon/geo-trapezoid.svg | 1 - apps/web/public/icons/icon/geo-triangle.svg | 1 - apps/web/public/icons/icon/geo-x-box.svg | 1 - apps/web/public/icons/icon/github.svg | 1 - apps/web/public/icons/icon/group.svg | 1 - .../icons/icon/horizontal-align-end.svg | 1 - .../icons/icon/horizontal-align-middle.svg | 1 - .../icons/icon/horizontal-align-start.svg | 1 - apps/web/public/icons/icon/info-circle.svg | 1 - apps/web/public/icons/icon/leading.svg | 1 - apps/web/public/icons/icon/link.svg | 1 - apps/web/public/icons/icon/lock.svg | 1 - apps/web/public/icons/icon/menu.svg | 1 - apps/web/public/icons/icon/minus.svg | 1 - apps/web/public/icons/icon/mixed.svg | 1 - apps/web/public/icons/icon/pack.svg | 1 - apps/web/public/icons/icon/plus.svg | 1 - .../icons/icon/question-mark-circle.svg | 1 - apps/web/public/icons/icon/question-mark.svg | 1 - apps/web/public/icons/icon/redo.svg | 1 - apps/web/public/icons/icon/reset-zoom.svg | 1 - apps/web/public/icons/icon/rotate-ccw.svg | 1 - apps/web/public/icons/icon/rotate-cw.svg | 1 - apps/web/public/icons/icon/send-backward.svg | 1 - apps/web/public/icons/icon/send-to-back.svg | 1 - apps/web/public/icons/icon/share-1.svg | 1 - .../public/icons/icon/size-extra-large.svg | 1 - apps/web/public/icons/icon/size-large.svg | 1 - apps/web/public/icons/icon/size-medium.svg | 1 - apps/web/public/icons/icon/size-small.svg | 1 - apps/web/public/icons/icon/spline-cubic.svg | 1 - apps/web/public/icons/icon/spline-line.svg | 1 - .../public/icons/icon/stack-horizontal.svg | 1 - apps/web/public/icons/icon/stack-vertical.svg | 1 - .../public/icons/icon/stretch-horizontal.svg | 1 - .../public/icons/icon/stretch-vertical.svg | 1 - .../public/icons/icon/text-align-center.svg | 1 - .../web/public/icons/icon/text-align-left.svg | 1 - .../public/icons/icon/text-align-right.svg | 1 - apps/web/public/icons/icon/toggle-off.svg | 1 - apps/web/public/icons/icon/toggle-on.svg | 1 - apps/web/public/icons/icon/tool-arrow.svg | 1 - apps/web/public/icons/icon/tool-eraser.svg | 1 - apps/web/public/icons/icon/tool-frame.svg | 1 - apps/web/public/icons/icon/tool-hand.svg | 1 - apps/web/public/icons/icon/tool-highlight.svg | 1 - apps/web/public/icons/icon/tool-laser.svg | 1 - apps/web/public/icons/icon/tool-line.svg | 1 - apps/web/public/icons/icon/tool-media.svg | 1 - apps/web/public/icons/icon/tool-note.svg | 1 - apps/web/public/icons/icon/tool-pencil.svg | 1 - apps/web/public/icons/icon/tool-pointer.svg | 1 - .../web/public/icons/icon/tool-screenshot.svg | 1 - apps/web/public/icons/icon/tool-text.svg | 1 - apps/web/public/icons/icon/trash.svg | 1 - apps/web/public/icons/icon/twitter.svg | 1 - apps/web/public/icons/icon/undo.svg | 1 - apps/web/public/icons/icon/ungroup.svg | 1 - apps/web/public/icons/icon/unlock.svg | 1 - .../public/icons/icon/vertical-align-end.svg | 1 - .../icons/icon/vertical-align-middle.svg | 1 - .../icons/icon/vertical-align-start.svg | 1 - .../public/icons/icon/warning-triangle.svg | 1 - apps/web/public/icons/icon/zoom-in.svg | 1 - apps/web/public/icons/icon/zoom-out.svg | 1 - apps/web/public/translations/ar.json | 295 -------------- apps/web/public/translations/ca.json | 295 -------------- apps/web/public/translations/cs.json | 352 ---------------- apps/web/public/translations/da.json | 160 -------- apps/web/public/translations/de.json | 310 --------------- apps/web/public/translations/en.json | 1 - apps/web/public/translations/es.json | 299 -------------- apps/web/public/translations/fa.json | 343 ---------------- apps/web/public/translations/fi.json | 312 --------------- apps/web/public/translations/fr.json | 372 ----------------- apps/web/public/translations/gl.json | 349 ---------------- apps/web/public/translations/he.json | 86 ---- apps/web/public/translations/hi-in.json | 290 -------------- apps/web/public/translations/hr.json | 358 ----------------- apps/web/public/translations/hu.json | 365 ----------------- apps/web/public/translations/id.json | 373 ----------------- apps/web/public/translations/it.json | 330 --------------- apps/web/public/translations/ja.json | 351 ---------------- apps/web/public/translations/ko-kr.json | 372 ----------------- apps/web/public/translations/ku.json | 93 ----- apps/web/public/translations/languages.json | 150 ------- apps/web/public/translations/main.json | 375 ------------------ apps/web/public/translations/my.json | 112 ------ apps/web/public/translations/ne.json | 295 -------------- apps/web/public/translations/no.json | 62 --- apps/web/public/translations/pl.json | 113 ------ apps/web/public/translations/pt-br.json | 333 ---------------- apps/web/public/translations/pt-pt.json | 86 ---- apps/web/public/translations/ro.json | 371 ----------------- apps/web/public/translations/ru.json | 347 ---------------- apps/web/public/translations/sl.json | 373 ----------------- apps/web/public/translations/sv.json | 96 ----- apps/web/public/translations/te.json | 112 ------ apps/web/public/translations/th.json | 295 -------------- apps/web/public/translations/tr.json | 355 ----------------- apps/web/public/translations/uk.json | 347 ---------------- apps/web/public/translations/vi.json | 295 -------------- apps/web/public/translations/zh-cn.json | 353 ----------------- apps/web/public/translations/zh-tw.json | 316 --------------- package.json | 249 ++++++------ packages/ui/icons/bottomleft.svg | 14 + packages/ui/icons/bottomright.svg | 14 + packages/ui/icons/index.ts | 8 + packages/ui/icons/topleft.svg | 14 + packages/ui/icons/topright.svg | 14 + 240 files changed, 1212 insertions(+), 12199 deletions(-) delete mode 100644 apps/web/app/(canvas)/canvas/page.tsx delete mode 100644 apps/web/app/(canvas)/canvas/search&create.tsx delete mode 100644 apps/web/app/(canvas)/canvas/thinkPad.tsx delete mode 100644 apps/web/app/(canvas)/canvas/thinkPads.tsx delete mode 100644 apps/web/app/(canvas)/layout.tsx rename apps/web/app/{(canvas) => (thinkpad)}/canvasStyles.css (95%) create mode 100644 apps/web/app/(thinkpad)/layout.tsx rename apps/web/app/{(canvas)/canvas => (thinkpad)/thinkpad}/[id]/page.tsx (55%) create mode 100644 apps/web/app/(thinkpad)/thinkpad/image.tsx create mode 100644 apps/web/app/(thinkpad)/thinkpad/page.tsx delete mode 100644 apps/web/app/api/unfirlsite/route.ts delete mode 100644 apps/web/components/canvas/canvas.tsx create mode 100644 apps/web/components/canvas/custom_nodes/textcard.tsx rename apps/web/components/canvas/{twitterCard.tsx => custom_nodes/twittercard.tsx} (100%) delete mode 100644 apps/web/components/canvas/draggableComponent.tsx delete mode 100644 apps/web/components/canvas/dropComponent.tsx rename apps/web/components/canvas/{enabledComp.tsx => enabled.tsx} (99%) delete mode 100644 apps/web/components/canvas/enabledComp copy.tsx delete mode 100644 apps/web/components/canvas/resizableLayout.tsx create mode 100644 apps/web/components/canvas/resizablelayout.tsx create mode 100644 apps/web/components/canvas/sidepanel.tsx create mode 100644 apps/web/components/canvas/sidepanelcard.tsx delete mode 100644 apps/web/components/canvas/textCard.tsx create mode 100644 apps/web/components/canvas/tldrawComponent.tsx create mode 100644 apps/web/components/canvas/tldrawDrop.tsx create mode 100644 apps/web/lib/ExternalDroppedContent.ts delete mode 100644 apps/web/lib/createEmbeds.ts create mode 100644 apps/web/lib/unfirlsite.ts delete mode 100644 apps/web/public/embed-icons/codepen.png delete mode 100644 apps/web/public/embed-icons/codesandbox.png delete mode 100644 apps/web/public/embed-icons/desmos.png delete mode 100644 apps/web/public/embed-icons/excalidraw.png delete mode 100644 apps/web/public/embed-icons/felt.png delete mode 100644 apps/web/public/embed-icons/figma.png delete mode 100644 apps/web/public/embed-icons/github_gist.png delete mode 100644 apps/web/public/embed-icons/google_calendar.png delete mode 100644 apps/web/public/embed-icons/google_maps.png delete mode 100644 apps/web/public/embed-icons/google_slides.png delete mode 100644 apps/web/public/embed-icons/observable.png delete mode 100644 apps/web/public/embed-icons/replit.png delete mode 100644 apps/web/public/embed-icons/scratch.png delete mode 100644 apps/web/public/embed-icons/spotify.png delete mode 100644 apps/web/public/embed-icons/tldraw.png delete mode 100644 apps/web/public/embed-icons/val_town.png delete mode 100644 apps/web/public/embed-icons/vimeo.png delete mode 100644 apps/web/public/embed-icons/youtube.png delete mode 100644 apps/web/public/fonts/IBMPlexMono-Medium.woff2 delete mode 100644 apps/web/public/fonts/IBMPlexSans-Medium.woff2 delete mode 100644 apps/web/public/fonts/IBMPlexSerif-Medium.woff2 delete mode 100644 apps/web/public/fonts/Shantell_Sans-Tldrawish.woff2 delete mode 100644 apps/web/public/icons/icon/align-bottom.svg delete mode 100644 apps/web/public/icons/icon/align-center-horizontal.svg delete mode 100644 apps/web/public/icons/icon/align-center-vertical.svg delete mode 100644 apps/web/public/icons/icon/align-left.svg delete mode 100644 apps/web/public/icons/icon/align-right.svg delete mode 100644 apps/web/public/icons/icon/align-top.svg delete mode 100644 apps/web/public/icons/icon/arrow-left.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-arrow.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-bar.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-diamond.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-dot.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-none.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-square.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-triangle-inverted.svg delete mode 100644 apps/web/public/icons/icon/arrowhead-triangle.svg delete mode 100644 apps/web/public/icons/icon/blob.svg delete mode 100644 apps/web/public/icons/icon/bring-forward.svg delete mode 100644 apps/web/public/icons/icon/bring-to-front.svg delete mode 100644 apps/web/public/icons/icon/broken.svg delete mode 100644 apps/web/public/icons/icon/check-circle.svg delete mode 100644 apps/web/public/icons/icon/check.svg delete mode 100644 apps/web/public/icons/icon/chevron-down.svg delete mode 100644 apps/web/public/icons/icon/chevron-left.svg delete mode 100644 apps/web/public/icons/icon/chevron-right.svg delete mode 100644 apps/web/public/icons/icon/chevron-up.svg delete mode 100644 apps/web/public/icons/icon/chevrons-ne.svg delete mode 100644 apps/web/public/icons/icon/chevrons-sw.svg delete mode 100644 apps/web/public/icons/icon/clipboard-copied.svg delete mode 100644 apps/web/public/icons/icon/clipboard-copy.svg delete mode 100644 apps/web/public/icons/icon/color.svg delete mode 100644 apps/web/public/icons/icon/cross-2.svg delete mode 100644 apps/web/public/icons/icon/cross-circle.svg delete mode 100644 apps/web/public/icons/icon/dash-dashed.svg delete mode 100644 apps/web/public/icons/icon/dash-dotted.svg delete mode 100644 apps/web/public/icons/icon/dash-draw.svg delete mode 100644 apps/web/public/icons/icon/dash-solid.svg delete mode 100644 apps/web/public/icons/icon/disconnected.svg delete mode 100644 apps/web/public/icons/icon/discord.svg delete mode 100644 apps/web/public/icons/icon/distribute-horizontal.svg delete mode 100644 apps/web/public/icons/icon/distribute-vertical.svg delete mode 100644 apps/web/public/icons/icon/dot.svg delete mode 100644 apps/web/public/icons/icon/dots-horizontal.svg delete mode 100644 apps/web/public/icons/icon/dots-vertical.svg delete mode 100644 apps/web/public/icons/icon/drag-handle-dots.svg delete mode 100644 apps/web/public/icons/icon/duplicate.svg delete mode 100644 apps/web/public/icons/icon/edit.svg delete mode 100644 apps/web/public/icons/icon/external-link.svg delete mode 100644 apps/web/public/icons/icon/fill-none.svg delete mode 100644 apps/web/public/icons/icon/fill-pattern.svg delete mode 100644 apps/web/public/icons/icon/fill-semi.svg delete mode 100644 apps/web/public/icons/icon/fill-solid.svg delete mode 100644 apps/web/public/icons/icon/follow.svg delete mode 100644 apps/web/public/icons/icon/following.svg delete mode 100644 apps/web/public/icons/icon/font-draw.svg delete mode 100644 apps/web/public/icons/icon/font-mono.svg delete mode 100644 apps/web/public/icons/icon/font-sans.svg delete mode 100644 apps/web/public/icons/icon/font-serif.svg delete mode 100644 apps/web/public/icons/icon/geo-arrow-down.svg delete mode 100644 apps/web/public/icons/icon/geo-arrow-left.svg delete mode 100644 apps/web/public/icons/icon/geo-arrow-right.svg delete mode 100644 apps/web/public/icons/icon/geo-arrow-up.svg delete mode 100644 apps/web/public/icons/icon/geo-check-box.svg delete mode 100644 apps/web/public/icons/icon/geo-cloud.svg delete mode 100644 apps/web/public/icons/icon/geo-diamond.svg delete mode 100644 apps/web/public/icons/icon/geo-ellipse.svg delete mode 100644 apps/web/public/icons/icon/geo-heart.svg delete mode 100644 apps/web/public/icons/icon/geo-hexagon.svg delete mode 100644 apps/web/public/icons/icon/geo-octagon.svg delete mode 100644 apps/web/public/icons/icon/geo-oval.svg delete mode 100644 apps/web/public/icons/icon/geo-pentagon.svg delete mode 100644 apps/web/public/icons/icon/geo-rectangle.svg delete mode 100644 apps/web/public/icons/icon/geo-rhombus-2.svg delete mode 100644 apps/web/public/icons/icon/geo-rhombus.svg delete mode 100644 apps/web/public/icons/icon/geo-star.svg delete mode 100644 apps/web/public/icons/icon/geo-trapezoid.svg delete mode 100644 apps/web/public/icons/icon/geo-triangle.svg delete mode 100644 apps/web/public/icons/icon/geo-x-box.svg delete mode 100644 apps/web/public/icons/icon/github.svg delete mode 100644 apps/web/public/icons/icon/group.svg delete mode 100644 apps/web/public/icons/icon/horizontal-align-end.svg delete mode 100644 apps/web/public/icons/icon/horizontal-align-middle.svg delete mode 100644 apps/web/public/icons/icon/horizontal-align-start.svg delete mode 100644 apps/web/public/icons/icon/info-circle.svg delete mode 100644 apps/web/public/icons/icon/leading.svg delete mode 100644 apps/web/public/icons/icon/link.svg delete mode 100644 apps/web/public/icons/icon/lock.svg delete mode 100644 apps/web/public/icons/icon/menu.svg delete mode 100644 apps/web/public/icons/icon/minus.svg delete mode 100644 apps/web/public/icons/icon/mixed.svg delete mode 100644 apps/web/public/icons/icon/pack.svg delete mode 100644 apps/web/public/icons/icon/plus.svg delete mode 100644 apps/web/public/icons/icon/question-mark-circle.svg delete mode 100644 apps/web/public/icons/icon/question-mark.svg delete mode 100644 apps/web/public/icons/icon/redo.svg delete mode 100644 apps/web/public/icons/icon/reset-zoom.svg delete mode 100644 apps/web/public/icons/icon/rotate-ccw.svg delete mode 100644 apps/web/public/icons/icon/rotate-cw.svg delete mode 100644 apps/web/public/icons/icon/send-backward.svg delete mode 100644 apps/web/public/icons/icon/send-to-back.svg delete mode 100644 apps/web/public/icons/icon/share-1.svg delete mode 100644 apps/web/public/icons/icon/size-extra-large.svg delete mode 100644 apps/web/public/icons/icon/size-large.svg delete mode 100644 apps/web/public/icons/icon/size-medium.svg delete mode 100644 apps/web/public/icons/icon/size-small.svg delete mode 100644 apps/web/public/icons/icon/spline-cubic.svg delete mode 100644 apps/web/public/icons/icon/spline-line.svg delete mode 100644 apps/web/public/icons/icon/stack-horizontal.svg delete mode 100644 apps/web/public/icons/icon/stack-vertical.svg delete mode 100644 apps/web/public/icons/icon/stretch-horizontal.svg delete mode 100644 apps/web/public/icons/icon/stretch-vertical.svg delete mode 100644 apps/web/public/icons/icon/text-align-center.svg delete mode 100644 apps/web/public/icons/icon/text-align-left.svg delete mode 100644 apps/web/public/icons/icon/text-align-right.svg delete mode 100644 apps/web/public/icons/icon/toggle-off.svg delete mode 100644 apps/web/public/icons/icon/toggle-on.svg delete mode 100644 apps/web/public/icons/icon/tool-arrow.svg delete mode 100644 apps/web/public/icons/icon/tool-eraser.svg delete mode 100644 apps/web/public/icons/icon/tool-frame.svg delete mode 100644 apps/web/public/icons/icon/tool-hand.svg delete mode 100644 apps/web/public/icons/icon/tool-highlight.svg delete mode 100644 apps/web/public/icons/icon/tool-laser.svg delete mode 100644 apps/web/public/icons/icon/tool-line.svg delete mode 100644 apps/web/public/icons/icon/tool-media.svg delete mode 100644 apps/web/public/icons/icon/tool-note.svg delete mode 100644 apps/web/public/icons/icon/tool-pencil.svg delete mode 100644 apps/web/public/icons/icon/tool-pointer.svg delete mode 100644 apps/web/public/icons/icon/tool-screenshot.svg delete mode 100644 apps/web/public/icons/icon/tool-text.svg delete mode 100644 apps/web/public/icons/icon/trash.svg delete mode 100644 apps/web/public/icons/icon/twitter.svg delete mode 100644 apps/web/public/icons/icon/undo.svg delete mode 100644 apps/web/public/icons/icon/ungroup.svg delete mode 100644 apps/web/public/icons/icon/unlock.svg delete mode 100644 apps/web/public/icons/icon/vertical-align-end.svg delete mode 100644 apps/web/public/icons/icon/vertical-align-middle.svg delete mode 100644 apps/web/public/icons/icon/vertical-align-start.svg delete mode 100644 apps/web/public/icons/icon/warning-triangle.svg delete mode 100644 apps/web/public/icons/icon/zoom-in.svg delete mode 100644 apps/web/public/icons/icon/zoom-out.svg delete mode 100644 apps/web/public/translations/ar.json delete mode 100644 apps/web/public/translations/ca.json delete mode 100644 apps/web/public/translations/cs.json delete mode 100644 apps/web/public/translations/da.json delete mode 100644 apps/web/public/translations/de.json delete mode 100644 apps/web/public/translations/en.json delete mode 100644 apps/web/public/translations/es.json delete mode 100644 apps/web/public/translations/fa.json delete mode 100644 apps/web/public/translations/fi.json delete mode 100644 apps/web/public/translations/fr.json delete mode 100644 apps/web/public/translations/gl.json delete mode 100644 apps/web/public/translations/he.json delete mode 100644 apps/web/public/translations/hi-in.json delete mode 100644 apps/web/public/translations/hr.json delete mode 100644 apps/web/public/translations/hu.json delete mode 100644 apps/web/public/translations/id.json delete mode 100644 apps/web/public/translations/it.json delete mode 100644 apps/web/public/translations/ja.json delete mode 100644 apps/web/public/translations/ko-kr.json delete mode 100644 apps/web/public/translations/ku.json delete mode 100644 apps/web/public/translations/languages.json delete mode 100644 apps/web/public/translations/main.json delete mode 100644 apps/web/public/translations/my.json delete mode 100644 apps/web/public/translations/ne.json delete mode 100644 apps/web/public/translations/no.json delete mode 100644 apps/web/public/translations/pl.json delete mode 100644 apps/web/public/translations/pt-br.json delete mode 100644 apps/web/public/translations/pt-pt.json delete mode 100644 apps/web/public/translations/ro.json delete mode 100644 apps/web/public/translations/ru.json delete mode 100644 apps/web/public/translations/sl.json delete mode 100644 apps/web/public/translations/sv.json delete mode 100644 apps/web/public/translations/te.json delete mode 100644 apps/web/public/translations/th.json delete mode 100644 apps/web/public/translations/tr.json delete mode 100644 apps/web/public/translations/uk.json delete mode 100644 apps/web/public/translations/vi.json delete mode 100644 apps/web/public/translations/zh-cn.json delete mode 100644 apps/web/public/translations/zh-tw.json create mode 100644 packages/ui/icons/bottomleft.svg create mode 100644 packages/ui/icons/bottomright.svg create mode 100644 packages/ui/icons/topleft.svg create mode 100644 packages/ui/icons/topright.svg diff --git a/apps/web/app/(canvas)/canvas/page.tsx b/apps/web/app/(canvas)/canvas/page.tsx deleted file mode 100644 index 0bf30d89..00000000 --- a/apps/web/app/(canvas)/canvas/page.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from "react"; -import { getCanvas } from "@/app/actions/fetchers"; -import SearchandCreate from "./search&create"; -import ThinkPads from "./thinkPads"; - -async function page() { - const canvas = await getCanvas(); - return ( -
-
-

Your thinkpads

- - { - // @ts-ignore - canvas.success && - } -
-
- ); -} - -export default page; diff --git a/apps/web/app/(canvas)/canvas/search&create.tsx b/apps/web/app/(canvas)/canvas/search&create.tsx deleted file mode 100644 index ad64729e..00000000 --- a/apps/web/app/(canvas)/canvas/search&create.tsx +++ /dev/null @@ -1,45 +0,0 @@ -"use client"; - -import { useFormStatus } from "react-dom"; -import Image from "next/image"; -import { SearchIcon } from "@repo/ui/icons"; -import { createCanvas } from "@/app/actions/doers"; -import { toast } from "sonner"; - -export default function SearchandCreate() { - return ( -
-
- - -
- -
{ - const res = await createCanvas(); - if (!res.success) { - toast.warning(res.message, { - style: { backgroundColor: "rgb(22 31 42 / 0.3)" }, - }); - } - }} - > -
- ); -} - -function Button() { - const { pending } = useFormStatus(); - return ( - - ); -} diff --git a/apps/web/app/(canvas)/canvas/thinkPad.tsx b/apps/web/app/(canvas)/canvas/thinkPad.tsx deleted file mode 100644 index 4d31107d..00000000 --- a/apps/web/app/(canvas)/canvas/thinkPad.tsx +++ /dev/null @@ -1,276 +0,0 @@ -import { getCanvasData } from "@/app/actions/fetchers"; -import { AnimatePresence, motion } from "framer-motion"; -import Link from "next/link"; -import { - EllipsisHorizontalCircleIcon, - TrashIcon, - PencilSquareIcon, -} from "@heroicons/react/24/outline"; -import { toast } from "sonner"; -import { Label } from "@repo/ui/shadcn/label"; - -const childVariants = { - hidden: { opacity: 0, y: 10, filter: "blur(2px)" }, - visible: { opacity: 1, y: 0, filter: "blur(0px)" }, -}; - -export default function ThinkPad({ - title, - description, - image, - id, -}: { - title: string; - description: string; - image: string; - id: string; -}) { - const [deleted, setDeleted] = useState(false); - const [info, setInfo] = useState({ title, description }); - return ( - - {!deleted && ( - - - - Loading... - - } - > - - - -
- - {info.title} - - - {info.description} - -
- setDeleted(true)} - setInfo={(e) => setInfo(e)} - /> - - )} - - ); -} - -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@repo/ui/shadcn/popover"; - -function Menu({ - info, - id, - setDeleted, - setInfo, -}: { - info: { title: string; description: string }; - id: string; - setDeleted: () => void; - setInfo: ({ - title, - description, - }: { - title: string; - description: string; - }) => void; -}) { - return ( - - - - - - - - - - ); -} - -function EditToolbar({ - id, - setInfo, - info, -}: { - id: string; - setInfo: ({ - title, - description, - }: { - title: string; - description: string; - }) => void; - info: { - title: string; - description: string; - }; -}) { - const [open, setOpen] = useState(false); - return ( - - - - - -
{ - const data = { - title: FormData.get("title") as string, - description: FormData.get("description") as string, - }; - const res = await AddCanvasInfo({ id, ...data }); - if (res.success) { - setOpen(false); - setInfo(data); - } else { - setOpen(false); - toast.error("Something went wrong.", { - style: { backgroundColor: "rgb(22 31 42 / 0.3)" }, - }); - } - }} - > - - Edit Canvas - - Add Description to your canvas. Pro tip: Let AI do the job, as you - add your content into canvas, we will autogenerate your - description. - - -
-
- - -
-
- -