Skip to content

Latest commit

 

History

History
87 lines (70 loc) · 2.4 KB

File metadata and controls

87 lines (70 loc) · 2.4 KB
title useMakeCopilotActionable
description A hook for providing actions the Copilot can call.

useMakeCopilotActionable is a React hook that lets you integrate actionable functions in the Copilot chat. The Copilot can then call these actions to trigger actions in your application, allowing for interactive and dynamic behavior controlled by the Copilot.

```jsx useMakeCopilotActionable Example useMakeCopilotActionable( { name: "sayHello", description: "Say hello to someone.", argumentAnnotations: [ { name: "name", type: "string", description: "name of the person to say greet", required: true, }, ],
  implementation: async (name: string) => {
    alert(`Hello, ${name}!`);
  },
},
[],

);

</RequestExample>

## Parameters

<ResponseField name="function" type="AnnotatedFunction" required>
The function made available to the Copilot. See [AnnotatedFunction](#annotatedfunction).
</ResponseField>

## AnnotatedFunction

<ResponseField name="name" type="string" required>
The name of the function.
</ResponseField>

<ResponseField name="description" type="string" required>
A description of the function. This is used to instruct the Copilot
on how to use the function.
</ResponseField>

<ResponseField name="argumentAnnotations" type="AnnotatedFunctionArgument[]" required>
Annotated arguments for the function. See [AnnotatedFunctionArgument](#annotatedfunctionargument).
</ResponseField>

<ResponseField name="implementation" type="(...args: Inputs) => Promise<void>" required>
The implementation of the function.
</ResponseField>

## AnnotatedFunctionArgument

<ResponseField name="name" type="string" required>
The name of the argument.
</ResponseField>

<ResponseField name="type" type="'string' | 'number' | 'boolean' | 'object' | 'array'" required>
The type of the argument.
</ResponseField>

<ResponseField name="description" type="string" required>
A description of the argument. This is used to instruct the Copilot
on how what this argument is used for.
</ResponseField>

<ResponseField name="required" type="boolean" required>
Wether or not the argument is required.
</ResponseField>

<ResponseField name="items" required>
If the argument is an array, this field describes the items in the array, i.e.:
```js
items: {
  type: string;
}