Skip to content

Commit

Permalink
Merge branch 'main' into jrmy/improve-performance
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyphilemon committed Dec 3, 2024
2 parents 2db12cf + a13368c commit dd9fb88
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AUTH_SECRET=****
# The following keys below are automatically created and
# added to your environment when you deploy on vercel

# Instructions to create kv database here: https://vercel.com/docs/storage/vercel-blob
# Instructions to create a Vercel Blob Store here: https://vercel.com/docs/storage/vercel-blob
BLOB_READ_WRITE_TOKEN=****

# Instructions to create a database here: https://vercel.com/docs/storage/vercel-postgres/quickstart
Expand Down
12 changes: 6 additions & 6 deletions app/(chat)/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function POST(request: Request) {

const streamingData = new StreamData();

const result = await streamText({
const result = streamText({
model: customModel(model.apiIdentifier),
system: systemPrompt,
messages: coreMessages,
Expand Down Expand Up @@ -135,7 +135,7 @@ export async function POST(request: Request) {
content: '',
});

const { fullStream } = await streamText({
const { fullStream } = streamText({
model: customModel(model.apiIdentifier),
system:
'Write about the given topic. Markdown is supported. Use headings wherever appropriate.',
Expand Down Expand Up @@ -199,7 +199,7 @@ export async function POST(request: Request) {
content: document.title,
});

const { fullStream } = await streamText({
const { fullStream } = streamText({
model: customModel(model.apiIdentifier),
system:
'You are a helpful writing assistant. Based on the description, please update the piece of writing.',
Expand Down Expand Up @@ -272,7 +272,7 @@ export async function POST(request: Request) {
Omit<Suggestion, 'userId' | 'createdAt' | 'documentCreatedAt'>
> = [];

const { elementStream } = await streamObject({
const { elementStream } = streamObject({
model: customModel(model.apiIdentifier),
system:
'You are a help writing assistant. Given a piece of writing, please offer suggestions to improve the piece of writing and describe the change. It is very important for the edits to contain full sentences instead of just words. Max 5 suggestions.',
Expand Down Expand Up @@ -326,11 +326,11 @@ export async function POST(request: Request) {
},
},
},
onFinish: async ({ responseMessages }) => {
onFinish: async ({ response }) => {
if (session.user?.id) {
try {
const responseMessagesWithoutIncompleteToolCalls =
sanitizeResponseMessages(responseMessages);
sanitizeResponseMessages(response.messages);

await saveMessages({
messages: responseMessagesWithoutIncompleteToolCalls.map(
Expand Down
4 changes: 2 additions & 2 deletions app/(chat)/chat/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cookies } from 'next/headers';
import { notFound } from 'next/navigation';

import { auth } from '@/app/(auth)/auth';
import { Chat as PreviewChat } from '@/components/chat';
import { Chat } from '@/components/chat';
import { DEFAULT_MODEL_NAME, models } from '@/lib/ai/models';
import { getChatById, getMessagesByChatId } from '@/lib/db/queries';
import { convertToUIMessages } from '@/lib/utils';
Expand Down Expand Up @@ -37,7 +37,7 @@ export default async function Page(props: { params: Promise<{ id: string }> }) {
DEFAULT_MODEL_NAME;

return (
<PreviewChat
<Chat
id={chat.id}
initialMessages={convertToUIMessages(messagesFromDb)}
selectedModelId={selectedModelId}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scan": "next dev & npx react-scan@latest localhost:3000"
},
"dependencies": {
"@ai-sdk/openai": "1.0.0-canary.3",
"@ai-sdk/openai": "1.0.6",
"@radix-ui/react-alert-dialog": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.1",
Expand All @@ -33,7 +33,7 @@
"@vercel/analytics": "^1.3.1",
"@vercel/blob": "^0.24.1",
"@vercel/postgres": "^0.10.0",
"ai": "4.0.0-canary.9",
"ai": "4.0.10",
"bcrypt-ts": "^5.0.2",
"class-variance-authority": "^0.7.0",
"classnames": "^2.5.1",
Expand Down
Loading

0 comments on commit dd9fb88

Please sign in to comment.