Skip to content

Documentation for set_session_options #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/building-with-codegen/calling-out-to-llms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,10 @@ method.edit(new_impl)
```python
codebase.set_session_options(max_ai_requests=200)
```
<
Note>
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:
```python
codebase.set_session_options(max_seconds=300, max_transactions=500)
```
</Note>
16 changes: 15 additions & 1 deletion src/codegen/sdk/core/codebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,21 @@ def find_by_span(self, span: Span) -> list[Editable]:
return []

def set_session_options(self, **kwargs: Unpack[SessionOptions]) -> None:
"""Sets the Session options for the current codebase."""
"""Sets the session options for the current codebase.

This method updates the session options with the provided keyword arguments and
configures the transaction manager accordingly. It sets the maximum number of
transactions and resets the stopwatch based on the updated session options.

Args:
**kwargs: Keyword arguments representing the session options to update.
- max_transactions (int, optional): The maximum number of transactions
allowed in a session.
- max_seconds (int, optional): The maximum duration in seconds for a session
before it times out.
- max_ai_requests (int, optional): The maximum number of AI requests
allowed in a session.
"""
self.G.session_options = self.G.session_options.model_copy(update=kwargs)
self.G.transaction_manager.set_max_transactions(self.G.session_options.max_transactions)
self.G.transaction_manager.reset_stopwatch(self.G.session_options.max_seconds)
Expand Down