forked from openai/openai-agents-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.py
More file actions
48 lines (33 loc) · 1.34 KB
/
Copy patheditor.py
File metadata and controls
48 lines (33 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import annotations
import sys
from dataclasses import dataclass
from typing import Literal, Protocol, runtime_checkable
from .run_context import RunContextWrapper
from .util._types import MaybeAwaitable
ApplyPatchOperationType = Literal["create_file", "update_file", "delete_file"]
_DATACLASS_KWARGS = {"slots": True} if sys.version_info >= (3, 10) else {}
@dataclass(**_DATACLASS_KWARGS)
class ApplyPatchOperation:
"""Represents a single apply_patch editor operation requested by the model."""
type: ApplyPatchOperationType
path: str
diff: str | None = None
ctx_wrapper: RunContextWrapper | None = None
move_to: str | None = None
@dataclass(**_DATACLASS_KWARGS)
class ApplyPatchResult:
"""Optional metadata returned by editor operations."""
status: Literal["completed", "failed"] | None = None
output: str | None = None
@runtime_checkable
class ApplyPatchEditor(Protocol):
"""Host-defined editor that applies diffs on disk."""
def create_file(
self, operation: ApplyPatchOperation
) -> MaybeAwaitable[ApplyPatchResult | str | None]: ...
def update_file(
self, operation: ApplyPatchOperation
) -> MaybeAwaitable[ApplyPatchResult | str | None]: ...
def delete_file(
self, operation: ApplyPatchOperation
) -> MaybeAwaitable[ApplyPatchResult | str | None]: ...