|
11 | 11 | import time |
12 | 12 | from typing import Match, Sequence, override |
13 | 13 |
|
14 | | -from .bots import Bot, OperationHook, Toolbox |
| 14 | +from .bots import Bot, Goal, OperationHook, Toolbox |
15 | 15 | from .common import random_id |
16 | 16 | from .prompt import PromptRenderer, TemplatedPrompt |
17 | 17 | from .store import Store, sql |
@@ -85,7 +85,7 @@ def _write(self, path: PurePosixPath, contents: str) -> None: |
85 | 85 | f"{mode},{sha},{path}", add=True, cacheinfo=True |
86 | 86 | ) |
87 | 87 |
|
88 | | - def update_index(self) -> None: |
| 88 | + def trim_index(self) -> None: |
89 | 89 | diff = self._repo.git.diff(name_only=True, cached=True) |
90 | 90 | untouched = [ |
91 | 91 | path |
@@ -125,9 +125,10 @@ def generate_draft( |
125 | 125 | self, |
126 | 126 | prompt: str | TemplatedPrompt, |
127 | 127 | bot: Bot, |
128 | | - checkout=False, |
129 | | - reset=False, |
130 | | - sync=False, |
| 128 | + checkout: bool = False, |
| 129 | + reset: bool = False, |
| 130 | + sync: bool = False, |
| 131 | + timeout: float | None = None, |
131 | 132 | ) -> None: |
132 | 133 | if isinstance(prompt, str) and not prompt.strip(): |
133 | 134 | raise ValueError("Empty prompt") |
@@ -159,11 +160,12 @@ def generate_draft( |
159 | 160 | ) |
160 | 161 |
|
161 | 162 | start_time = time.perf_counter() |
| 163 | + goal = Goal(prompt_contents, timeout) |
162 | 164 | toolbox = _Toolbox(self._repo, self._operation_hook) |
163 | | - action = bot.act(prompt_contents, toolbox) |
| 165 | + action = bot.act(goal, toolbox) |
164 | 166 | end_time = time.perf_counter() |
165 | 167 |
|
166 | | - toolbox.update_index() |
| 168 | + toolbox.trim_index() |
167 | 169 | title = action.title |
168 | 170 | if not title: |
169 | 171 | title = _default_title(prompt_contents) |
|
0 commit comments