@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) ​
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
Source ​
Properties ​
assistant? ​
optional assistant: AssistantContent;
Information received from OpenAI
Source ​
previous? ​
optional previous: Interaction;
Previous interaction in chain
Source ​
user ​
user: UserContent;
Information sent (or to be sent) by us to OpenAI
Source ​
Accessors ​
complete ​
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 ​
expectsToolResponse ​
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 ​
Methods ​
toMessages() ​
toMessages(): Message[]
Convert interaction chain ending in this interaction to array of messages
Returns ​
Message
[]
Array of messages