Quazim0t0 commited on
Commit
1dd7417
·
verified ·
1 Parent(s): 9c8c274

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +15 -2
agent.py CHANGED
@@ -20,8 +20,21 @@ import uuid
20
  import fr24
21
  import liquid
22
 
23
- TRACES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "traces")
24
- os.makedirs(TRACES_DIR, exist_ok=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  JSONL_LOG = os.path.join(TRACES_DIR, "agent_log.jsonl")
26
 
27
  MODEL_NAME = os.environ.get("LLM_REPO", "LiquidAI/LFM2.5-350M")
 
20
  import fr24
21
  import liquid
22
 
23
+ _LOCAL_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "traces")
24
+
25
+ try:
26
+ # Attempt to use the local directory and prove it is writable
27
+ os.makedirs(_LOCAL_DIR, exist_ok=True)
28
+ _test_path = os.path.join(_LOCAL_DIR, ".write_test")
29
+ with open(_test_path, "w") as f:
30
+ f.write("ok")
31
+ os.remove(_test_path)
32
+ TRACES_DIR = _LOCAL_DIR
33
+ except (OSError, PermissionError):
34
+ # If Hugging Face locks the file system, fallback to /tmp
35
+ TRACES_DIR = "/tmp/traces"
36
+ os.makedirs(TRACES_DIR, exist_ok=True)
37
+
38
  JSONL_LOG = os.path.join(TRACES_DIR, "agent_log.jsonl")
39
 
40
  MODEL_NAME = os.environ.get("LLM_REPO", "LiquidAI/LFM2.5-350M")