Skip to content

Commit

Permalink
🌭
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Nov 6, 2023
1 parent 5018eae commit 1257af6
Show file tree
Hide file tree
Showing 90 changed files with 364 additions and 298 deletions.
90 changes: 78 additions & 12 deletions docs/pages/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<p align="center">
<a href="https://www.npmjs.com/package/dexter"><img alt="NPM" src="https://img.shields.io/npm/v/dexter.svg" /></a>
<p>
<a href="https://www.npmjs.com/package/@dexaai/dexter"><img alt="NPM" src="https://img.shields.io/npm/v/@dexaai/dexter.svg" /></a>
<a href="https://github.com/dexaai/dexter/actions/workflows/test.yml"><img alt="Build Status" src="https://github.com/dexaai/dexter/actions/workflows/main.yml/badge.svg" /></a>
<a href="https://github.com/dexaai/dexter/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
</p>

- [Dexter](#dexter)
- [Features](#features)
- [Install](#install)
- [Usage](#usage)
- [Docs](#docs)
- [License](#license)
# Dexter <!-- omit from toc -->

# Dexter
Dexter is a set of mature LLM tools used in production at [Dexa](https://dexa.ai), with a focus on real-world RAG ([Retrieval Augmented Generation](https://arxiv.org/abs/2005.11401)).

> Dexter is a set of mature LLM tools used in production at [Dexa](https://dexa.ai), with a focus on real-world RAG ([Retrieval Augmented Generation](https://arxiv.org/abs/2005.11401)).
_If you're a TypeScript AI engineer, check it out!_ 😊

**If you're a TypeScript AI engineer, check it out!** 😊
- [Features](#features)
- [Install](#install)
- [Usage](#usage)
- [Docs](#docs)
- [Examples](#examples)
- [Basic](#basic)
- [Caching](#caching)
- [Redis Caching](#redis-caching)
- [Chatbot](#chatbot)
- [License](#license)

## Features

Expand All @@ -38,7 +42,7 @@ npm install @dexaai/dexter

This package requires `node >= 18` or an environment with `fetch` support.

This package exports [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) only. If your project uses CommonJS, [consider switching to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function.
This package exports [ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If your project uses CommonJS, consider switching to ESM or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function.

## Usage

Expand Down Expand Up @@ -79,6 +83,68 @@ async function example() {

See the [docs](https://dexter.dexa.ai) for a full usage guide and API reference.

## Examples

To run the included examples, clone this repo, run `pnpm install`, set up your `.env` file, and then run an example file using `tsx`.

Environment variables required to run the examples:

- `OPENAI_API_KEY` - OpenAI API key
- `PINECONE_API_KEY` - Pinecone API key
- `PINECONE_BASE_URL` - Pinecone index's base URL
- You should be able to use a free-tier "starter" index for most of the examples, but you'll need to upgrade to a paid index to run the any of the hybrid search examples
- Note that Pinecone's free starter index doesn't support namespaces, `deleteAll`, or hybrid search _:sigh:_
- `SPLADE_SERVICE_URL` - optional; only used for the chatbot hybrid search example

### Basic

```bash
npx tsx examples/basic.ts
```

[source](./examples/basic.ts)

### Caching

```bash
npx tsx examples/caching.ts
```

[source](./examples/caching.ts)

### Redis Caching

This example requires a valid `REDIS_URL` env var.

```bash
npx tsx examples/caching-redis.ts
```

[source](./examples/caching-redis.ts)

### Chatbot

This is a more involved example of a chatbot using RAG. It indexes 100 transcript chunks from the [Huberman Lab Podcast](https://hubermanlab.com) into a [hybrid Pinecone datastore](https://docs.pinecone.io/docs/hybrid-search) using [OpenAI ada-002 embeddings](https://platform.openai.com/docs/guides/embeddings) for the dense vectors and a [HuggingFace SPLADE model](https://huggingface.co/naver/splade-cocondenser-ensembledistil) for the sparse embeddings.

You'll need the following environment variables to run this example:

- `OPENAI_API_KEY`
- `PINECONE_API_KEY`
- `PINECONE_BASE_URL`
- Note: Pinecone's free starter indexes don't seem to support namespaces or hybrid search, so unfortunately you'll need to upgrade to a paid plan to run this example. See Pinecone's [hybrid docs](https://docs.pinecone.io/docs/hybrid-search) for details on setting up a hybrid index, and make sure it is using the `dotproduct` metric.
- `SPLADE_SERVICE_URL`
- Here is an [example](https://gist.github.com/transitive-bullshit/cc9140ff832fc7e815a48f0a45e1fc27) of how to run a SPLADE REST API, which can be deployed to [Modal](https://modal.com) or any other GPU-enabled hosting provider.

```bash
npx tsx examples/chatbot/ingest.ts
```

```bash
npx tsx examples/chatbot/cli.ts
```

[source](./examples/chatbot)

## License

MIT © [Dexa](https://dexa.ai)
14 changes: 7 additions & 7 deletions docs/pages/docs/classes/AbstractDatastore.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

#### Source

[src/datastore/datastore.ts:36](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L36)
[src/datastore/datastore.ts:36](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L36)

## Properties

| Modifier | Property | Type | Description | Source |
| :------ | :------ | :------ | :------ | :------ |
| `abstract` | `datastoreProvider` | [`Provider`](../namespaces/Datastore/type-aliases/Provider.md) | - | [src/datastore/datastore.ts:26](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L26) |
| `abstract` | `datastoreType` | [`Type`](../namespaces/Datastore/type-aliases/Type.md) | - | [src/datastore/datastore.ts:25](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L25) |
| `abstract` | `datastoreProvider` | [`Provider`](../namespaces/Datastore/type-aliases/Provider.md) | - | [src/datastore/datastore.ts:26](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L26) |
| `abstract` | `datastoreType` | [`Type`](../namespaces/Datastore/type-aliases/Type.md) | - | [src/datastore/datastore.ts:25](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L25) |

## Methods

Expand All @@ -56,7 +56,7 @@

#### Source

[src/datastore/datastore.ts:22](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L22)
[src/datastore/datastore.ts:22](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L22)

***

Expand All @@ -70,7 +70,7 @@

#### Source

[src/datastore/datastore.ts:23](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L23)
[src/datastore/datastore.ts:23](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L23)

***

Expand All @@ -91,7 +91,7 @@

#### Source

[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L53)
[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L53)

***

Expand All @@ -112,4 +112,4 @@

#### Source

[src/datastore/datastore.ts:18](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L18)
[src/datastore/datastore.ts:18](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L18)
14 changes: 7 additions & 7 deletions docs/pages/docs/classes/AbstractHybridDatastore.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

#### Source

[src/datastore/hybrid-datastore.ts:11](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/hybrid-datastore.ts#L11)
[src/datastore/hybrid-datastore.ts:11](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/hybrid-datastore.ts#L11)

## Properties

| Modifier | Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ | :------ |
| `abstract` | `datastoreProvider` | [`Provider`](../namespaces/Datastore/type-aliases/Provider.md) | - | [`AbstractDatastore`](AbstractDatastore.md).`datastoreProvider` | [src/datastore/datastore.ts:26](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L26) |
| `abstract` | `datastoreType` | [`Type`](../namespaces/Datastore/type-aliases/Type.md) | - | [`AbstractDatastore`](AbstractDatastore.md).`datastoreType` | [src/datastore/datastore.ts:25](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L25) |
| `abstract` | `datastoreProvider` | [`Provider`](../namespaces/Datastore/type-aliases/Provider.md) | - | [`AbstractDatastore`](AbstractDatastore.md).`datastoreProvider` | [src/datastore/datastore.ts:26](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L26) |
| `abstract` | `datastoreType` | [`Type`](../namespaces/Datastore/type-aliases/Type.md) | - | [`AbstractDatastore`](AbstractDatastore.md).`datastoreType` | [src/datastore/datastore.ts:25](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L25) |

## Methods

Expand All @@ -64,7 +64,7 @@

#### Source

[src/datastore/datastore.ts:22](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L22)
[src/datastore/datastore.ts:22](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L22)

***

Expand All @@ -82,7 +82,7 @@

#### Source

[src/datastore/datastore.ts:23](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L23)
[src/datastore/datastore.ts:23](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L23)

***

Expand All @@ -107,7 +107,7 @@

#### Source

[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L53)
[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L53)

***

Expand All @@ -132,4 +132,4 @@

#### Source

[src/datastore/datastore.ts:18](https://github.com/dexaai/llm-tools/blob/2b78745/src/datastore/datastore.ts#L18)
[src/datastore/datastore.ts:18](https://github.com/dexaai/llm-tools/blob/5018eae/src/datastore/datastore.ts#L18)
36 changes: 18 additions & 18 deletions docs/pages/docs/classes/AbstractModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@

#### Source

[src/model/model.ts:67](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L67)
[src/model/model.ts:67](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L67)

## Properties

| Modifier | Property | Type | Description | Source |
| :------ | :------ | :------ | :------ | :------ |
| `abstract` | `modelProvider` | [`Provider`](../namespaces/Model/type-aliases/Provider.md) | - | [src/model/model.ts:57](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L57) |
| `abstract` | `modelType` | [`Type`](../namespaces/Model/type-aliases/Type.md) | - | [src/model/model.ts:56](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L56) |
| `public` | `tokenizer` | [`ITokenizer`](../namespaces/Model/interfaces/ITokenizer.md) | - | [src/model/model.ts:65](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L65) |
| `abstract` | `modelProvider` | [`Provider`](../namespaces/Model/type-aliases/Provider.md) | - | [src/model/model.ts:57](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L57) |
| `abstract` | `modelType` | [`Type`](../namespaces/Model/type-aliases/Type.md) | - | [src/model/model.ts:56](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L56) |
| `public` | `tokenizer` | [`ITokenizer`](../namespaces/Model/interfaces/ITokenizer.md) | - | [src/model/model.ts:65](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L65) |

## Methods

Expand All @@ -65,7 +65,7 @@ Add event handlers to the model.

#### Source

[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L235)
[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L235)

***

Expand All @@ -87,7 +87,7 @@ Add the params. Overrides existing keys.

#### Source

[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L213)
[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L213)

***

Expand Down Expand Up @@ -115,7 +115,7 @@ Clone the model, optionally adding new arguments

#### Source

[src/model/model.ts:52](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L52)
[src/model/model.ts:52](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L52)

***

Expand All @@ -131,7 +131,7 @@ Get the current client

#### Source

[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L180)
[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L180)

***

Expand All @@ -147,7 +147,7 @@ Get the current context

#### Source

[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L191)
[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L191)

***

Expand All @@ -163,7 +163,7 @@ Get the current event handlers

#### Source

[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L230)
[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L230)

***

Expand All @@ -179,7 +179,7 @@ Get the current params

#### Source

[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L208)
[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L208)

***

Expand All @@ -200,7 +200,7 @@ Get the current params

#### Source

[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L78)
[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L78)

***

Expand All @@ -222,7 +222,7 @@ Set the cache to a new cache. Set to undefined to remove existing.

#### Source

[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L174)
[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L174)

***

Expand All @@ -244,7 +244,7 @@ Set the client to a new OpenAI API client.

#### Source

[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L185)
[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L185)

***

Expand All @@ -266,7 +266,7 @@ Set the context to a new context. Removes all existing values.

#### Source

[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L202)
[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L202)

***

Expand All @@ -289,7 +289,7 @@ Set to empty object `{}` to remove all events.

#### Source

[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L244)
[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L244)

***

Expand All @@ -311,7 +311,7 @@ Set the params to a new params. Removes all existing values.

#### Source

[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L223)
[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L223)

***

Expand All @@ -333,4 +333,4 @@ Add the context. Overrides existing keys.

#### Source

[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/2b78745/src/model/model.ts#L196)
[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/5018eae/src/model/model.ts#L196)
Loading

0 comments on commit 1257af6

Please sign in to comment.