diff options
Diffstat (limited to 'autogpts/autogpt/autogpt/models/context_item.py')
-rw-r--r-- | autogpts/autogpt/autogpt/models/context_item.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/autogpts/autogpt/autogpt/models/context_item.py b/autogpts/autogpt/autogpt/models/context_item.py index 17a2a0b8e..a669bdcc8 100644 --- a/autogpts/autogpt/autogpt/models/context_item.py +++ b/autogpts/autogpt/autogpt/models/context_item.py @@ -1,11 +1,12 @@ import logging +import os.path from abc import ABC, abstractmethod from pathlib import Path from typing import Optional from pydantic import BaseModel, Field -from autogpt.commands.file_operations_utils import read_textual_file +from autogpt.commands.file_operations_utils import decode_textual_file logger = logging.getLogger(__name__) @@ -56,7 +57,9 @@ class FileContextItem(BaseModel, ContextItem): @property def content(self) -> str: - return read_textual_file(self.file_path, logger) + # TODO: use workspace.open_file() + with open(self.file_path, "rb") as file: + return decode_textual_file(file, os.path.splitext(file.name)[1], logger) class FolderContextItem(BaseModel, ContextItem): |