Repository navigation
docs(examples): add Ollama SmartScraper schema example with num_ctx - #1186
Open
sakshamagrawal364-max wants to merge 2 commits into
Open
sakshamagrawal364-max wants to merge 2 commits into
sakshamagrawal364-max wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4sQj3sEyWi9Ke2aciLBFd
Ollama's default context window truncates whole web pages, which can cut off the model's JSON answer. The example now lives with the other Ollama SmartScraper examples, sets num_ctx alongside model_tokens and uses a Pydantic schema, runnable fully locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4sQj3sEyWi9Ke2aciLBFd
This branch has not been deployed
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.
Summary
Adds
examples/smart_scraper_graph/ollama/smart_scraper_schema_ollama_num_ctx.py, a SmartScraper + Pydantic schema example on a local Ollama model that sets Ollama'snum_ctxalongsidemodel_tokens.Ollama runs models with a small context window by default. When I first ran SmartScraper on a full listing page with
llama3.2:3band nonum_ctx(and no schema), the JSON answer came back cut off after the first item. Withnum_ctx: 8192and a schema, the same page returns every item. None of the existing Ollama examples setnum_ctx, so this documents the setting where people will look for it.Only the one example file is added; no library code changes.
Testing
ruff check,black --check,isort --check-onlypass on the new file.llama3.2:3bon CPU: it returned all 20 books with title and price. GenerateAnswer took about 140 s on 4 CPU cores.🤖 Generated with Claude Code
https://claude.ai/code/session_01B4sQj3vVBgYiv6mcWmjmz8