Eureka / src /eureka /math_agent /tools /source_cache.py
manxis-contact's picture
Add files using upload-large-folder tool
a30d31a verified
Raw
History Blame Contribute Delete
586 Bytes
from __future__ import annotations
class SourceCache:
def __init__(self):self.data={}
def put_role(self,ref,version,role,payload):self.data[(ref,version,role)]=payload
def check_role(self,ref,version,role):
if (ref,version,role) in self.data:return {'status':'HIT','payload':self.data[(ref,version,role)]}
if any(r==ref and ro==role and v!=version for r,v,ro in self.data):return {'status':'REFRESH_VERSION_CHANGED'}
if any(r==ref and v==version for r,v,ro in self.data):return {'status':'MISS_ROLE'}
return {'status':'MISS_SOURCE'}