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.

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

Save experience to the database.

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.

Parameters:
  • reward (float) – The reward value to be updated.

  • msg_ids (list) – List of message IDs to update.

  • run_id (int) – The run ID associated with the experiences.

  • task_id (str) – The task ID associated with the experiences.

Returns:

List of updated experiences.

Return type:

List[Experience]

Note

Only experiences that have not been consumed (consumed == 0) will be returned. For example, if you call this method multiple times with the same msg_ids, only the first call will return the updated experiences; subsequent calls will return an empty list.