Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

defineChatMiddleware.md

41 lines1.2 KB

1---
2id: defineChatMiddleware
3title: defineChatMiddleware
4---
5​
6# Function: defineChatMiddleware()
7​
8```ts
9function defineChatMiddleware<TContext, TRequires, TProvides>(middleware): DefinedChatMiddleware<TContext, TRequires, TProvides>;
10```
11​
12Defined in: [packages/ai/src/activities/chat/middleware/define.ts:23](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/middleware/define.ts#L23)
13​
14Identity helper for authoring middleware with precise capability inference.
15Returns the middleware unchanged at runtime; only sharpens its type so the
16`chat()` array coverage check and `createChatMiddleware` builder can read the
17exact `requires`/`provides`.
18​
19## Type Parameters
20​
21### TContext
22​
23`TContext` = `unknown`
24​
25### TRequires
26​
27`TRequires` *extends* readonly [`CapabilityHandle`](../type-aliases/CapabilityHandle.md)[] = readonly \[\]
28​
29### TProvides
30​
31`TProvides` *extends* readonly [`CapabilityHandle`](../type-aliases/CapabilityHandle.md)[] = readonly \[\]
32​
33## Parameters
34​
35### middleware
36​
37[`ChatMiddleware`](../interfaces/ChatMiddleware.md)\<`TContext`\> & `object`
38​
39## Returns
40​
41[`DefinedChatMiddleware`](../interfaces/DefinedChatMiddleware.md)\<`TContext`, `TRequires`, `TProvides`\>