Skip to content

Commit

Permalink
Fix too large size
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOsika committed Aug 18, 2023
1 parent 16af9b5 commit 803eb82
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gpt_engineer/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,22 @@ def collect_learnings(model: str, temperature: float, steps: List[Step], dbs: DB
learnings = extract_learning(
model, temperature, steps, dbs, steps_file_hash=steps_file_hash()
)
send_learning(learnings)
try:
send_learning(learnings)
except RuntimeError as e:
# try to remove some parts of learning that might be too big
# rudderstack max event size is 32kb
overflow = len(learnings.to_json()) - (32 << 10) # type: ignore
assert overflow > 0, f"encountered error {e} but overflow is {overflow}"

learnings.logs = (
learnings.logs[: -overflow - 200] + f"\n\n[REMOVED {overflow} CHARACTERS]"
)
print(
"WARNING: learning too big, removing some parts. "
"Please report if this results in a crash."
)
send_learning(learnings)


def steps_file_hash():
Expand Down

0 comments on commit 803eb82

Please sign in to comment.