Skip to content

Function: defineChatSessionFunction()

ts
function defineChatSessionFunction<Params>(functionDefinition: {
  description: string;
  params: Params & GbnfJsonSchema;
  handler: (params: GbnfJsonSchemaToType<Params>) => any;
 }): ChatSessionModelFunction<Params>

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 undefined | GbnfJsonSchema

Parameters

ParameterTypeDescription
functionDefinitionobject
functionDefinition.description?string-
functionDefinition.params?Params & GbnfJsonSchema-
functionDefinition.handler(params: GbnfJsonSchemaToType<Params>) => any-

Returns

ChatSessionModelFunction<Params>

Defined in

evaluator/LlamaChatSession/utils/defineChatSessionFunction.ts:12