Tools like web browser and code interpreters for LLMs
Project description
Langrocks is a collection of tools for LLMs.
Quickstart | Documentation | Langrocks
Installation
Install Langrocks using pip:
pip install -U langrocks
this will install the Langrocks CLI and the necessary dependencies. Make sure you have Docker installed on your system.
Getting Started
Start the Langrocks server by running:
langrocks
This will start the necessary containers and make the server available at localhost:3000
by default.
Examples
Langrocks comes with several example scripts in the langrocks/examples
directory. Here are some key features:
Web Browser
You can use the web browser to navigate the web and extract information, get screenshots, downloads and more based on your interaction with the LLM.
from langrocks.client.web_browser import WebBrowser
from langrocks.common.models.web_browser import WebBrowserCommand, WebBrowserCommandType
with WebBrowser("localhost:3000", capture_screenshot=True, html=True) as web_browser:
# Navigate to a webpage
content = web_browser.run_commands([
WebBrowserCommand(
command_type=WebBrowserCommandType.GOTO,
data="https://www.google.com"
),
WebBrowserCommand(
command_type=WebBrowserCommandType.WAIT,
selector="body"
)
])
# Extract content
text = web_browser.get_text()
html = web_browser.get_html()
images = web_browser.get_images()
Computer
You can use the computer tool to control a remote computer and interact with it by operating the mouse and keyboard. This is useful for models like Anthropic's claude with computer use.
from langrocks.client.computer import Computer
from langrocks.common.models.computer import ComputerCommand, ComputerCommandType
with Computer("localhost:3000", interactive=True) as computer:
print(computer.get_remote_viewer_url())
content = computer.run_commands(
[
ComputerCommand(command_type=ComputerCommandType.COMPUTER_KEY, data="ctrl+l"),
ComputerCommand(command_type=ComputerCommandType.COMPUTER_WAIT, data="1"),
ComputerCommand(command_type=ComputerCommandType.COMPUTER_TYPE, data="https://www.google.com"),
ComputerCommand(command_type=ComputerCommandType.COMPUTER_WAIT, data="1"),
ComputerCommand(command_type=ComputerCommandType.COMPUTER_KEY, data="Return"),
ComputerCommand(command_type=ComputerCommandType.COMPUTER_TERMINATE),
]
)
File Operations
You can use the file operations tool to convert between different file formats.
from langrocks.client.files import FileOperations
from langrocks.common.models.files import FileMimeType
DATA = r"""
\documentclass[a4paper,10pt]{article}
\usepackage[a4paper,margin=0.75in]{geometry}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{hyperref}
\usepackage{multicol}
...
...
"""
with FileOperations("localhost:3000") as fops:
print("\nRunning file converter")
# Convert file
print("Converting file")
response = fops.convert_file(
data=DATA.encode(),
filename="resume.tex",
input_mime_type=FileMimeType.LATEX,
output_mime_type=FileMimeType.PDF,
options=["-V", "geometry:margin=0.5in"],
)
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
File details
Details for the file langrocks-0.2.2.tar.gz
.
File metadata
- Download URL: langrocks-0.2.2.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/24.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e79dc9e9293eb9ae499b49d7b0836b93cc04b70891bf34a447a6596dcb8c5b3 |
|
MD5 | 5b2a856067933dd515cb26b371a7f26d |
|
BLAKE2b-256 | b042b5a831f39b4b39bd961cc3185fdbaffc2eafad8a099454739a8daad88e3e |
File details
Details for the file langrocks-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: langrocks-0.2.2-py3-none-any.whl
- Upload date:
- Size: 49.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/24.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cf80510f39684e2a6f2f99736d19f2758d53e98b8a2fa622b48520f91a62a4d |
|
MD5 | 4dd5674d10654b67087dee88e516cbf1 |
|
BLAKE2b-256 | 3fc9307546adfc10fd705109c7e3c0efadcc07a99265a8be3b281b9c2350c734 |