mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-07 08:26:15 +00:00
fix: stuff
This commit is contained in:
parent
626ca898e4
commit
e30e9f4e0b
6 changed files with 7727 additions and 15754 deletions
|
|
@ -163,6 +163,7 @@ export async function batchCreateChunksAndEmbeddings({
|
|||
vectors.push(...batchVectors);
|
||||
}
|
||||
console.log(
|
||||
"vector Id list: ",
|
||||
vectors.map((vector) => {
|
||||
return vector.id;
|
||||
}),
|
||||
|
|
@ -187,7 +188,7 @@ export async function batchCreateChunksAndEmbeddings({
|
|||
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));
|
||||
console.log(newVectors);
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ app.post("/api/add", zValidator("json", vectorObj), async (c) => {
|
|||
break;
|
||||
}
|
||||
|
||||
console.log("Chunks are here:", chunks);
|
||||
|
||||
await batchCreateChunksAndEmbeddings({
|
||||
store,
|
||||
body,
|
||||
|
|
|
|||
|
|
@ -22,10 +22,18 @@ export interface ThreadTweetData {
|
|||
}
|
||||
|
||||
export function chunkThread(threadText: string): TweetChunks {
|
||||
const thread = JSON.parse(threadText);
|
||||
if (typeof thread == "string") {
|
||||
console.log("DA WORKER FAILED DO SOMEHTING FIX DA WROKER");
|
||||
let thread = threadText;
|
||||
|
||||
try {
|
||||
thread = JSON.parse(threadText);
|
||||
} catch (e) {
|
||||
console.log("error: thread is not json.", e);
|
||||
}
|
||||
|
||||
if (typeof threadText == "string") {
|
||||
console.log("DA WORKER FAILED DO SOMEHTING FIX DA WROKER", thread);
|
||||
const rawTweet = getRawTweet(thread);
|
||||
console.log(rawTweet);
|
||||
const parsedTweet: any = JSON.parse(rawTweet);
|
||||
|
||||
const chunkedTweet = chunkText(parsedTweet.text, 1536);
|
||||
|
|
@ -46,8 +54,8 @@ export function chunkThread(threadText: string): TweetChunks {
|
|||
|
||||
return { type: "tweet", chunks };
|
||||
} else {
|
||||
console.log(JSON.stringify(thread));
|
||||
const chunkedTweets = thread.map((tweet: Tweet) => {
|
||||
console.log("thread in else statement", JSON.stringify(thread));
|
||||
const chunkedTweets = (thread as any).map((tweet: Tweet) => {
|
||||
const chunkedTweet = chunkText(tweet.text, 1536);
|
||||
|
||||
const metadata = {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { type NextRequest } from "next/server";
|
|||
import { addFromAPIType } from "@repo/shared-types";
|
||||
import { ensureAuth } from "../ensureAuth";
|
||||
import { createMemoryFromAPI } from "./helper";
|
||||
import { getRawTweet } from "@repo/shared-types/utils";
|
||||
|
||||
export const runtime = "edge";
|
||||
|
||||
|
|
@ -22,14 +23,36 @@ export async function POST(req: NextRequest) {
|
|||
body = await req.json();
|
||||
} catch (e) {
|
||||
const error = (e as Error).message;
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: "A JSON was not sent to the API. " + error,
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
},
|
||||
);
|
||||
|
||||
console.log(error);
|
||||
|
||||
const tryJson = getRawTweet(await req.text());
|
||||
console.log(tryJson);
|
||||
|
||||
if (tryJson) {
|
||||
try {
|
||||
body = JSON.parse(tryJson);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: "Raw found but not json?" + error,
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
message: "Raw not found & not json." + error,
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const validated = addFromAPIType.safeParse(body);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
"@radix-ui/react-popover": "^1.0.7",
|
||||
"@radix-ui/react-slot": "^1.1.0",
|
||||
"@sentry/nextjs": "^8",
|
||||
"ai": "^3.3.0",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.0.0",
|
||||
"drizzle-orm": "0.30.0",
|
||||
|
|
|
|||
23418
pnpm-lock.yaml
generated
23418
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue