Skip to content

AIDK API Reference / aidk-server / createContextExtractor

Function: createContextExtractor() ​

ts
function createContextExtractor<TBody>(config: {
  metadata?:   | keyof TBody
     | (body: TBody) => Record<string, unknown> | undefined;
  sessionId?:   | keyof TBody
     | (body: TBody, headers?: Record<string, string | undefined>) => string | undefined;
  tenantId?: keyof TBody | (body: TBody) => string;
  threadId?: keyof TBody | (body: TBody) => string;
  userId?: keyof TBody | (body: TBody) => string;
}): ContextExtractor<TBody>;

Defined in: packages/server/src/execution-context.ts:118

Create a context extractor with custom field mappings

Type Parameters ​

Type Parameter
TBody

Parameters ​

ParameterType
config{ metadata?: | keyof TBody | (body: TBody) => Record<string, unknown> | undefined; sessionId?: | keyof TBody | (body: TBody, headers?: Record<string, string | undefined>) => string | undefined; tenantId?: keyof TBody | (body: TBody) => string; threadId?: keyof TBody | (body: TBody) => string; userId?: keyof TBody | (body: TBody) => string; }
config.metadata?| keyof TBody | (body: TBody) => Record<string, unknown> | undefined
config.sessionId?| keyof TBody | (body: TBody, headers?: Record<string, string | undefined>) => string | undefined
config.tenantId?keyof TBody | (body: TBody) => string
config.threadId?keyof TBody | (body: TBody) => string
config.userId?keyof TBody | (body: TBody) => string

Returns ​

ContextExtractor<TBody>

Released under the MIT License.