esyeng / pai_dashboard

Front end for personalized LLM agent dashboard
https://jasmyn.app
1 stars 0 forks source link

PLS HELP #2

Open esyeng opened 2 days ago

esyeng commented 2 days ago

!duplicated thread naming function in contexts/ChatContext.tsx!

src/contexts/ChatContext.tsx, line 450

`const createNewThread = async () => { const newThreadId = _createID(); const threadsArray = Object.values(threads); // await threads console.log('threads length', threadsArray.length); setCurrentThreadId(threadsArray.length + 1); localStorage.setItem("lastThreadId", (threadsArray.length + 1).toString());

    setThreads((prev: Threads) => ({
        ...prev,
        [newThreadId]: {
            id: threadsArray.length + 1,
            title: newThreadId,
            createdAt: formatDate(new Date()),
            messages: [] as unknown[],
        },
    }));
    setActiveMessageQueue([]);
    // console.log("user", user);
    if (user) {
        console.log("now saving new thread");
        return await saveNewThread(
            threadsArray.length + 1,
            newThreadId,
            user.user.id,
            []
        );
    }
};`

### In src/lib/api.ts line 216

`export const saveNewThread = async (
thread_id: number | string,
title: string,
userId: string,
messages: string[]

) => { const client = createClerkSupabaseClient(); console.log("saving new thread", thread_id, title, userId, messages); try { const { data, error } = await client.from("threads").insert([ { title: title, thread_id: thread_id, user_id: userId, messages: messages, }, ]); if (error) { throw new Error("Failed to create thread"); } return data; } catch (error) { console.error("Error creating thread:", error); return error; } };`

esyeng commented 2 days ago

Ok update I tried a new ting: https://github.com/esyeng/pai_dashboard/commit/d7d06105bc61a3be0e7bafa7bc04ce4a33d8c8e2