Saltar al contenido principal

Function: useReply()

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

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

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

sessionId

string | undefined

Existing session id, or undefined to start a new one.

text

string

The user's message.

options?

AssistantReplyOptions = {}

Optional completion options.

Returns

Promise<AssistantResult>

An AssistantResult with the reply and session id.

Example

import { useReply } from "katanakit-js";

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