Skip to content

Commit

Permalink
made pageToMemory work
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhravya committed Apr 14, 2024
1 parent 4390325 commit d70c088
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/web/src/actions/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,36 @@ export async function addMemory(

const data = await resp.text();

console.log(data);

content.content = data;
}

if (!content.content || content.content == "") {
return null;
}

console.log({ ...content, user: user.email });

// Add to vectorDB
const res = (await Promise.race([
fetch("https://cf-ai-backend.dhravya.workers.dev/add", {
method: "POST",
headers: {
"X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY,
},
body: JSON.stringify({ ...content, user: user.email }),
body: JSON.stringify({
pageContent: content.content,
url: content.url,
spaces,
user: user.email,
}),
}),
new Promise((_, reject) =>
setTimeout(() => reject(new Error("Request timed out")), 40000),
),
])) as Response;

if (res.status !== 200) {
console.log(res.status, res.statusText);
return null;
}

const [addedMemory] = await db
.insert(storedContent)
.values({
Expand Down

0 comments on commit d70c088

Please sign in to comment.