From 3d936f957ee20feb7c3863ddccf204c4fa9ae080 Mon Sep 17 00:00:00 2001 From: zaidmukaddam Date: Tue, 27 Aug 2024 11:06:22 +0530 Subject: [PATCH] feat: Update toDataStreamResponse method for chat and cohere routes and dependencies --- app/actions.ts | 2 +- app/api/chat/route.ts | 2 +- app/api/cohere/route.ts | 2 +- pnpm-lock.yaml | 106 ++++++++++++++++++++++++++-------------- 4 files changed, 73 insertions(+), 39 deletions(-) diff --git a/app/actions.ts b/app/actions.ts index c4b7782..8cb114a 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -17,7 +17,7 @@ export async function suggestQuestions(history: any[]) { model: groq('llama-3.1-70b-versatile'), temperature: 0, system: - `You are a search engine query generator. You 'have' to create 3 questions for the search engine based on the message history which has been provided to you. + `You are a search engine query generator. You 'have' to create only '3' questions for the search engine based on the message history which has been provided to you. The questions should be open-ended and should encourage further discussion while maintaining the whole context. Limit it to 5-10 words per question. Always put the user input's context is some way so that the next search knows what to search for exactly. Try to stick to the context of the conversation and avoid asking questions that are too general or too specific. diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index eefc5b8..d7769f0 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -439,5 +439,5 @@ When asked a "What is" question, maintain the same format as the question and an toolChoice: "auto", }); - return result.toAIStreamResponse(); + return result.toDataStreamResponse(); } diff --git a/app/api/cohere/route.ts b/app/api/cohere/route.ts index c51d5c2..0f93a3f 100644 --- a/app/api/cohere/route.ts +++ b/app/api/cohere/route.ts @@ -401,5 +401,5 @@ Remember to always run the appropriate tool(s) first and compose your response b toolChoice: "auto", }); - return result.toAIStreamResponse(); + return result.toDataStreamResponse(); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 139de53..a82402a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,10 +10,10 @@ dependencies: version: 0.0.31(zod@3.23.8) '@ai-sdk/cohere': specifier: latest - version: 0.0.20(zod@3.23.8) + version: 0.0.21(zod@3.23.8) '@ai-sdk/openai': specifier: latest - version: 0.0.53(zod@3.23.8) + version: 0.0.54(zod@3.23.8) '@e2b/code-interpreter': specifier: ^0.0.8 version: 0.0.8 @@ -64,7 +64,7 @@ dependencies: version: 1.4.0 ai: specifier: latest - version: 3.3.17(openai@4.56.0)(react@18.3.1)(svelte@4.2.18)(vue@3.4.35)(zod@3.23.8) + version: 3.3.19(openai@4.56.0)(react@18.3.1)(svelte@4.2.18)(vue@3.4.35)(zod@3.23.8) class-variance-authority: specifier: ^0.7.0 version: 0.7.0 @@ -172,14 +172,14 @@ packages: zod: 3.23.8 dev: false - /@ai-sdk/cohere@0.0.20(zod@3.23.8): - resolution: {integrity: sha512-QCd7SneC/q2sPvfmewYtcwCSayv3leGmuwESSx33qdl11A9IXGYNyiw6juIsp3EvZnnxUjWUR8ilhyHhyk45Hw==} + /@ai-sdk/cohere@0.0.21(zod@3.23.8): + resolution: {integrity: sha512-WmhCuxJp5VqVhb47ILAQ6RPXS9Ophm1loMnG44PL/YjO2m1qfu3UWM+FLuRI57WFS0eTIjP/VUAhjQq45isAjw==} engines: {node: '>=18'} peerDependencies: zod: ^3.0.0 dependencies: - '@ai-sdk/provider': 0.0.21 - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) + '@ai-sdk/provider': 0.0.22 + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) zod: 3.23.8 dev: false @@ -194,6 +194,17 @@ packages: zod: 3.23.8 dev: false + /@ai-sdk/openai@0.0.54(zod@3.23.8): + resolution: {integrity: sha512-0jqUSY9Lq0ie4AxnAucmiMhVBbs8ivvOW73sq3pCNA+LFeb2edOcnI0qmfGfHTn/VOjUCf2TvzQzHQx1Du3sYA==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.0.0 + dependencies: + '@ai-sdk/provider': 0.0.22 + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) + zod: 3.23.8 + dev: false + /@ai-sdk/provider-utils@1.0.16(zod@3.23.8): resolution: {integrity: sha512-8Nd8vIkGTIthhfgJEdP9KyMlykehBNP/1J47eMC3vQqYgJV6r5Bgvl3LFVfWi9KzamiD8tp9nU2NJKTeo4MH/A==} engines: {node: '>=18'} @@ -210,6 +221,22 @@ packages: zod: 3.23.8 dev: false + /@ai-sdk/provider-utils@1.0.17(zod@3.23.8): + resolution: {integrity: sha512-2VyeTH5DQ6AxqvwdyytKIeiZyYTyJffpufWjE67zM2sXMIHgYl7fivo8m5wVl6Cbf1dFPSGKq//C9s+lz+NHrQ==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.0.0 + peerDependenciesMeta: + zod: + optional: true + dependencies: + '@ai-sdk/provider': 0.0.22 + eventsource-parser: 1.1.2 + nanoid: 3.3.6 + secure-json-parse: 2.7.0 + zod: 3.23.8 + dev: false + /@ai-sdk/provider@0.0.21: resolution: {integrity: sha512-9j95uaPRxwYkzQdkl4XO/MmWWW5c5vcVSXtqvALpD9SMB9fzH46dO3UN4VbOJR2J3Z84CZAqgZu5tNlkptT9qQ==} engines: {node: '>=18'} @@ -217,8 +244,15 @@ packages: json-schema: 0.4.0 dev: false - /@ai-sdk/react@0.0.51(react@18.3.1)(zod@3.23.8): - resolution: {integrity: sha512-Hq5splFSB6OVovHamXvpnd1S7jfIz/CXWjaLo9sr90jd/W370NA8GhBd6oSLfqMeKrPosV4qRBH5S8lv2bauqA==} + /@ai-sdk/provider@0.0.22: + resolution: {integrity: sha512-smZ1/2jL/JSKnbhC6ama/PxI2D/psj+YAe0c0qpd5ComQCNFltg72VFf0rpUSFMmFuj1pCCNoBOCrvyl8HTZHQ==} + engines: {node: '>=18'} + dependencies: + json-schema: 0.4.0 + dev: false + + /@ai-sdk/react@0.0.52(react@18.3.1)(zod@3.23.8): + resolution: {integrity: sha512-4Gm+AoINDXQ4lzIZFKOWOcKgjgiAFdyhmBxnyuaqzTJCoRWNUSea62xhjqRE0u8wagfPgxWUAyS8BAsY0EqOyg==} engines: {node: '>=18'} peerDependencies: react: ^18 || ^19 @@ -229,15 +263,15 @@ packages: zod: optional: true dependencies: - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) - '@ai-sdk/ui-utils': 0.0.38(zod@3.23.8) + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) + '@ai-sdk/ui-utils': 0.0.39(zod@3.23.8) react: 18.3.1 swr: 2.2.5(react@18.3.1) zod: 3.23.8 dev: false - /@ai-sdk/solid@0.0.41(zod@3.23.8): - resolution: {integrity: sha512-w4vSkd2388FJMnKPALP8SL4p3XAR70FAPj0qrd5AoYyQMMjX/E6zQGc8YAhAAnGSwiQwq/DZaE4y0lorwFVyOw==} + /@ai-sdk/solid@0.0.42(zod@3.23.8): + resolution: {integrity: sha512-tr1rXRg0bLls7ZEQCWfd0Tv7irFlKQRjBSKSCstwrGtTeDA7zwUP4tIiUaCyzM3lwyE6Qgl17SrAoxSD+xP+zQ==} engines: {node: '>=18'} peerDependencies: solid-js: ^1.7.7 @@ -245,14 +279,14 @@ packages: solid-js: optional: true dependencies: - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) - '@ai-sdk/ui-utils': 0.0.38(zod@3.23.8) + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) + '@ai-sdk/ui-utils': 0.0.39(zod@3.23.8) transitivePeerDependencies: - zod dev: false - /@ai-sdk/svelte@0.0.43(svelte@4.2.18)(zod@3.23.8): - resolution: {integrity: sha512-lUve6AGc3dtue14LLGiZs7J7L/3jEHh6SGXwuG/nDygeicKPzmG9drWZlhTdpNHN9wKtBgrCdJxQ96HKswLDNA==} + /@ai-sdk/svelte@0.0.44(svelte@4.2.18)(zod@3.23.8): + resolution: {integrity: sha512-soSiEX1BUiwRSdoc+7mAoCeuM3Vs/ebdb1gNL7ta9Zma7GTHq802Wi7KfWfypoAqpgi0QUapzCRMvgrl4oW4AQ==} engines: {node: '>=18'} peerDependencies: svelte: ^3.0.0 || ^4.0.0 @@ -260,16 +294,16 @@ packages: svelte: optional: true dependencies: - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) - '@ai-sdk/ui-utils': 0.0.38(zod@3.23.8) + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) + '@ai-sdk/ui-utils': 0.0.39(zod@3.23.8) sswr: 2.1.0(svelte@4.2.18) svelte: 4.2.18 transitivePeerDependencies: - zod dev: false - /@ai-sdk/ui-utils@0.0.38(zod@3.23.8): - resolution: {integrity: sha512-SyyfqBu7xnsfUuq3kSxzP+fxGCTMqaSL5WYGiBJpr/yLWySjBJCg/k7WueO440AqVpZBzCd3nWoCpPmjfMK8Yg==} + /@ai-sdk/ui-utils@0.0.39(zod@3.23.8): + resolution: {integrity: sha512-yxlJBFEiWR7rf/oS7MFX9O5Hr7VYV0ipMBrvds66N3+m52/nCbBB5C/eBefzeR+hoGc/r5xGo7Yd1cncGYHHTw==} engines: {node: '>=18'} peerDependencies: zod: ^3.0.0 @@ -277,16 +311,16 @@ packages: zod: optional: true dependencies: - '@ai-sdk/provider': 0.0.21 - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) + '@ai-sdk/provider': 0.0.22 + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) json-schema: 0.4.0 secure-json-parse: 2.7.0 zod: 3.23.8 zod-to-json-schema: 3.23.2(zod@3.23.8) dev: false - /@ai-sdk/vue@0.0.43(vue@3.4.35)(zod@3.23.8): - resolution: {integrity: sha512-bJB7muMpmP/wPKbDU8GCmDpI1HSkuTWz9DsQ4ZlBaCk5wqRLKxRtzM9NxfeQ15RojSLxYhKf/lDwW10RPtjcaw==} + /@ai-sdk/vue@0.0.44(vue@3.4.35)(zod@3.23.8): + resolution: {integrity: sha512-IsDCoy7u4V081dKT1i6b/Cxh2G0aftetbif+qNQGh5QeU9TtGs9KDW+onPkXeqlDQcpMN0Q5zaNGaZ7YBK50Gw==} engines: {node: '>=18'} peerDependencies: vue: ^3.3.4 @@ -294,8 +328,8 @@ packages: vue: optional: true dependencies: - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) - '@ai-sdk/ui-utils': 0.0.38(zod@3.23.8) + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) + '@ai-sdk/ui-utils': 0.0.39(zod@3.23.8) swrv: 1.0.4(vue@3.4.35) vue: 3.4.35(typescript@5.5.4) transitivePeerDependencies: @@ -1673,8 +1707,8 @@ packages: humanize-ms: 1.2.1 dev: false - /ai@3.3.17(openai@4.56.0)(react@18.3.1)(svelte@4.2.18)(vue@3.4.35)(zod@3.23.8): - resolution: {integrity: sha512-Z3cPRImctE8GMZV0e15ZlO+bqfLlVWqO+JiShJT20l3iYlZYwsQMQXjt5hiF3m7+VvbzIq+ORdp1Ai11GxzBVQ==} + /ai@3.3.19(openai@4.56.0)(react@18.3.1)(svelte@4.2.18)(vue@3.4.35)(zod@3.23.8): + resolution: {integrity: sha512-Q3K3cubOYqLVK/5P6oWu5kjjPgAo4Lr+zzLZCCG0HX9b8QemgQCPmZGRNgLNf3a2y6m4NwpjJjAPYHPlb3ytwQ==} engines: {node: '>=18'} peerDependencies: openai: ^4.42.0 @@ -1694,13 +1728,13 @@ packages: zod: optional: true dependencies: - '@ai-sdk/provider': 0.0.21 - '@ai-sdk/provider-utils': 1.0.16(zod@3.23.8) - '@ai-sdk/react': 0.0.51(react@18.3.1)(zod@3.23.8) - '@ai-sdk/solid': 0.0.41(zod@3.23.8) - '@ai-sdk/svelte': 0.0.43(svelte@4.2.18)(zod@3.23.8) - '@ai-sdk/ui-utils': 0.0.38(zod@3.23.8) - '@ai-sdk/vue': 0.0.43(vue@3.4.35)(zod@3.23.8) + '@ai-sdk/provider': 0.0.22 + '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) + '@ai-sdk/react': 0.0.52(react@18.3.1)(zod@3.23.8) + '@ai-sdk/solid': 0.0.42(zod@3.23.8) + '@ai-sdk/svelte': 0.0.44(svelte@4.2.18)(zod@3.23.8) + '@ai-sdk/ui-utils': 0.0.39(zod@3.23.8) + '@ai-sdk/vue': 0.0.44(vue@3.4.35)(zod@3.23.8) '@opentelemetry/api': 1.9.0 eventsource-parser: 1.1.2 json-schema: 0.4.0