Skip to content

Commit

Permalink
fix(Root): fix ai sdk by updating it to version 4
Browse files Browse the repository at this point in the history
  • Loading branch information
dartilesm committed Nov 23, 2024
1 parent 8974fd8 commit 6d35184
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions apps/chat-with-pdf/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ export async function POST(req: Request) {
const data = new StreamData();
data.append(messageData);

const result = await streamText({
const result = streamText({
model: google("gemini-1.5-flash-latest"),
messages: convertToCoreMessages(messages),
system: systemInstructions,
maxTokens: 3000,
onFinish({ text, toolCalls, toolResults, usage, finishReason }) {
onFinish({ text, toolCalls, toolResults, usage, finishReason, ...rest }) {
console.log({
onFinish: {
text,
toolCalls,
toolResults,
usage,
finishReason,
...rest,
},
});
data.close();
Expand Down
1 change: 0 additions & 1 deletion apps/chat-with-pdf/lib/supabase/queries/get-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export async function getChat(id: string) {
},
)(supabase);

console.log({ chat, id });
if (!chat?.suggestedQuestions) {
const suggestedQuestions = await generateAndUpdateSuggestedQuestions(
supabase,
Expand Down
8 changes: 4 additions & 4 deletions apps/chat-with-pdf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"lint": "next lint"
},
"dependencies": {
"@ai-sdk/anthropic": "0.0.50",
"@ai-sdk/anthropic": "1.0.0",
"@ai-sdk/google": "1.0.0",
"@ai-sdk/openai": "1.0.0",
"ai": "4.0.0",
"@makefy/ui": "workspace:*",
"@makefy/supabase": "workspace:*",
"@react-email/components": "0.0.25",
Expand Down Expand Up @@ -38,8 +41,6 @@
"usehooks-ts": "3.1.0"
},
"devDependencies": {
"@ai-sdk/google": "0.0.48",
"@ai-sdk/openai": "0.0.13",
"@google/generative-ai": "0.14.1",
"@langchain/community": "0.2.16",
"@langchain/core": "0.2.15",
Expand All @@ -53,7 +54,6 @@
"@types/node": "20",
"@types/react": "18.2.61",
"@types/react-dom": "18.2.19",
"ai": "3.4.30",
"autoprefixer": "10.4.20",
"dotenv-cli": "7.4.2",
"js-md5": "0.8.3",
Expand Down
4 changes: 3 additions & 1 deletion apps/chat-with-pdf/utils/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export async function getContext(query: string, documentId: string) {
const { data: documentSections, error } = await supabase.rpc(
"match_documents",
{
query_embedding: userQueryEmbeddings.toString(),
query_embedding: Array.isArray(userQueryEmbeddings)
? JSON.stringify(userQueryEmbeddings)
: JSON.stringify([userQueryEmbeddings]),
match_threshold: 0.7,
match_count: 200,
document_id: documentId,
Expand Down
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ AS $function$BEGIN
END;$function$
;

CREATE TRIGGER remove_document_file_after_chat_delete
AFTER DELETE ON public."Chat" FOR EACH ROW
EXECUTE FUNCTION public.remove_document_file_after_removing_chats ();

0 comments on commit 6d35184

Please sign in to comment.