mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: handle UnicodeDecodeError when loading skills in ADK
PiperOrigin-RevId: 869956988
This commit is contained in:
committed by
Copybara-Service
parent
d56cb4142c
commit
3fbc27fa4d
@@ -36,9 +36,15 @@ def _load_dir(directory: pathlib.Path) -> dict[str, str]:
|
||||
files = {}
|
||||
if directory.exists() and directory.is_dir():
|
||||
for file_path in directory.rglob("*"):
|
||||
if "__pycache__" in file_path.parts:
|
||||
continue
|
||||
if file_path.is_file():
|
||||
relative_path = file_path.relative_to(directory)
|
||||
try:
|
||||
files[str(relative_path)] = file_path.read_text(encoding="utf-8")
|
||||
except UnicodeDecodeError:
|
||||
# Binary files or non-UTF-8 files are skipped for text content.
|
||||
continue
|
||||
return files
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user