Skip to content
0

katanakit-js / useReply

Function: useReply() ​

ts
function useReply(
   sessionId, 
   text, 
   options?
): Promise<AssistantResult>;

Defined in: src/core/services/assistant.service.ts:349

Sends a user message within a conversation and returns the assistant reply. If no sessionId is provided, a new session is created. The user message and the assistant reply are persisted only on success.

Parameters ​

ParameterTypeDescription
sessionIdstring | undefinedExisting session id, or undefined to start a new one.
textstringThe user's message.
optionsAssistantReplyOptionsOptional completion options.

Returns ​

Promise<AssistantResult>

An AssistantResult with the reply and session id.

Example ​

ts
import { useReply } from "katanakit-js";

const result = await useReply(undefined, "How do I reset my password?");
if (result.ok) console.log(result.data.reply);

Released under the MIT License.