Skip to content

Commit d726481

Browse files
authored
Documentation for set_session_options (#137)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [x] I have added tests for my changes - [x] I have updated the documentation or added new documentation as needed - [x] I have read and agree to the [Contributor License Agreement](../CLA.md) --------- Co-authored-by: KopekC <[email protected]>
1 parent 0f8b288 commit d726481

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/building-with-codegen/calling-out-to-llms.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,10 @@ method.edit(new_impl)
225225
```python
226226
codebase.set_session_options(max_ai_requests=200)
227227
```
228+
<
229+
Note>
230+
You can also use `codebase.set_session_options` to increase the execution time and the number of operations allowed in a session. This is useful for handling larger tasks or more complex operations that require additional resources. Adjust the `max_seconds` and `max_transactions` parameters to suit your needs:
231+
```python
232+
codebase.set_session_options(max_seconds=300, max_transactions=500)
233+
```
234+
</Note>

src/codegen/sdk/core/codebase.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,21 @@ def find_by_span(self, span: Span) -> list[Editable]:
11171117
return []
11181118

11191119
def set_session_options(self, **kwargs: Unpack[SessionOptions]) -> None:
1120-
"""Sets the Session options for the current codebase."""
1120+
"""Sets the session options for the current codebase.
1121+
1122+
This method updates the session options with the provided keyword arguments and
1123+
configures the transaction manager accordingly. It sets the maximum number of
1124+
transactions and resets the stopwatch based on the updated session options.
1125+
1126+
Args:
1127+
**kwargs: Keyword arguments representing the session options to update.
1128+
- max_transactions (int, optional): The maximum number of transactions
1129+
allowed in a session.
1130+
- max_seconds (int, optional): The maximum duration in seconds for a session
1131+
before it times out.
1132+
- max_ai_requests (int, optional): The maximum number of AI requests
1133+
allowed in a session.
1134+
"""
11211135
self.G.session_options = self.G.session_options.model_copy(update=kwargs)
11221136
self.G.transaction_manager.set_max_transactions(self.G.session_options.max_transactions)
11231137
self.G.transaction_manager.reset_stopwatch(self.G.session_options.max_seconds)

0 commit comments

Comments
 (0)