chore: cleanup context window ui, adjust for reasoning + added db migration
This commit is contained in:
parent
431eb919b5
commit
02dde68ea3
13 changed files with 875 additions and 144 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
saveChat,
|
||||
saveMessages,
|
||||
} from '@/lib/db/queries';
|
||||
import { updateChatLastContextById } from '@/lib/db/queries';
|
||||
import { convertToUIMessages, generateUUID } from '@/lib/utils';
|
||||
import { generateTitleFromUserMessage } from '../../actions';
|
||||
import { createDocument } from '@/lib/ai/tools/create-document';
|
||||
|
|
@ -208,6 +209,17 @@ export async function POST(request: Request) {
|
|||
chatId: id,
|
||||
})),
|
||||
});
|
||||
|
||||
if (finalUsage) {
|
||||
try {
|
||||
await updateChatLastContextById({
|
||||
chatId: id,
|
||||
context: finalUsage,
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn('Unable to persist last usage for chat', id, err);
|
||||
}
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
return 'Oops, an error occurred!';
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { getChatById, getMessagesByChatId } from '@/lib/db/queries';
|
|||
import { DataStreamHandler } from '@/components/data-stream-handler';
|
||||
import { DEFAULT_CHAT_MODEL } from '@/lib/ai/models';
|
||||
import { convertToUIMessages } from '@/lib/utils';
|
||||
import { LanguageModelV2Usage } from '@ai-sdk/provider';
|
||||
|
||||
export default async function Page(props: { params: Promise<{ id: string }> }) {
|
||||
const params = await props.params;
|
||||
|
|
@ -53,6 +54,7 @@ export default async function Page(props: { params: Promise<{ id: string }> }) {
|
|||
isReadonly={session?.user?.id !== chat.userId}
|
||||
session={session}
|
||||
autoResume={true}
|
||||
initialLastContext={chat.lastContext}
|
||||
/>
|
||||
<DataStreamHandler />
|
||||
</>
|
||||
|
|
@ -69,6 +71,7 @@ export default async function Page(props: { params: Promise<{ id: string }> }) {
|
|||
isReadonly={session?.user?.id !== chat.userId}
|
||||
session={session}
|
||||
autoResume={true}
|
||||
initialLastContext={chat.lastContext}
|
||||
/>
|
||||
<DataStreamHandler />
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue