Skip to content

Commit c41b868

Browse files
refactor: streamline attribute calculation and caching logic
1 parent 2b43250 commit c41b868

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

run_ac.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def save_ac_value(record_id: str, attr_value: Any) -> None:
124124

125125
if data_type == "LLM_RESPONSE" and "http" in CACHE_FILE_UPLOAD_LINK_A2VYBG:
126126
llm_ac_cache[llm_config_hash] = cached_records
127+
# TODO only save cache every few records to avoid request spamming
127128
requests.put(CACHE_FILE_UPLOAD_LINK_A2VYBG, json=llm_ac_cache)
128129

129130
processed_records = processed_records + 1
@@ -145,16 +146,10 @@ async def process_llm_record_batch(record_dict_batch: List[Dict[str, Any]]) -> N
145146
DEFAULT_USER_PROMPT_A2VYBG, record_dict
146147
)
147148

148-
if record_dict["id"] in cached_records:
149-
print(
150-
"Using cached value for record with record_id",
151-
record_dict["data"]["running_id"],
152-
flush=True,
153-
)
154-
attr_value: str = cached_records[record_dict["id"]]
155-
else:
156-
attr_value: str = await attribute_calculators.ac(record_dict["data"])
157-
cached_records[record_dict["id"]] = attr_value
149+
attr_value: str = await attribute_calculators.ac(
150+
record_dict["data"], cached_records
151+
)
152+
158153
save_ac_value(record_dict["id"], attr_value)
159154

160155

0 commit comments

Comments
 (0)