Skip to content

Commit 29d1a70

Browse files
committed
📑 fix file paths
1 parent c86b153 commit 29d1a70

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

codeinterpreterapi/schema/file.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class File(BaseModel):
99

1010
@classmethod
1111
def from_path(cls, path: str):
12+
if not path.startswith("/"):
13+
path = f"./{path}"
1214
with open(path, "rb") as f:
1315
path = path.split("/")[-1]
1416
return cls(name=path, content=f.read())
@@ -33,6 +35,8 @@ async def afrom_url(cls, url: str):
3335
return cls(name=url.split("/")[-1], content=await r.read())
3436

3537
def save(self, path: str):
38+
if not path.startswith("/"):
39+
path = f"./{path}"
3640
with open(path, "wb") as f:
3741
f.write(self.content)
3842

0 commit comments

Comments
 (0)