Skip to content

Commit ae1b52a

Browse files
CopilotTomeHirata
andcommitted
Address code review feedback: Fix comments and error messages
Co-authored-by: TomeHirata <[email protected]>
1 parent dc4b402 commit ae1b52a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dspy/predict/react.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ def _call_with_potential_trajectory_truncation(self, module, trajectory, **input
155155
try:
156156
trajectory = self.truncate_trajectory(trajectory)
157157
except ValueError:
158-
# Cannot truncate further, re-raise as a clear error
158+
# Cannot truncate further, raise a clear error
159159
raise ValueError(
160160
"The context window was exceeded and the trajectory could not be truncated further."
161-
)
161+
) from None
162162
raise ValueError(
163-
"The context window was exceeded after 3 attempts to truncate the trajectory."
163+
"The context window was exceeded even after 3 attempts to truncate the trajectory."
164164
)
165165

166166
async def _async_call_with_potential_trajectory_truncation(self, module, trajectory, **input_args):
@@ -175,12 +175,12 @@ async def _async_call_with_potential_trajectory_truncation(self, module, traject
175175
try:
176176
trajectory = self.truncate_trajectory(trajectory)
177177
except ValueError:
178-
# Cannot truncate further, re-raise as a clear error
178+
# Cannot truncate further, raise a clear error
179179
raise ValueError(
180180
"The context window was exceeded and the trajectory could not be truncated further."
181-
)
181+
) from None
182182
raise ValueError(
183-
"The context window was exceeded after 3 attempts to truncate the trajectory."
183+
"The context window was exceeded even after 3 attempts to truncate the trajectory."
184184
)
185185

186186
def truncate_trajectory(self, trajectory):

0 commit comments

Comments
 (0)