feat: Integrate Toonify library for token-efficient responses#67
Merged
VinciGit00 merged 3 commits intomainfrom Nov 28, 2025
Merged
feat: Integrate Toonify library for token-efficient responses#67VinciGit00 merged 3 commits intomainfrom
VinciGit00 merged 3 commits intomainfrom
Conversation
- Add toonify>=1.0.0 as dependency in pyproject.toml - Create toon_converter utility module for TOON format conversion - Add return_toon parameter to all scraping methods in both sync and async clients - Include TOON support in: smartscraper, searchscraper, crawl, agenticscraper, markdownify, and scrape - Add comprehensive examples (sync and async) demonstrating TOON usage - Create detailed TOON_INTEGRATION.md documentation - TOON format reduces token usage by 30-60% compared to JSON - Tested with API key sgai-e32215fb-5940-400f-91ea-30af5f35e0c9
- Replace hardcoded API key with environment variable instructions - Update examples to use SGAI_API_KEY environment variable - Remove API key reference from documentation - Users should set their own API key via environment variables
Dependency ReviewThe following issues were found:
License Issuesscrapegraph-py/pyproject.toml
OpenSSF Scorecard
Scanned Files
|
|
π This PR is included in version 1.44.0 π The release is available on:
Your semantic-release bot π¦π |
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.
π¨ TOON Format Integration
This PR integrates the Toonify library to enable token-efficient responses using TOON (Token-Oriented Object Notation) format, achieving 30-60% reduction in token usage compared to JSON.
π Changes
Core Implementation
toonify>=1.0.0dependency topyproject.tomltoon_converter.pyutility module for TOON conversionreturn_toonparameter to all scraping methods (sync & async)Supported Methods
All the following methods now support
return_toon=True:smartscraper()/get_smartscraper()searchscraper()/get_searchscraper()crawl()/get_crawl()agenticscraper()/get_agenticscraper()markdownify()/get_markdownify()scrape()/get_scrape()Documentation & Examples
TOON_INTEGRATION.mddocumentationexamples/toon_example.pyexamples/toon_async_example.pyπ‘ Benefits
π Example Comparison
JSON Format (verbose):
{ "request_id": "f424487d-6e2b-4361-824f-9c54f8fe0d8e", "status": "completed", "website_url": "https://example.com", "result": { "page_title": "Example Domain", "main_heading": "Example Domain" } }TOON Format (compact):
π Usage
β Testing
π Files Changed
pyproject.toml,client.py,async_client.pytoon_converter.py,TOON_INTEGRATION.md, example filesTotal: 7 files changed, 764 insertions(+), 58 deletions(-)
π Related