Dialog Tape
Types and classes for dialog tapes and annotators.
Classes:
-
AnnotationAction
–AnnotationAction is a subclass of Action that represents an action produced by an annotator.
-
AnnotatorFreeFormThought
–AnnotatorFreeFormThought is a subclass of Thought that represents a free-form thought provided by an annotator.
-
AssistantStep
–Represents a step taken by an assistant in a dialog.
-
AssistantThought
–Represents a thought generated by an assistant.
-
DialogAnnotator
–DialogAnnotator is a class that extends the Annotator agent with specific types DialogTape and DialogAnnotatorTape.
-
DialogContext
–Context for dialog agents, containing tools and other information.
-
FunctionCall
–A class representing a function call.
-
FunctionSpec
–A class representing the specification of a function.
-
SystemStep
–Step rendered into system message of the prompt.
-
ToolCall
–ToolCall is a model representing a tool call with a specific function, id, and type.
-
ToolCalls
–Action that wraps one-or-many tool calls.
-
ToolResult
–ToolResult is a subclass of Observation that represents the result of a tool call.
-
ToolSpec
–ToolSpec is a model that represents a tool specification with a type and a function.
-
UserStep
–Represents a step taken by a user in a dialog.
Attributes:
-
DialogAnnotatorTape
(TypeAlias
) –Type alias for dialog annotator tapes.
-
DialogEvent
(TypeAlias
) –Type alias for dialog events.
-
DialogStep
(TypeAlias
) –Type alias for dialog steps.
-
DialogTape
–Type alias for dialog tapes.
DialogAnnotatorTape: TypeAlias = Tape[DialogTape, AnnotatorFreeFormThought | AnnotationAction]
module-attribute
Type alias for dialog annotator tapes.
DialogEvent: TypeAlias = AgentEvent[DialogTape]
module-attribute
Type alias for dialog events.
DialogStep: TypeAlias = UserStep | ToolResult | SystemStep | AssistantThought | SetNextNode | Pass | Call | Respond | FinalStep | AssistantStep | ToolCalls
module-attribute
Type alias for dialog steps.
DialogTape = Tape[DialogContext | None, DialogStep]
module-attribute
Type alias for dialog tapes.
AnnotationAction
Bases: Action
AnnotationAction is a subclass of Action that represents an action produced by an annotator.
Attributes:
-
kind
(Literal['annotation_action']
) –A string literal indicating the type of action.
-
annotation
(dict
) –A dictionary containing annotation data.
Source code in tapeagents/dialog_tape.py
268 269 270 271 272 273 274 275 276 277 278 |
|
AnnotatorFreeFormThought
Bases: Thought
AnnotatorFreeFormThought is a subclass of Thought that represents a free-form thought provided by an annotator.
Attributes:
-
kind
(Literal['annotator_free_form_thought']
) –A constant string that identifies the type of thought.
-
content
(str
) –The content of the free-form thought provided by the annotator.
Source code in tapeagents/dialog_tape.py
255 256 257 258 259 260 261 262 263 264 265 |
|
AssistantStep
Bases: Action
Represents a step taken by an assistant in a dialog.
Attributes:
-
content
(str
) –The content of the assistant's response.
-
kind
(Literal['assistant']
) –The type of step, which is always "assistant".
Source code in tapeagents/dialog_tape.py
67 68 69 70 71 72 73 74 75 76 77 |
|
AssistantThought
Bases: Thought
Represents a thought generated by an assistant.
Attributes:
-
content
(Any
) –The content of the assistant's thought.
-
kind
(Literal['assistant_thought']
) –A literal string indicating the type of thought.
Source code in tapeagents/dialog_tape.py
54 55 56 57 58 59 60 61 62 63 64 |
|
DialogAnnotator
Bases: Annotator[DialogTape, DialogAnnotatorTape]
DialogAnnotator is a class that extends the Annotator agent with specific types DialogTape and DialogAnnotatorTape.
Methods:
-
make_own_tape
–DialogTape) -> DialogAnnotatorTape: Creates and returns a DialogAnnotatorTape instance using the provided DialogTape instance.
Methods:
-
make_own_tape
–Creates a DialogAnnotatorTape instance using given DialogTape as context.
Source code in tapeagents/dialog_tape.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
make_own_tape(tape)
Creates a DialogAnnotatorTape instance using given DialogTape as context.
Parameters:
-
tape
(DialogTape
) –The DialogTape instance to be converted.
Returns:
-
DialogAnnotatorTape
(DialogAnnotatorTape
) –A new instance of DialogAnnotatorTape with the provided context.
Source code in tapeagents/dialog_tape.py
294 295 296 297 298 299 300 301 302 303 304 |
|
DialogContext
Bases: BaseModel
Context for dialog agents, containing tools and other information.
Source code in tapeagents/dialog_tape.py
237 238 239 240 241 242 243 |
|
FunctionCall
Bases: BaseModel
A class representing a function call.
Attributes:
-
name
(str
) –The name of the function being called.
-
arguments
(Any
) –The arguments to be passed to the function.
Source code in tapeagents/dialog_tape.py
80 81 82 83 84 85 86 87 88 89 90 |
|
FunctionSpec
Bases: BaseModel
A class representing the specification of a function.
Attributes:
-
name
(str
) –The name of the function.
-
description
(str
) –A brief description of the function.
-
parameters
(dict
) –A dictionary containing the parameters of the function.
Source code in tapeagents/dialog_tape.py
196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
SystemStep
Bases: Observation
Step rendered into system message of the prompt.
Attributes:
-
content
(str
) –The content of the system step.
-
kind
(Literal['system']
) –A literal indicating the type of step, which is always "system".
Source code in tapeagents/dialog_tape.py
28 29 30 31 32 33 34 35 36 37 38 |
|
ToolCall
Bases: BaseModel
ToolCall is a model representing a tool call with a specific function, id, and type.
Attributes:
-
function
(FunctionCall
) –The function call associated with the tool.
-
id
(str
) –The identifier for the tool call. Defaults to an empty string.
-
type
(str
) –The type of the tool call. Defaults to "function".
Source code in tapeagents/dialog_tape.py
93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
ToolCalls
Bases: Action
Action that wraps one-or-many tool calls.
We structure this class similar to OpenAI tool calls, but we let function arguments be Any, not just str
(see FunctionCall
class)
Attributes:
-
tool_calls
(list[ToolCall]
) –The list of tool calls to be made.
-
kind
(Literal['assistant']
) –The type of step, which is always "assistant".
Methods:
-
from_dicts
–Create a ToolCalls instance from a list of dictionaries.
-
from_llm_output
–Converts an LLMOutput object to a ToolCalls object.
Source code in tapeagents/dialog_tape.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
from_dicts(dicts)
staticmethod
Create a ToolCalls instance from a list of dictionaries.
Parameters:
-
dicts
(list
) –A list of dictionaries where each dictionary represents a tool call.
Returns:
-
ToolCalls
–An instance of ToolCalls created from the provided list of dictionaries.
Source code in tapeagents/dialog_tape.py
122 123 124 125 126 127 128 129 130 131 132 133 |
|
from_llm_output(llm_output)
staticmethod
Converts an LLMOutput object to a ToolCalls object.
Parameters:
-
llm_output
(LLMOutput
) –The output from the language model, which contains tool calls.
Returns:
-
ToolCalls
(ToolCalls
) –An object containing a list of ToolCall objects.
Raises:
-
ValueError
–If the llm_output does not contain any tool calls.
Source code in tapeagents/dialog_tape.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
ToolResult
Bases: Observation
ToolResult is a subclass of Observation that represents the result of a tool call.
Attributes:
-
content
(Any
) –The content of the tool result.
-
tool_call_id
(str
) –The unique identifier for the tool call. Defaults to an empty string.
-
kind
(Literal['tool']
) –The kind of result, which is always "tool". Defaults to "tool".
Source code in tapeagents/dialog_tape.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
ToolSpec
Bases: BaseModel
ToolSpec is a model that represents a tool specification with a type and a function.
Attributes:
-
type
(Literal['function']
) –The type of the tool, which is always "function".
-
function
(FunctionSpec
) –The specification of the function.
Methods:
-
from_function
–Creates an instance of the class by validating the model from a given function.
Source code in tapeagents/dialog_tape.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
from_function(function)
classmethod
Creates an instance of the class by validating the model from a given function.
Parameters:
-
function
(Callable
) –The function to be converted and validated.
Returns:
-
ToolSpec
–An instance of the class with the validated model.
Source code in tapeagents/dialog_tape.py
223 224 225 226 227 228 229 230 231 232 233 234 |
|
UserStep
Bases: Observation
Represents a step taken by a user in a dialog.
Attributes:
-
content
(str
) –The content of the user's step.
-
kind
(Literal['user']
) –The type of step, which is always "user".
Source code in tapeagents/dialog_tape.py
41 42 43 44 45 46 47 48 49 50 51 |
|