Function: defineChatSessionFunction()
ts
function defineChatSessionFunction<Params, Defs>(functionDefinition: {
description?: string;
params?: Readonly<Params> & GbnfJsonSchema<Defs>;
handler: (params: GbnfJsonSchemaToType<NoInfer<Params>>) => any;
}): ChatSessionModelFunction<NoInfer<Params>>;Defined in: evaluator/LlamaChatSession/utils/defineChatSessionFunction.ts:12
Define a function that can be used by the model in a chat session, and return it.
This is a helper function to facilitate defining functions with full TypeScript type information.
The handler function can return a Promise, and the return value will be awaited before being returned to the model.
Type Parameters
| Type Parameter |
|---|
Params extends | GbnfJsonBasicSchema | GbnfJsonConstSchema | GbnfJsonEnumSchema | GbnfJsonBasicStringSchema | GbnfJsonFormatStringSchema | GbnfJsonOneOfSchema<Defs> | GbnfJsonObjectSchema<string, Defs> | GbnfJsonArraySchema<Defs> | GbnfJsonRefSchema<Defs> |
Defs extends GbnfJsonDefList<Defs> |
Parameters
| Parameter | Type | Description |
|---|---|---|
functionDefinition | { description?: string; params?: Readonly<Params> & GbnfJsonSchema<Defs>; handler: (params: GbnfJsonSchemaToType<NoInfer<Params>>) => any; } | |
functionDefinition.description? | string | - |
functionDefinition.params? | Readonly<Params> & GbnfJsonSchema<Defs> | - |
functionDefinition.handler | (params: GbnfJsonSchemaToType<NoInfer<Params>>) => any | - |
Returns
ChatSessionModelFunction<NoInfer<Params>>