class CollectorData:
def __init__(
self,
id: UUID,
name: str,
role: Literal['user', 'assistant', 'system', 'tool'],
message: Optional[str] = None,
function_call: Optional[Dict[str, Any]] = None
):
Create a data item store information about a message. Used by the data collector.
Parameters:
Literal["user", "assistant", "system", "function"]
): The role of the message.None
)None
)def from_context(name, context: Dict[str, Any]):
Create a data collector from a context.
Parameters:
Returns:
CollectorData: The data collector.
class BaseDataCollector(ABC):
Base class for data collectors.
def __init__(self):
Create a data collector.
def step(
self,
role: Literal['user', 'assistant', 'system', 'tool'],
name: Optional[str] = None,
message: Optional[str] = None,
function_call: Optional[Dict[str, Any]] = None
):
Record a message.
Parameters:
Literal["user", "assistant", "system", "tool"]
): The role of the message.None
)None
)None
)Returns:
Self: The data collector.
def record(self, agent: Union[List[ChatAgent], ChatAgent]):
Record agents.
Parameters:
def start(self):
Start recording.
def stop(self):
Stop recording.
def recording(self):
Whether the collector is recording.
def reset(self, reset_agents: bool = True):
Reset the collector.
Parameters:
def convert(self):
Convert the collected data.
def llm_convert(self, converter: Any, prompt: Optional[str] = None):
Convert the collected data.
def get_agent_history(self, name: str):
Get the message history of an agent.
Parameters:
Returns:
List[CollectorData]: The message history of the agent