Giter Site home page Giter Site logo

Comments (6)

lgrammel avatar lgrammel commented on July 17, 2024 1

WIP PR: #2052

from ai.

BrianHung avatar BrianHung commented on July 17, 2024

A possible solution might be to enqueue a toolCall message and the error message, so that useChat gets an updated messages list which prevents triggerRequest from being called again.

          } catch (error) {
            controller.enqueue // tool call finished with an arguments parsing error
            toolResultsStreamController!.enqueue({
              type: 'error',
              error,
            });
          }

} catch (error) {
toolResultsStreamController!.enqueue({
type: 'error',
error,
});
}

from ai.

BrianHung avatar BrianHung commented on July 17, 2024

If I am reading this right

Unfortunately function-calling is not guaranteed to follow the schema, and there can be differences in quality from model to model.

The arguments returned may not always follow the zod schema that was given.

I don't know what is better behavior here

  • stop early and tell the user that it was unable to generate arguments to the specified tool call
  • continue to try again until maxAutomaticRoundtrips is exhausted

from ai.

BrianHung avatar BrianHung commented on July 17, 2024

For my use case, I was able to avoid an argument parsing error by being more precise with the tool and parameter descriptions.

showBarChart: {
	description:
		'Make a bar plot in matplotlib. The bars are positioned at x. Their dimensions are given by height. Always include the data parameter as a list of JSON objects.',
	parameters: z.object({
		axisKey: z.string().describe('The key to use for the x-axis.'),
		data: z
			.array(z.record(z.union([z.string(), z.number()])))
			.describe(
				'List of JSON objects for which to generate grouped bars. JSON objects must always contain axisKey as a field.'
			),
		title: z.string().optional().describe('Set a title for the plot.'),
		yLabel: z.string().optional().describe('Set the label for the y-axis.'),
	}),
},

from ai.

lgrammel avatar lgrammel commented on July 17, 2024

Reproduced.

from ai.

lgrammel avatar lgrammel commented on July 17, 2024

Cause:

  • when the last message in useChat is an assistant message with completed tool calls,
  • and streamText only returns an error event,
  • then the checks fail and an infinite loop with the last assistant message is started.

from ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.