Skip to content

docs(examples): add Ollama SmartScraper schema example with num_ctx - #1186

Open
sakshamagrawal364-max wants to merge 2 commits into
ScrapeGraphAI:pre/betafrom
sakshamagrawal364-max:docs/ollama-local-example
Open

sakshamagrawal364-max wants to merge 2 commits into
ScrapeGraphAI:pre/betafrom
sakshamagrawal364-max:docs/ollama-local-example

Conversation

@sakshamagrawal364-max

@sakshamagrawal364-max sakshamagrawal364-max commented Nov 22, 2026 •

Copy link
Copy Markdown

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's num_ctx alongside model_tokens.

Ollama runs models with a small context window by default. When I first ran SmartScraper on a full listing page with llama3.2:3b and no num_ctx (and no schema), the JSON answer came back cut off after the first item. With num_ctx: 8192 and a schema, the same page returns every item. None of the existing Ollama examples set num_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-only pass on the new file.
  • Ran the example end to end against https://books.toscrape.com/ with Ollama 0.40.17 and llama3.2:3b on CPU: it returned all 20 books with title and price. GenerateAnswer took about 140 s on 4 CPU cores.
  • I did not run the full test suite, since the change is an example file only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B4sQj3vVBgYiv6mcWmjmz8

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
@sakshamagrawal364-max sakshamagrawal364-max changed the title Docs/ollama local example docs(examples): add Ollama SmartScraper schema example with num_ctx Nov 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants