🔄 Big News! bazed.ai is now sagentic.ai. Same vision, new name!

Skip to content

@sagentic-ai/sagentic-af / Interaction

Interaction ​

Interaction is a single interaction in a conversation. An interaction is a pair of messages, one from us to OpenAI and one from OpenAI to us. The messages can be either text or tool calls or responses to tool calls. Interactions are chained together to form a thread in a form of linked list. An Interaction can be complete or incomplete. An interaction is complete if we have received a response from OpenAI completing the interaction. This means that if the last message in the interaction is from us, the interaction is not complete.

Constructors ​

new Interaction(user, previous) ​

ts
new Interaction(user, previous?): Interaction

Create new Interaction

Parameters ​

• user: UserContent

Text or tool results sent (or to be sent) by us to OpenAI

• previous?: Interaction

Previous interaction in chain, omitting this means this is the first interaction in the chain

Returns ​

Interaction

Interaction

Source ​

src/thread.ts:126

Properties ​

assistant? ​

ts
optional assistant: AssistantContent;

Information received from OpenAI

Source ​

src/thread.ts:119


previous? ​

ts
optional previous: Interaction;

Previous interaction in chain

Source ​

src/thread.ts:115


user ​

ts
user: UserContent;

Information sent (or to be sent) by us to OpenAI

Source ​

src/thread.ts:117

Accessors ​

complete ​

ts
get complete(): boolean

Is this interaction complete? An interaction is complete if we have received a response from OpenAI.

Returns ​

boolean

true if complete, false otherwise

Source ​

src/thread.ts:139


expectsToolResponse ​

ts
get expectsToolResponse(): boolean

Does this interaction expect response from tools?

Throws ​

Error if malformed tool call

Returns ​

boolean

true if expects response from tools, false otherwise

Source ​

src/thread.ts:147

Methods ​

toMessages() ​

ts
toMessages(): Message[]

Convert interaction chain ending in this interaction to array of messages

Returns ​

Message[]

Array of messages

Source ​

src/thread.ts:158