Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFinish strange error with Drizzle/BASE_URL: "values() must be called with at least one value" #619

Open
fullstackwebdev opened this issue Dec 14, 2024 · 5 comments

Comments

@fullstackwebdev
Copy link

Using the repo's onFinished I am getting an error, but only when tool calling. Is there a way to get better tracing or debugging for resolving this? All this abstraction seems to be confusing, what is the actual error?

 GET /api/files/df381887-0a81-461b-8179-ac9de943c373.jpeg 200 in 195ms
 GET /api/history 200 in 364ms
Failed to save messages in database Error: values() must be called with at least one value
    at PgInsertBuilder.values (turbopack://[project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_bxbm5u47tukj6nmhfvnnj7uaym/node_modules/src/pg-core/query-builders/insert.ts:54:9)
    at saveMessages (turbopack://[project]/lib/db/queries.ts:111:36)
    at onFinish (turbopack://[project]/app/(chat)/api/chat/route.ts:342:29)
    at Object.flush (turbopack://[project]/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ai/core/generate-text/stream-text.ts:920:26)
  52 | 		values = Array.isArray(values) ? values : [values];
  53 | 		if (values.length === 0) {
> 54 | 			throw new Error('values() must be called with at least one value');
     | 			     ^
  55 | 		}
  56 | 		const mappedValues = values.map((entry) => {
  57 | 			const result: Record<string, Param | SQL> = {};
Failed to save chat
 POST /api/chat 200 in 1237ms
 GET /api/history 200 in 300ms
 GET /api/vote?chatId=20a2e516-9c8f-40eb-86ab-7f48a7beddd1 200 in 314ms



@sailxjx
Copy link

sailxjx commented Dec 14, 2024

I have the same problem, and I don't know how to debug it, the document didn't clarify anything, not even returning a message like greeting in the tool call.

@wjx
Copy link

wjx commented Dec 14, 2024

If you add new tool calls, ensure that you include them in both the AllowedTools type and the allTools array in /api/chat/route.ts. Failing to do so will result in incomplete messages being passed to onFinish when the tool is invoked, causing the aforementioned error.

@sailxjx
Copy link

sailxjx commented Dec 14, 2024

If you add new tool calls, ensure that you include them in both the AllowedTools type and the allTools array in /api/chat/route.ts. Failing to do so will result in incomplete messages being passed to onFinish when the tool is invoked, causing the aforementioned error.

That's the correct answer, the document missing this step.

@fullstackwebdev
Copy link
Author

Hi thanks, I also get it on image uploading.

@wjx
Copy link

wjx commented Dec 14, 2024

Hi thanks, I also get it on image uploading.

How do you upload image?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants