-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(chat): add --timeout option to ask command #260
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -102,6 +102,13 @@ def register_chat_commands(cli): | |||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| @click.option("--save-as-note", is_flag=True, help="Save response as a note") | ||||||||||||||||||||||||||||||
| @click.option("--note-title", default=None, help="Note title (use with --save-as-note)") | ||||||||||||||||||||||||||||||
| @click.option( | ||||||||||||||||||||||||||||||
| "--timeout", | ||||||||||||||||||||||||||||||
| default=120, | ||||||||||||||||||||||||||||||
| type=int, | ||||||||||||||||||||||||||||||
| show_default=True, | ||||||||||||||||||||||||||||||
| help="Request timeout in seconds. Increase for long prompts (default: 120).", | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
Comment on lines
+105
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
Answer: Sources: Validate
Proposed fix `@click.option`(
"--timeout",
default=120,
- type=int,
+ type=click.IntRange(min=1),
show_default=True,
- help="Request timeout in seconds. Increase for long prompts (default: 120).",
+ help="Request timeout in seconds. Increase for long prompts.",
)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| @with_client | ||||||||||||||||||||||||||||||
| def ask_cmd( | ||||||||||||||||||||||||||||||
| ctx, | ||||||||||||||||||||||||||||||
|
|
@@ -112,6 +119,7 @@ def ask_cmd( | |||||||||||||||||||||||||||||
| json_output, | ||||||||||||||||||||||||||||||
| save_as_note, | ||||||||||||||||||||||||||||||
| note_title, | ||||||||||||||||||||||||||||||
| timeout, | ||||||||||||||||||||||||||||||
| client_auth, | ||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||
| """Ask a notebook a question. | ||||||||||||||||||||||||||||||
|
|
@@ -131,7 +139,7 @@ def ask_cmd( | |||||||||||||||||||||||||||||
| nb_id = require_notebook(notebook_id) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| async def _run(): | ||||||||||||||||||||||||||||||
| async with NotebookLMClient(client_auth) as client: | ||||||||||||||||||||||||||||||
| async with NotebookLMClient(client_auth, timeout=float(timeout)) as client: | ||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the general rules for network clients, it is recommended to use granular timeouts. A single float value sets the same timeout for connection and reading. Using a shorter connect timeout (e.g., 10s) while allowing a longer read timeout improves resilience by failing fast on connection issues while still accommodating slow responses. Note that the
Suggested change
References
|
||||||||||||||||||||||||||||||
| nb_id_resolved = await resolve_notebook_id(client, nb_id) | ||||||||||||||||||||||||||||||
| effective_conv_id = _determine_conversation_id( | ||||||||||||||||||||||||||||||
| explicit_conversation_id=conversation_id, | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text contains a redundant default value since
show_default=Trueis enabled, which will cause Click to append[default: 120]automatically. Additionally, the timeout should be validated to ensure it is a positive value to avoid potential issues with the underlying network client.