Tools for data extraction from the web with AI
Project description
truffles 🍫
A python framework that extends playwright with language model tools (page.tools) for web automation and data extraction.
Note: Currently only supported with async playwright.
An open-source framework that extends Playwright with AI capabilities for web automation and data extraction. truffles implements global caching of AI interactions to improve efficiency across the community.
page = truffles.wrap(browser)
# go to your favorite website
page.goto("https://example.com/products")
# auto list detection
items = await page.tools.get_main_list()
# json structure from locator
products = await items.tools.to_structure(
{
"title": str,
"price": float
}
)
Tools
The .tools attribute is a namespace for all added tools, cleanly separating them from the page object.
Implemented Tools
The repo contains a few tools that implement common patterns for web automation, that are powered by LLMs and have been proven to work well in the wild. Currently, the following tools are implemented or in the works:
- Automatic List Detection
- Autonomous Pagination (under development)
- Intelligent & Safe Data Extraction (under development)
Context Manager
The ContextManager is internally used by tools to store and retrieve reusable context in automations. This greatly reduces the amount of LLM calls required.
In the future, a publicly shared context will be available as an optional feature to further reduce costs.
The ContextManager operates mostly in the background and is automatically initialized when truffles.astart is called, but it can also be initialized and accessed manually.
from truffles.context import ContextManager
ContextManager.initialize()
Tool Extensibility
The framework is designed to be easily extensible. You can implement your own tools by inheriting from BaseTool and implementing the execute method.
from truffles.tools import BaseTool
class MyTool(BaseTool):
def execute(self, *args, **kwargs):
# your code here
pass
Technical Details
- Asynchronous architecture
- Built to seamlessly extend existing playwright projects
- Out-of-the-box support for langchain supported models
A more extensive setup example
from playwright.async_api import async_playwright
import truffles
p = await async_playwright().start()
browser = await p.chromium.launch()
# initializes the default model and context manager
await truffles.astart()
page = truffles.wrap(browser)
# your code here
Project Status
Current development focuses on:
- Improving current tools
- Extending the functionality
- Optimizing performance of
ContextManager
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file truffles-0.1.0.tar.gz.
File metadata
- Download URL: truffles-0.1.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d5c8974d9a02907fd3e469c480ebbab0835a9f0576a986b40fde95168a96f1
|
|
| MD5 |
5dce8f6527f6a4c973de1370383169fc
|
|
| BLAKE2b-256 |
60c6a56a615196d38486bfb242a15bf95a5c28d9e6cdf8628cb648c15850d9bf
|
Provenance
The following attestation bundles were made for truffles-0.1.0.tar.gz:
Publisher:
release-please.yml on shoco-team/truffles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truffles-0.1.0.tar.gz -
Subject digest:
40d5c8974d9a02907fd3e469c480ebbab0835a9f0576a986b40fde95168a96f1 - Sigstore transparency entry: 154059692
- Sigstore integration time:
-
Permalink:
shoco-team/truffles@7735cd44c2857f09c3b7a75e9337667a2ea31bd4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shoco-team
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@7735cd44c2857f09c3b7a75e9337667a2ea31bd4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file truffles-0.1.0-py3-none-any.whl.
File metadata
- Download URL: truffles-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c3c3317e36912c4aa69f55d3875d307e99755b8372ef8a470dd852992575363
|
|
| MD5 |
43d3c227baaedeee6207f8a4dfdcb6ce
|
|
| BLAKE2b-256 |
cccc751ccc4c3aa57c45fe7804add1d43a00606c13bd510cd18f27cb73c42ac1
|
Provenance
The following attestation bundles were made for truffles-0.1.0-py3-none-any.whl:
Publisher:
release-please.yml on shoco-team/truffles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truffles-0.1.0-py3-none-any.whl -
Subject digest:
6c3c3317e36912c4aa69f55d3875d307e99755b8372ef8a470dd852992575363 - Sigstore transparency entry: 154059693
- Sigstore integration time:
-
Permalink:
shoco-team/truffles@7735cd44c2857f09c3b7a75e9337667a2ea31bd4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shoco-team
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@7735cd44c2857f09c3b7a75e9337667a2ea31bd4 -
Trigger Event:
push
-
Statement type: