Modernize, refine, and standardize the notebook collection - #219
Open
sis0k0 wants to merge 26 commits into
Open
Conversation
Collaborator
|
Ran a code review agent on the PR and spot-checked its outputs and recommendations. Seemed sane to me. Here at it's findings: PR-219-review.md |
…ll order ag2 1.0.2 dropped the retrievechat-mongodb extra and the autogen namespace, so the notebook failed on both %pip install and the subsequent autogen imports. Pin ag2<1.0 with the openai extra (needed by autogen.oai.client but not pulled in transitively), and move the install cell above the dotenv/pymongo/openai imports it was previously running after.
…niques notebook SearchIndexModel was migrated to new-style vector field syntax but never got type="vectorSearch", so Atlas rejects the index creation with "Attribute mappings missing." The surrounding try/except only printed the error and let execution continue, masking the failure until every later $vectorSearch stage broke with no obvious cause. Now the type is set and the exception propagates instead of being swallowed.
…sion section max_tokens=256 left no budget for gpt-oss-20b's reasoning output, so both agent invocations returned an empty string, the empty answer got written into MongoDB chat history, and the knowledge_base tool was never reached in the second turn. Raise max_tokens to 4096 and fail loudly instead of silently returning '' when a model call comes back empty. Also: retitle the "compression retriever" section to describe what it actually does (compression is exposed as an explicit tool, not a wrapping retriever) instead of building an unused variable; restore the gpt2 pin on PromptCompressor so it doesn't fall back to a ~13GB default model on CPU; drop the unreachable device_map except branch; correct the prose naming the wrong Fireworks model; pin the fast-moving langchain packages instead of resolving to latest. Stale committed outputs from the max_tokens=256 bug (leaked harmony markers, empty answers) are cleared rather than left in, since they can't be re-executed without live API credentials in this session.
…ynced docs MIN_FOREIGN_RESULT_SCORE was set to 0.0, making the score < threshold check unreachable for any non-negative Tavily score, so every foreign search result got embedded and written to working_memory regardless of relevance. Restore the 0.5 threshold. Also fix markdown/code desync left by an earlier reshuffle: move the agent demo call and its wrap-up back next to the agent definition, move the dataset-loading narrative to actually precede the dataset loading code, remove a verbatim duplicate agent-definition cell, and restore the missing "Step 3: Data Loading and Preparation" heading (the notebook was jumping from Step 2 straight to Step 4). Pin pydantic-ai instead of resolving to latest.
…scaffolding ANTHROPIC_API_KEY was required via get_or_prompt_env and raised OSError on an empty prompt, but the notebook actually runs on ChatOpenAI(model="gpt-5-mini") — ChatAnthropic is commented out. This blocked anyone without an Anthropic account from getting past that cell. Drop the requirement and the unused langchain_anthropic install; fix the invalid commented-out model id (claude-sonnet-4 -> claude-sonnet-4-0) and note that temperature=0 is silently ignored by langchain-openai for gpt-5-mini. Also remove leftover debug scaffolding: a final cell that made an extra billed LLM call to inspect graph output shape (with its committed output), and max_retries=1 which made the retry branch dead code. Pin the fast-moving langchain/langgraph packages instead of resolving to latest.
A prior dead-link pass mistook pandas' repr ellipsis truncation
(".../access/manage-t...") for a broken link and rewrote it to a URL
that doesn't match its own row label. Revert the committed outputs
back to what the code actually produced rather than keeping the
fabricated substitutions.
- Fix glued H1 headings in 5 notebooks where the heading was appended
to the Colab badge markdown line with no trailing newline, so it
rendered as literal text instead of a heading.
- Remove the templated filler problem statement ("This notebook
solves the problem of building and evaluating <filename> workflows
using MongoDB-backed retrieval and agent orchestration.") generated
from the filename in 11 notebooks, rather than leaving generic
boilerplate in place of a real description.
_search_arxiv created a brand-new arxiv.Client() on every call, so its built-in "no more than one request every 3 seconds" throttling was reset each time and never actually applied between calls. Once the earlier max_tokens fix let the agent make several arXiv searches within one turn, the back-to-back requests weren't spaced out and arXiv started returning HTTP 429. Share a single Client instance across calls so its rate limiting works as intended.
Member
Author
|
@ajosh0504 , thank you for the review! I addressed the comments in the latest commits. |
Collaborator
|
@sis0k0 Reran the code review agent. Few more minor issues that result in failures when running the notebook outside of Colab:
Everything else looks good! |
Both notebooks call nest_asyncio.apply() but never installed the package, relying on it being preinstalled in Colab. Add it to the pip install cell so the notebooks run outside Colab too.
Several install cells had redundant/duplicated flags from a prior mechanical edit, e.g. "-U -q -U langgraph" and "-U -q -Uq openai". Dedupe them down to a single -U -q.
Member
Author
|
@ajosh0504 , good catch! Cleaned up the doubled install flags and add the missing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR is a broad maintenance and quality pass over the notebook collection, focused on
notebooks/agents/. It normalizes install commands, cleans up cell outputs, adds "Open in Colab" buttons, standardizes environment-variable handling, migrates notebooks to the current Atlas vector index syntax, fixes dead links, and substantively refines several individual agent notebooks. 35 files changed.Deeply refined notebooks
Substantive content and narrative rewrites, not just mechanical edits:
Standardized environment-variable handling
The five modernized notebooks now load secrets consistently:
python-dotenvto the install cell and callload_dotenv()so variables defined in a local.envfile are read automatically.get_or_prompt_env(var_name, prompt_text)helper that returns the value from the environment (.envor already-set) when present, and otherwise falls back to agetpassprompt, raising a clearEnvironmentErrorif left empty.OPENAI_API_KEY,FIREWORKS_API_KEY, andMONGODB_URIare resolved through this helper instead of being hardcoded or prompted ad hoc, so the notebooks run non-interactively when a.envfile is present and prompt gracefully when it is not.Other standardized conventions
Applied consistently across the agent notebooks:
!pipwith%pip, then normalized all installs to%pip install -U -qfor quiet, up-to-date installs.agents/,rag/,evals/, andpartners/.Modernization
Housekeeping
.envfiles out of version control).