Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
36bca22
EXU chat: UI polish, logo, centering, glow; env files ignored
EXUCOMICS Oct 20, 2025
1f943ff
Fixed vector store logic and redeploying to Vercel
EXUCOMICS Oct 20, 2025
e30a68f
Remove WeatherWidget usage from function-calling example
EXUCOMICS Oct 20, 2025
6a3d42f
Fix package.json JSON; lock Node 20.x; correct scripts
EXUCOMICS Oct 20, 2025
99f534c
Upgrade Next.js to 14.2.33 to address security advisories
EXUCOMICS Oct 20, 2025
0baffc1
preview: branch to get Vercel Subdomain
EXUCOMICS Oct 22, 2025
2fed4a7
secure embed: origin allowlist plus header auth plus UI fixes
EXUCOMICS Oct 23, 2025
95db7e6
fix remove duplicate helper and clean vector store code
EXUCOMICS Oct 23, 2025
322d517
security fix allowed origins
EXUCOMICS Oct 23, 2025
32771f8
allow embedding clear xframe options
EXUCOMICS Oct 23, 2025
339b826
enable iframe embed for weebly
EXUCOMICS Oct 23, 2025
642f835
fix headers correct source pattern and csp for weebly embed
EXUCOMICS Oct 23, 2025
c05556c
fix headers use /path* and csp frame ancestors for weebly
EXUCOMICS Oct 23, 2025
defb817
allow weebly to frame via csp; add sandboxx.weebly.com to CORS allow …
EXUCOMICS Oct 23, 2025
0d9baa5
allow ifram embed for exucomics weebly
EXUCOMICS Oct 23, 2025
55a8b2f
width changes updated 5;52
EXUCOMICS Oct 23, 2025
9c52a77
font size and width change
EXUCOMICS Oct 23, 2025
13a7e4b
new font change and width
EXUCOMICS Oct 23, 2025
d6814ec
UPDATED6:22
EXUCOMICS Oct 23, 2025
9f2a56b
REDOWIDTH
EXUCOMICS Oct 23, 2025
2770721
NEWESTUPDATE
EXUCOMICS Oct 23, 2025
6e1a66f
NEWCHANGEUPDATE3
EXUCOMICS Oct 23, 2025
a6d8f6a
UIFIXES center input fixes
EXUCOMICS Oct 30, 2025
7eb573c
new UI fixesss
EXUCOMICS Oct 30, 2025
749abc1
NEWURLS
EXUCOMICS Oct 30, 2025
98b58e2
Same originsWEelbs
EXUCOMICS Oct 30, 2025
dab027b
FINALTEST
EXUCOMICS Oct 30, 2025
a340e51
URLDEPLOPROBLEM
EXUCOMICS Oct 30, 2025
597e41d
chore widen csp frame-ancestors for weebly
EXUCOMICS Oct 30, 2025
79e0084
changing assistant box sizes
EXUCOMICS Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ yarn-error.log*
# local env files
.env*.local
.env

.env.local
# vercel
.vercel

Expand Down
41 changes: 26 additions & 15 deletions app/api/assistants/files/route.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import { assistantId } from "@/app/assistant-config";
import { openai } from "@/app/openai";


// upload file to assistant's vector store
export async function POST(request) {
const formData = await request.formData(); // process file as FormData
const file = formData.get("file"); // retrieve the single file from FormData
const vectorStoreId = await getOrCreateVectorStore(); // get or create vector store
export async function POST(request: Request) {
const formData = await request.formData(); // process file as FormData
const file = formData.get("file") as File; // the single uploaded file

const vectorStoreId = await getOrCreateVectorStore(); // get/create VS

// upload using the file stream
// 1) upload the file to OpenAI Files
const openaiFile = await openai.files.create({
file: file,
file,
purpose: "assistants",
});

// add file to vector store
// 2) attach it to the vector store
await openai.beta.vectorStores.files.create(vectorStoreId, {
file_id: openaiFile.id,
});

return new Response();
}


// list files in assistant's vector store
export async function GET() {
const vectorStoreId = await getOrCreateVectorStore(); // get or create vector store
const vectorStoreId = await getOrCreateVectorStore();

const fileList = await openai.beta.vectorStores.files.list(vectorStoreId);

const filesArray = await Promise.all(
Expand All @@ -39,39 +44,45 @@ export async function GET() {
};
})
);

return Response.json(filesArray);
}


// delete file from assistant's vector store
export async function DELETE(request) {
export async function DELETE(request: Request) {
const body = await request.json();
const fileId = body.fileId;
const fileId = body.fileId as string;

const vectorStoreId = await getOrCreateVectorStore(); // get or create vector store
await openai.beta.vectorStores.files.del(vectorStoreId, fileId); // delete file from vector store
const vectorStoreId = await getOrCreateVectorStore();
await openai.beta.vectorStores.files.del(vectorStoreId, fileId);

return new Response();
}

/* Helper functions */


/* Helper functions */
const getOrCreateVectorStore = async () => {
const assistant = await openai.beta.assistants.retrieve(assistantId);

// if the assistant already has a vector store, return it
// If the assistant already has a vector store, return it
if (assistant.tool_resources?.file_search?.vector_store_ids?.length > 0) {
return assistant.tool_resources.file_search.vector_store_ids[0];
}
// otherwise, create a new vector store and attatch it to the assistant

// Otherwise, create a new vector store and attach it to the assistant
const vectorStore = await openai.beta.vectorStores.create({
name: "sample-assistant-vector-store",
});

await openai.beta.assistants.update(assistantId, {
tool_resources: {
file_search: {
vector_store_ids: [vectorStore.id],
},
},
});

return vectorStore.id;
};
2 changes: 1 addition & 1 deletion app/assistant-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export let assistantId = ""; // set your assistant ID here
export let assistantId = ""; // asst_dLiaMuKISxoNoeUD7FWSAY7v

if (assistantId === "") {
assistantId = process.env.OPENAI_ASSISTANT_ID;
Expand Down
Loading