senti-beta / scratch /fix_microservice_models.py
joseph njoroge kariuki
Deploy Senti AI to Hugging Face Spaces
021e065
Raw
History Blame Contribute Delete
925 Bytes
import os
BASE_DIR = r"c:\Users\LENOVO\Desktop\senti_ai"
PACKS = ["sentibiz", "senticorporate", "sentiglobal", "sentiplan"]
for pack in PACKS:
model_path = os.path.join(BASE_DIR, pack, "model.py")
if not os.path.exists(model_path):
print(f"Skipping {pack} (not found)")
continue
with open(model_path, "r", encoding="utf-8") as f:
content = f.read()
old_tensor_line = "x = torch.tensor([feat], dtype=torch.float32)"
new_tensor_line = "x = torch.tensor([feat[:9]], dtype=torch.float32)"
if old_tensor_line in content:
print(f"Fixing {pack} model tensor shape...")
content = content.replace(old_tensor_line, new_tensor_line)
with open(model_path, "w", encoding="utf-8") as f:
f.write(content)
else:
print(f"{pack} does not have target tensor line or is already fixed")
print("Finished fixing dimensions.")