fix: NameError hashlib in _antigravity_normalize_context, use string comparison instead
This commit is contained in:
Binary file not shown.
@@ -4385,19 +4385,19 @@ def _antigravity_normalize_context(input_data):
|
|||||||
if msg_item is not input_data[latest_user_idx]:
|
if msg_item is not input_data[latest_user_idx]:
|
||||||
result.append(msg_item)
|
result.append(msg_item)
|
||||||
|
|
||||||
latest_hash = hashlib.sha256(" ".join(latest_user.strip().split()).encode()).hexdigest()
|
latest_norm = " ".join(latest_user.strip().split())[:200].lower()
|
||||||
already_present = False
|
already_present = False
|
||||||
for r in result:
|
for r in result:
|
||||||
if isinstance(r, dict) and r.get("type") == "message" and r.get("role") == "user":
|
if isinstance(r, dict) and r.get("type") == "message" and r.get("role") == "user":
|
||||||
c = r.get("content", "")
|
c = r.get("content", "")
|
||||||
if isinstance(c, str):
|
if isinstance(c, str):
|
||||||
rh = hashlib.sha256(" ".join(c.strip().split()).encode()).hexdigest()
|
rn = " ".join(c.strip().split())[:200].lower()
|
||||||
elif isinstance(c, list):
|
elif isinstance(c, list):
|
||||||
combined = " ".join(p.get("text", p.get("input_text", "")) for p in c if isinstance(p, dict))
|
combined = " ".join(p.get("text", p.get("input_text", "")) for p in c if isinstance(p, dict))
|
||||||
rh = hashlib.sha256(" ".join(combined.strip().split()).encode()).hexdigest()
|
rn = " ".join(combined.strip().split())[:200].lower()
|
||||||
else:
|
else:
|
||||||
rh = ""
|
rn = ""
|
||||||
if rh == latest_hash:
|
if rn == latest_norm:
|
||||||
already_present = True
|
already_present = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@@ -4385,19 +4385,19 @@ def _antigravity_normalize_context(input_data):
|
|||||||
if msg_item is not input_data[latest_user_idx]:
|
if msg_item is not input_data[latest_user_idx]:
|
||||||
result.append(msg_item)
|
result.append(msg_item)
|
||||||
|
|
||||||
latest_hash = hashlib.sha256(" ".join(latest_user.strip().split()).encode()).hexdigest()
|
latest_norm = " ".join(latest_user.strip().split())[:200].lower()
|
||||||
already_present = False
|
already_present = False
|
||||||
for r in result:
|
for r in result:
|
||||||
if isinstance(r, dict) and r.get("type") == "message" and r.get("role") == "user":
|
if isinstance(r, dict) and r.get("type") == "message" and r.get("role") == "user":
|
||||||
c = r.get("content", "")
|
c = r.get("content", "")
|
||||||
if isinstance(c, str):
|
if isinstance(c, str):
|
||||||
rh = hashlib.sha256(" ".join(c.strip().split()).encode()).hexdigest()
|
rn = " ".join(c.strip().split())[:200].lower()
|
||||||
elif isinstance(c, list):
|
elif isinstance(c, list):
|
||||||
combined = " ".join(p.get("text", p.get("input_text", "")) for p in c if isinstance(p, dict))
|
combined = " ".join(p.get("text", p.get("input_text", "")) for p in c if isinstance(p, dict))
|
||||||
rh = hashlib.sha256(" ".join(combined.strip().split()).encode()).hexdigest()
|
rn = " ".join(combined.strip().split())[:200].lower()
|
||||||
else:
|
else:
|
||||||
rh = ""
|
rn = ""
|
||||||
if rh == latest_hash:
|
if rn == latest_norm:
|
||||||
already_present = True
|
already_present = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user