-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
73 lines (60 loc) · 1.51 KB
/
Copy pathtypes.py
File metadata and controls
73 lines (60 loc) · 1.51 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from __future__ import annotations as _annotations
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Literal, TypeAlias
__all__ = (
"RawToolInput",
"ToolContent",
"ToolContentDiff",
"ToolContentText",
"ToolKind",
"ToolProjection",
"ToolStatus",
"TurnStopReason",
"TurnResult",
)
RawToolInput: TypeAlias = Mapping[str, object]
ToolKind: TypeAlias = Literal[
"read",
"edit",
"delete",
"move",
"search",
"execute",
"think",
"fetch",
"switch_mode",
"other",
]
ToolStatus: TypeAlias = Literal["pending", "completed", "failed"]
TurnStopReason: TypeAlias = Literal[
"end_turn",
"max_tokens",
"max_turn_requests",
"refusal",
"cancelled",
]
@dataclass(frozen=True, slots=True, kw_only=True)
class ToolContentText:
text: str
@dataclass(frozen=True, slots=True, kw_only=True)
class ToolContentDiff:
path: str
new_text: str
old_text: str | None = None
ToolContent: TypeAlias = ToolContentText | ToolContentDiff
@dataclass(frozen=True, slots=True, kw_only=True)
class ToolProjection:
tool_call_id: str
title: str
kind: ToolKind
raw_input: RawToolInput
raw_output: str
locations: tuple[str, ...] = ()
content: tuple[ToolContent, ...] = ()
status: ToolStatus = "completed"
@dataclass(frozen=True, slots=True, kw_only=True)
class TurnResult:
response_text: str
stop_reason: TurnStopReason = "end_turn"
tool_projections: tuple[ToolProjection, ...] = ()