Aller directement au contenu principal

openhands.events.observation.files

FileReadObservation Objects

@dataclass
class FileReadObservation(Observation)

This data class represents the content of a file.

FileWriteObservation Objects

@dataclass
class FileWriteObservation(Observation)

This data class represents a file write operation

FileEditObservation Objects

@dataclass
class FileEditObservation(Observation)

This data class represents a file edit operation

get_edit_groups

def get_edit_groups(n_context_lines: int = 2) -> list[dict[str, list[str]]]

Get the edit groups of the file edit.

visualize_diff

def visualize_diff(n_context_lines: int = 2,
change_applied: bool = True) -> str

Visualize the diff of the file edit.

Instead of showing the diff line by line, this function shows each hunk of changes as a separate entity.

Arguments:

  • n_context_lines - The number of lines of context to show before and after the changes.
  • change_applied - Whether the changes are applied to the file. If true, the file have been modified. If not, the file is not modified (due to linting errors).