Skip to content

Commit

Permalink
feat: update readme with more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj319 committed Oct 28, 2024
1 parent 658e06a commit 8ebfe81
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ go get github.com/vertexcover-io/locatr
- [ Quick Example ](#quick-example)

- [ Locatr Settings ](#locatr-options)
- [ LLM Client ](#llm-client)
- [ Cache Schema & Management ](#cache)


#### Locatr Options
Expand All @@ -32,6 +34,64 @@ go get github.com/vertexcover-io/locatr
- **UseCache** (`bool`):
- Default is `false`. Set to `true` to use the cache.

#### LLM Client

The `LlmClient` struct is used to create an LLM client. Supported providers are `anthropic` and `openai`.

```go
import (
"github.com/vertexcover-io/locatr/core"
"os"
)

llmClient, err := core.NewLlmClient(
os.Getenv("LLM_PROVIDER"), // Supported providers: "openai" | "anthropic"
os.Getenv("LLM_MODEL_NAME"),
os.Getenv("LLM_API_KEY"),
)
```

### Locatrs

Locatrs are are wrapper around the main plugin (playwright, selenium) we use. Currently only playwright is supported.

#### PlaywrightLocatr
Create an instance of `PlayWrightLocatr` using

```go
locatr := core.NewPlaywrightLocatr(page, llmClient, options)
```

### Methods

- **GetLocatr**: Locates an element using a descriptive string and returns a `Locator` object.

```go
searchBarLocator, err := locatr.GetLocatr("Search Docker Hub input field")
```

### Cache

#### Cache Schema

The cache is stored in JSON format. The schema is as follows:

```json
{
"Page Full Url" : [
{
"locatr_name": "The description of the element you gave",
"locatrs": [
"input#search"
]
}
]
}
```

#### Cache Management

To remove the cache, delete the file at the path specified in `BaseLocatrOptions`'s `CachePath`.

### Quick Example

Expand Down

0 comments on commit 8ebfe81

Please sign in to comment.