Skip to content

Passing global context into tools called by the runTools helper #597

Description

@tday

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

  • This is a feature request for the Node library

Describe the feature or improvement you're requesting

I currently have a pattern where I need to pass context to my tools to allow them to act on my app. For example:

function updateEvent(context: { eventId: string}, args: ArgsFromOpenAi) {
   const event = await fetchEvent(eventId);
}

It'd be great if there were some way to pass a global context to the runner since the runner is passed into each function call. Then, I could do something like this:

function updateEvent( args: ArgsFromOpenAi, runner: ChatCompletionStreamingRunner<EventContext>) {
  const { eventId } = runner.context;
   const event = await fetchEvent(eventId);
}

Additional context

A workaround is to build my own runner that leverages the existing helpers. However, this is complicated because of the types integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions