Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.3%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: BilalG1
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage: https://tarsier.vercel.app
  • Size: 2.09 GB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 5
  • Releases: 0
Created almost 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation Security Support

README.md

Tarsier Monkey

Vision utilities for web interaction agents

Python Version

Main site      Twitter      Discord

Tarsier

If you've tried using an LLM to automate web interactions, you've probably run into questions like:

  • How should you feed the webpage to an LLM? (e.g. HTML, Accessibility Tree, Screenshot)
  • How do you map LLM responses back to web elements?
  • How can you inform a text-only LLM about the page's visual structure?

At Reworkd, we iterated on all these problems across tens of thousands of real web tasks to build a powerful perception system for web agents... Tarsier! In the video below, we use Tarsier to provide webpage perception for a minimalistic GPT-4 LangChain web agent.

https://github.com/reworkd/tarsier/assets/50181239/af12beda-89b5-4add-b888-d780b353304b

How does it work?

Tarsier visually tags interactable elements on a page via brackets + an ID e.g. [23]. In doing this, we provide a mapping between elements and IDs for an LLM to take actions upon (e.g. CLICK [23]). We define interactable elements as buttons, links, or input fields that are visible on the page; Tarsier can also tag all textual elements if you pass tag_text_elements=True.

Furthermore, we've developed an OCR algorithm to convert a page screenshot into a whitespace-structured string (almost like ASCII art) that an LLM even without vision can understand. Since current vision-language models still lack fine-grained representations needed for web interaction tasks, this is critical. On our internal benchmarks, unimodal GPT-4 + Tarsier-Text beats GPT-4V + Tarsier-Screenshot by 10-20%!

| Tagged Screenshot | Tagged Text Representation | | :-------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------: | | tagged | tagged |

Installation

shell pip install tarsier

Usage

Visit our cookbook for agent examples using Tarsier:

We currently support 2 OCR engines: Google Vision and Microsoft Azure. To create service account credentials for Google, follow the instructions on this SO answer https://stackoverflow.com/a/46290808/1780891

The credentials for Microsoft Azure are stored as a simple JSON consisting of an API key and an endpoint

json { "key": "<enter_your_api_key>", "endpoint": "<enter_your_api_endpoint>" }

These values can be found in the keys and endpoint section of the computer vision resource. See the instructions at https://learn.microsoft.com/en-us/answers/questions/854952/dont-find-your-key-and-your-endpoint

Otherwise, basic Tarsier usage might look like the following:

```python import asyncio

from playwright.asyncapi import asyncplaywright from tarsier import Tarsier, GoogleVisionOCRService, MicrosoftAzureOCRService import json

def loadocrcredentials(jsonfilepath): with open(jsonfilepath) as f: credentials = json.load(f) return credentials

async def main(): # To create the service account key, follow the instructions on this SO answer https://stackoverflow.com/a/46290808/1780891

google_cloud_credentials = load_ocr_credentials('./google_service_acc_key.json')
#microsoft_azure_credentials = load_ocr_credentials('./microsoft_azure_credentials.json')

ocr_service = GoogleVisionOCRService(google_cloud_credentials)
#ocr_service = MicrosoftAzureOCRService(microsoft_azure_credentials)

tarsier = Tarsier(ocr_service)

async with async_playwright() as p:
    browser = await p.chromium.launch(headless=False)
    page = await browser.new_page()
    await page.goto("https://news.ycombinator.com")

    page_text, tag_to_xpath = await tarsier.page_to_text(page)

    print(tag_to_xpath)  # Mapping of tags to x_paths
    print(page_text)  # My Text representation of the page

if name == 'main': asyncio.run(main()) ```

Keep in mind that Tarsier tags different types of elements differently to help your LLM identify what actions are performable on each element. Specifically:

  • [#ID]: text-insertable fields (e.g. textarea, input with textual type)
  • [@ID]: hyperlinks (<a> tags)
  • [$ID]: other interactable elements (e.g. button, select)
  • [ID]: plain text (if you pass tag_text_elements=True)

Local Development

Setup

We have provided a handy setup script to get you up and running with Tarsier development.

shell ./script/setup.sh

If you modify any TypeScript files used by Tarsier, you'll need to execute the following command. This compiles the TypeScript into JavaScript, which can then be utilized in the Python package.

shell npm run build

Testing

We use pytest for testing. To run the tests, simply run:

shell poetry run pytest .

Linting

Prior to submitting a potential PR, please run the following to format your code:

shell ./script/format.sh

Supported OCR Services

Roadmap

  • [x] Add documentation and examples
  • [x] Clean up interfaces and add unit tests
  • [x] Launch
  • [x] Improve OCR text performance
  • [ ] Add options to customize tagging styling
  • [ ] Add support for other browsers drivers as necessary

Citations

bibtex @misc{reworkd2023tarsier, title = {Tarsier}, author = {Rohan Pandey and Adam Watkins and Asim Shrestha and Srijan Subedi}, year = {2023}, howpublished = {GitHub}, url = {https://github.com/reworkd/tarsier} }

Owner

  • Login: BilalG1
  • Kind: user

GitHub Events

Total
  • Delete event: 8
  • Issue comment event: 17
  • Pull request event: 17
  • Create event: 9
Last Year
  • Delete event: 8
  • Issue comment event: 17
  • Pull request event: 17
  • Create event: 9

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 29
  • Average time to close issues: N/A
  • Average time to close pull requests: 14 days
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 1.62
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 29
Past Year
  • Issues: 0
  • Pull requests: 29
  • Average time to close issues: N/A
  • Average time to close pull requests: 14 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 1.62
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 29
Top Authors
Issue Authors
  • dependabot[bot] (1)
Pull Request Authors
  • dependabot[bot] (49)
Top Labels
Issue Labels
dependencies (1)
Pull Request Labels
dependencies (49)

Dependencies

.github/workflows/python.yml actions
  • actions/checkout v4 composite
  • actions/setup-node v4 composite
  • actions/setup-python v5 composite
tarsier-service/docker-compose.yml docker
  • mysql 8.0
tarsier-service/service/Dockerfile docker
  • python 3.12-slim build
package-lock.json npm
  • @esbuild/android-arm 0.19.5 development
  • @esbuild/android-arm64 0.19.5 development
  • @esbuild/android-x64 0.19.5 development
  • @esbuild/darwin-arm64 0.19.5 development
  • @esbuild/darwin-x64 0.19.5 development
  • @esbuild/freebsd-arm64 0.19.5 development
  • @esbuild/freebsd-x64 0.19.5 development
  • @esbuild/linux-arm 0.19.5 development
  • @esbuild/linux-arm64 0.19.5 development
  • @esbuild/linux-ia32 0.19.5 development
  • @esbuild/linux-loong64 0.19.5 development
  • @esbuild/linux-mips64el 0.19.5 development
  • @esbuild/linux-ppc64 0.19.5 development
  • @esbuild/linux-riscv64 0.19.5 development
  • @esbuild/linux-s390x 0.19.5 development
  • @esbuild/linux-x64 0.19.5 development
  • @esbuild/netbsd-x64 0.19.5 development
  • @esbuild/openbsd-x64 0.19.5 development
  • @esbuild/sunos-x64 0.19.5 development
  • @esbuild/win32-arm64 0.19.5 development
  • @esbuild/win32-ia32 0.19.5 development
  • @esbuild/win32-x64 0.19.5 development
  • esbuild 0.19.5 development
  • prettier 3.1.0 development
  • typescript 5.2.2 development
package.json npm
  • esbuild ^0.19.5 development
  • prettier ^3.1.0 development
  • typescript ^5.2.2 development
tarsier-service/next/package-lock.json npm
  • 184 dependencies
tarsier-service/next/package.json npm
  • @types/node ^20 development
  • @types/react ^18 development
  • @types/react-dom ^18 development
  • postcss ^8 development
  • tailwindcss ^3.4.1 development
  • typescript ^5 development
  • @propelauth/react ^2.0.22
  • @radix-ui/react-dialog ^1.1.1
  • @radix-ui/react-slot ^1.1.0
  • @radix-ui/react-toast ^1.2.1
  • @stripe/react-stripe-js ^2.8.0
  • @stripe/stripe-js ^4.3.0
  • class-variance-authority ^0.7.0
  • clsx ^2.1.1
  • lucide-react ^0.428.0
  • next 14.2.5
  • react ^18
  • react-dom ^18
  • tailwind-merge ^2.5.2
  • tailwindcss-animate ^1.0.7
poetry.lock pypi
  • attrs 23.2.0
  • azure-ai-vision-imageanalysis 1.0.0b3
  • azure-core 1.30.2
  • cachetools 5.4.0
  • certifi 2024.7.4
  • cffi 1.16.0
  • charset-normalizer 3.3.2
  • colorama 0.4.6
  • coverage 7.6.0
  • google-api-core 2.19.1
  • google-auth 2.32.0
  • google-cloud-vision 3.7.3
  • googleapis-common-protos 1.63.2
  • greenlet 3.0.3
  • grpcio 1.65.1
  • grpcio-status 1.65.1
  • h11 0.14.0
  • idna 3.7
  • iniconfig 2.0.0
  • isodate 0.6.1
  • mypy 1.11.0
  • mypy-extensions 1.0.0
  • nest-asyncio 1.6.0
  • outcome 1.3.0.post0
  • packaging 24.1
  • playwright 1.45.1
  • pluggy 1.5.0
  • proto-plus 1.24.0
  • protobuf 5.27.2
  • pyasn1 0.6.0
  • pyasn1-modules 0.4.0
  • pycparser 2.22
  • pyee 11.1.0
  • pysocks 1.7.1
  • pytest 8.3.2
  • pytest-asyncio 0.23.8
  • pytest-base-url 2.1.0
  • pytest-cov 5.0.0
  • pytest-mock 3.14.0
  • pytest-playwright 0.5.1
  • python-dotenv 1.0.1
  • python-slugify 8.0.4
  • requests 2.32.3
  • rsa 4.9
  • ruff 0.5.6
  • selenium 4.23.1
  • six 1.16.0
  • sniffio 1.3.1
  • sortedcontainers 2.4.0
  • text-unidecode 1.3
  • trio 0.26.0
  • trio-websocket 0.11.1
  • typing-extensions 4.12.2
  • urllib3 2.2.2
  • webdriver-manager 4.0.2
  • websocket-client 1.8.0
  • wsproto 1.2.0
pyproject.toml pypi
  • mypy ^1.10.0 develop
  • ruff >=0.4.8,<0.6.0 develop
  • azure-ai-vision-imageanalysis ^1.0.0b2
  • google-cloud-vision ^3.7.2
  • playwright ^1.44.0
  • python ^3.11
  • selenium ^4.21.0
  • nest-asyncio ^1.6.0 test
  • pytest >=7.4.3,<9.0.0 test
  • pytest-asyncio >=0.21.2,<0.24.0 test
  • pytest-cov >=4.1,<6.0 test
  • pytest-mock ^3.14.0 test
  • pytest-playwright >=0.4.4,<0.6.0 test
  • webdriver-manager ^4.0.1 test
tarsier-service/service/poetry.lock pypi
  • annotated-types 0.7.0
  • anyio 4.4.0
  • attrs 24.2.0
  • azure-ai-vision-imageanalysis 1.0.0b3
  • azure-core 1.30.2
  • cachetools 5.5.0
  • certifi 2024.7.4
  • cffi 1.17.0
  • charset-normalizer 3.3.2
  • click 8.1.7
  • colorama 0.4.6
  • cryptography 43.0.0
  • distro 1.9.0
  • dnspython 2.6.1
  • email-validator 2.2.0
  • fastapi 0.112.1
  • fastapi-cli 0.0.5
  • google-api-core 2.19.1
  • google-auth 2.34.0
  • google-cloud-vision 3.7.4
  • googleapis-common-protos 1.63.2
  • greenlet 3.0.3
  • grpcio 1.65.5
  • grpcio-status 1.65.5
  • h11 0.14.0
  • httpcore 1.0.5
  • httptools 0.6.1
  • httpx 0.27.0
  • idna 3.7
  • isodate 0.6.1
  • jinja2 3.1.4
  • jiter 0.5.0
  • markdown-it-py 3.0.0
  • markupsafe 2.1.5
  • mdurl 0.1.2
  • openai 1.41.0
  • outcome 1.3.0.post0
  • playwright 1.46.0
  • propelauth-fastapi 2.1.16
  • propelauth-py 3.1.16
  • proto-plus 1.24.0
  • protobuf 5.27.3
  • pyasn1 0.6.0
  • pyasn1-modules 0.4.0
  • pycparser 2.22
  • pydantic 2.8.2
  • pydantic-core 2.20.1
  • pyee 11.1.0
  • pygments 2.18.0
  • pyjwt 2.9.0
  • pymysql 1.1.1
  • pysocks 1.7.1
  • python-dotenv 1.0.1
  • python-multipart 0.0.9
  • pyyaml 6.0.2
  • requests 2.32.3
  • rich 13.7.1
  • rsa 4.9
  • selenium 4.23.1
  • shellingham 1.5.4
  • six 1.16.0
  • sniffio 1.3.1
  • sortedcontainers 2.4.0
  • sqlalchemy 2.0.32
  • starlette 0.38.2
  • stripe 10.8.0
  • tarsier 0.6.38
  • tqdm 4.66.5
  • trio 0.26.2
  • trio-websocket 0.11.1
  • typer 0.12.4
  • typing-extensions 4.12.2
  • urllib3 2.2.2
  • uvicorn 0.30.6
  • uvloop 0.20.0
  • watchfiles 0.23.0
  • websocket-client 1.8.0
  • websockets 12.0
  • wsproto 1.2.0
tarsier-service/service/pyproject.toml pypi
  • cryptography ^43.0.0
  • fastapi ^0.112.1
  • openai ^1.41.0
  • playwright ^1.46.0
  • propelauth-fastapi ^2.1.16
  • pydantic ^2.8.2
  • pymysql ^1.1.1
  • python >=3.11,<4.0
  • python-dotenv ^1.0.1
  • sqlalchemy ^2.0.32
  • stripe ^10.8.0
  • tarsier ^0.6.38
  • uvicorn ^0.30.6
tarsier-snapshots/poetry.lock pypi
  • annotated-types 0.7.0
  • attrs 23.2.0
  • azure-ai-vision-imageanalysis 1.0.0b2
  • azure-core 1.30.2
  • bananalyzer 0.8.75
  • boto3 1.34.144
  • botocore 1.34.144
  • cachetools 5.4.0
  • certifi 2024.7.4
  • cffi 1.16.0
  • charset-normalizer 3.3.2
  • colorama 0.4.6
  • deepdiff 6.7.1
  • execnet 2.1.1
  • google-api-core 2.19.1
  • google-auth 2.32.0
  • google-cloud-vision 3.7.3
  • googleapis-common-protos 1.63.2
  • greenlet 3.0.3
  • grpcio 1.64.1
  • grpcio-status 1.64.1
  • h11 0.14.0
  • idna 3.7
  • iniconfig 2.0.0
  • isodate 0.6.1
  • jinja2 3.1.4
  • jmespath 1.0.1
  • markupsafe 2.1.5
  • numpy 1.26.4
  • ordered-set 4.1.0
  • outcome 1.3.0.post0
  • packaging 24.1
  • playwright 1.45.0
  • playwright-stealth 1.0.6
  • pluggy 1.5.0
  • proto-plus 1.24.0
  • protobuf 5.27.2
  • psutil 5.9.8
  • pyasn1 0.6.0
  • pyasn1-modules 0.4.0
  • pycparser 2.22
  • pydantic 2.8.2
  • pydantic-core 2.20.1
  • pyee 11.1.0
  • pysocks 1.7.1
  • pytest 7.4.4
  • pytest-asyncio 0.21.2
  • pytest-html 4.1.1
  • pytest-metadata 3.1.1
  • pytest-xdist 3.6.1
  • python-dateutil 2.9.0.post0
  • python-dotenv 1.0.1
  • regex 2024.5.15
  • requests 2.32.3
  • rsa 4.9
  • s3transfer 0.10.2
  • selenium 4.22.0
  • six 1.16.0
  • sniffio 1.3.1
  • sortedcontainers 2.4.0
  • tabulate 0.9.0
  • tarsier 0.6.31
  • tiktoken 0.6.0
  • trio 0.26.0
  • trio-websocket 0.11.1
  • typing-extensions 4.12.2
  • urllib3 2.2.2
  • websocket-client 1.8.0
  • wsproto 1.2.0
tarsier-snapshots/pyproject.toml pypi
  • bananalyzer 0.8.75
  • numpy ^1.26.3
  • playwright ^1.41.1
  • python ^3.11
  • python-dotenv ^1.0.1
  • tarsier *
  • tiktoken ^0.6.0