trinity.explorer.proxy.recorder module#

class trinity.explorer.proxy.recorder.HistoryRecorder(db_url: str, table_name: str)[source]#

Bases: object

Record chat history into the database using async SQL.

__init__(db_url: str, table_name: str)[source]#
async prepare() → None[source]#
async record_history(experiences: List[Experience]) → None[source]#

Save experiences to the database.

async update_reward(reward: float, msg_ids: list, run_id: int, task_id: str) → List[Experience][source]#

Update reward for given response IDs and return the updated experiences.

Only experiences that have not been consumed (consumed == 0) will be returned.

class trinity.explorer.proxy.recorder.MemoryHistoryRecorder[source]#

Bases: object

In-memory version of HistoryRecorder for high-performance reward update and history recording. All data is stored in memory, and can be flushed to persistent storage as needed.

__init__()[source]#
async record_history(experiences: List[Experience]) → None[source]#

Save experiences in memory.

async update_reward(reward: float, msg_ids: list, run_id: int, task_id: str) → List[Experience][source]#

Update reward for given response IDs and return the updated experiences.