Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Neet-Nestor committed Oct 24, 2024
1 parent 755c6c7 commit 0d0e44e
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

## Overview

The `web-agent-interface` library provides an API to interact with text selections, modifications, and other functionalities across different web platforms like Overleaf, Google Docs, and Google Calendar. This library makes it easier to customize your tools.
The `web-agent-interface` library provides tools to LLM agents in browsers to interact with different websites.

## Supported Platforms
**Note**: The project is still in development phase. It has limited coverage and its APIs may change.

- **Overleaf**: Manipulate text selections and content within Overleaf documents.
<!-- - **Google Docs (GDoc)**: Interact with text selections and modifications in Google Docs.
- **Google Calendar (GCal)**: Integrate and manage events on Google Calendar. -->
## Supported Tools

- **General DOM Operations**: Get page content and user selection.
- **Overleaf**: Edit Overleaf documents.
- **Google Calendar (GCal)**: Read and create events on Google Calendar.
<!-- - **Google Docs (GDoc)**: Interact with text selections and modifications in Google Docs. -->

## Installation

Expand All @@ -30,26 +33,37 @@ To install and build the library, follow these steps:

## Usage

### 1. Initialize the page handler in content script
### 1. Initialize State

```javascript
import { initHandler } from '@mlc-ai/web-agent-interface';
import { State } from '@mlc-ai/web-agent-interface';
const handler = initHandler();
const state = new State();
```
### 2. Get Available Tools
### 2. Import Tools
```javascript
import { tool, retriever, action } from '@mlc-ai/web-agent-interface';
```
### 3. Give Tool Description to Prompt
```javascript
import { getTools } from '@mlc-ai/web-agent-interface';
const system_prompt = `
You are a helpful AI agent.
You have the following tools to use:
const availableTools = getTools();
${tools.map((t) => JSON.stringify(t.schema)).join(",\n")}
`
```
### 3. Handling Tool Use
### 3. Call Tool Function to Get Observation
```javascript
const observation = handler.handleToolCall(toolName, parameters);
const { tool_name, parameters } = extractToolCall(llm_response);
const observation = tool[tool_name].implementation(state, parameters);
console.log("Got observation:", observation);
```

0 comments on commit 0d0e44e

Please sign in to comment.