Aller au contenu

@mirego/forra-api


@mirego/forra-api / Streaming Utilities / StreamWithToolsWrapper

Class: StreamWithToolsWrapper

Wrapper for handling streaming with tools. This class manages the tool execution loop, including executing tools client-side and making follow-up requests with tool results.

Constructors

Constructor

new StreamWithToolsWrapper(tools, maxLoopIterations): StreamWithToolsWrapper

Parameters

tools

Record\<string, ToolDefinition> = {}

maxLoopIterations

number = 10

Returns

StreamWithToolsWrapper

Methods

getToolSchemas()

getToolSchemas(): unknown[]

Get the OpenAI tool schemas to include in the request

Returns

unknown[]


hasTools()

hasTools(): boolean

Check if tools are configured

Returns

boolean


processChunksWithTools()

processChunksWithTools(chunks, currentMessages, makeFollowUpRequest, onChunk, onError): Promise\<void>

Process chunks and handle tool calls if present

Parameters

chunks

StreamChunk[]

currentMessages

ConversationMessage[]

makeFollowUpRequest

(messages, includeTools, clientToolCalls?) => Promise\<void>

onChunk

(chunks?) => void

onError

(error) => void

Returns

Promise\<void>


reset()

reset(): void

Reset the iteration counter for a new conversation

Returns

void

Properties

clarificationEmitted

clarificationEmitted: boolean = false