V2 and OSS prep for dexter (#6)

Co-authored-by: Riley Tomasek <riley.tomasek@gmail.com>
This commit is contained in:
Travis Fischer
2023-11-06 20:39:37 -06:00
committed by GitHub
parent cd9179f299
commit fdefca030e
286 changed files with 47799 additions and 5588 deletions
-8
View File
@@ -1,8 +0,0 @@
# Changesets
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
-11
View File
@@ -1,11 +0,0 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": ["examples-basic"]
}
+15
View File
@@ -0,0 +1,15 @@
# ------------------------------------------------------------------------------
# This is an example .env file.
#
# All of these environment vars must be defined either in your environment or in
# a local .env file in order to run the examples for this project.
# ------------------------------------------------------------------------------
OPENAI_API_KEY=
# Most examples will work with a free-tier index, but you'll need a paid hybrid-compatible index to run the chatbot example
PINECONE_API_KEY=
PINECONE_BASE_URL=
# Optional; only needed if using a hybrid datastore
#SPLADE_SERVICE_URL=
+2
View File
@@ -0,0 +1,2 @@
dist
.next
+1
View File
@@ -1,4 +1,5 @@
{
"root": true,
"extends": ["@dexaai/eslint-config", "@dexaai/eslint-config/node"],
"rules": {
"no-console": "off"
+48
View File
@@ -0,0 +1,48 @@
name: CI
on: [push, pull_request]
jobs:
test:
name: Test Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version:
- 21
- 20
- 18
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run test
run: pnpm run test
+4
View File
@@ -11,6 +11,10 @@ node_modules
temp
todo.md
.env*
!.env.example
.dev*
.env.local
.local-files
.vscode
.next
.vercel
+1
View File
@@ -0,0 +1 @@
enable-pre-post-scripts=true
+1
View File
@@ -6,3 +6,4 @@
**/build
**/dbschema
**/public
.next
-13
View File
@@ -1,13 +0,0 @@
# tsconfig
## 0.1.1
### Patch Changes
- Build packages before publishing
## 0.1.0
### Minor Changes
- Initial release
-11
View File
@@ -1,11 +0,0 @@
{
"name": "tsconfig",
"version": "0.1.1",
"private": true,
"files": [
"node-esm.json"
],
"publishConfig": {
"access": "public"
}
}
+66
View File
@@ -0,0 +1,66 @@
# Contributing
Suggestions and pull requests are very welcome. 😊
## Development
To develop the project locally, you'll need `node >= 18` and `pnpm >= 8`.
```bash
git clone https://github.com/dexaai/dexter
cd dexter
pnpm i
```
You can now run the `tsc` dev server to automatically recompile the project whenever you make changes:
```bash
pnpm dev
```
## Testing
You can run the test suite via:
```bash
pnpm test
```
Or just the [Vitest](https://vitest.dev) unit tests via:
```bash
pnpm test:unit
```
## 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`.
For example:
```bash
npx tsx examples/basic.ts
```
## Docs
The `./docs/pages/docs` directory is autogenerated via [typedoc](https://typedoc.org) and [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/next/packages/typedoc-plugin-markdown).
To rebuild the docs, run:
```bash
pnpm run docs
```
Please don't run this command when submitting PRs to keep them uncluttered, unless you're making changes to the docs themselves.
The docs folder is a normal [Next.js](https://nextjs.org) pages app built using [Nextra](https://nextra.site/).
You can run the docs dev server to preview your changes via:
```bash
cd docs
pnpm dev
```
The docs are automatically deployed to [Vercel](https://vercel.com).
+113
View File
@@ -0,0 +1,113 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import { globby } from 'globby';
import pMap from 'p-map';
/**
* Cleans up TypeDoc's a automated output to make it more suitable for Nextra.
*
* Nextra insists on title-casing identifiers, so we need to manually set their
* display names.
*/
async function main() {
const docsDir = path.join('docs', 'pages', 'docs');
const docs = (
await globby('**/*.md', {
cwd: docsDir,
})
)
.map((relativePath) => {
const absolutePath = path.join(docsDir, relativePath);
return {
relativePath,
absolutePath,
};
})
.filter(Boolean)
.sort((a, b) => a.relativePath.localeCompare(b.relativePath));
const metaMap: Record<string, string[]> = {};
await pMap(
docs,
async (doc) => {
console.log(`processing ${doc.relativePath}`);
const parts = doc.relativePath.split('/');
if (parts.length <= 1) {
return;
}
const bucket = parts.slice(0, -1).join('/');
if (!metaMap[bucket]) {
metaMap[bucket] = [];
}
metaMap[bucket].push(doc.relativePath);
},
{
concurrency: 32,
}
);
{
// top-level nextra _meta.json file
const docsMeta = {
exports: 'API Reference',
namespaces: 'Namespaces',
classes: 'Classes',
interfaces: 'Interfaces',
functions: 'Functions',
'type-aliases': {
title: 'Type Aliases',
display: 'hidden',
},
README: {
display: 'hidden',
},
};
await fs.writeFile(
path.join(docsDir, '_meta.json'),
JSON.stringify(docsMeta, null, 2),
'utf-8'
);
}
// sub nextra _meta.json files
await pMap(
Object.keys(metaMap),
async (key) => {
const values = metaMap[key]
.map((value) => value.split('/').slice(-1)[0].split('.')[0].trim())
.filter(Boolean)
.sort((a, b) => a.localeCompare(b));
if (values.length <= 1) {
return;
}
const meta = values.reduce(
(acc, value) => ({
...acc,
[value]: value,
}),
{}
);
const destDir = path.join(docsDir, key);
await fs.writeFile(
path.join(path.join(destDir, '_meta.json')),
JSON.stringify(meta, null, 2),
'utf-8'
);
},
{
concurrency: 4,
}
);
}
main();
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
+29
View File
@@ -0,0 +1,29 @@
import nextra from 'nextra';
const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
staticImage: true,
latex: false,
flexsearch: false,
defaultShowCopyCode: true,
});
export default withNextra({
reactStrictMode: false,
eslint: {
ignoreDuringBuilds: true,
},
rewrites() {
return [
{
source: '/guide',
destination: '/guide/install',
},
{
source: '/docs',
destination: '/docs/exports',
},
];
},
});
+18
View File
@@ -0,0 +1,18 @@
{
"private": true,
"name": "dexter-docs",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"license": "MIT",
"dependencies": {
"@vercel/analytics": "^1.1.1",
"next": "^14.0.1",
"nextra": "^2.13.2",
"nextra-theme-docs": "^2.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
+12
View File
@@ -0,0 +1,12 @@
import { Analytics } from '@vercel/analytics/react'
export default function App({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Analytics />
</>
)
}
+37
View File
@@ -0,0 +1,37 @@
{
"index": "Home",
"guide": "Guide",
"docs": "Documentation",
"-- Project": {
"type": "separator",
"title": "Project"
},
"faq": "FAQ",
"license": "License",
"-- Links": {
"type": "separator",
"title": "Links"
},
"dexa-link": {
"title": "Dexa ↗",
"type": "page",
"href": "https://dexa.ai",
"newWindow": true
},
"contact": {
"title": "Contact ↗",
"type": "page",
"href": "https://twitter.com/dexa_ai",
"newWindow": true
},
"contact-sidebar": {
"title": "Contact ↗",
"href": "https://twitter.com/dexa_ai",
"newWindow": true
},
"dexa-link-sidebar": {
"title": "Dexa ↗",
"href": "https://dexa.ai",
"newWindow": true
}
}
+1
View File
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
+150
View File
@@ -0,0 +1,150 @@
<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 <!-- omit from toc -->
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!_ 😊
- [Features](#features)
- [Install](#install)
- [Usage](#usage)
- [Docs](#docs)
- [Examples](#examples)
- [Basic](#basic)
- [Caching](#caching)
- [Redis Caching](#redis-caching)
- [Chatbot](#chatbot)
- [License](#license)
## Features
- production-quality RAG
- extremely fast and minimal
- handles caching, throttling, and batching for ingesting large datasets
- optional hybrid search w/ dense + sparse SPLADE embeddings
- supports arbitrary reranking strategies
- minimal TS package w/ full typing
- uses `fetch` everywhere
- supports Node.js 18+, Deno, Cloudflare Workers, Vercel edge functions, etc
- [well-documented](https://dexter.dexa.ai)
## Install
```bash
npm install @dexaai/dexter
```
This package requires `node >= 18` or an environment with `fetch` support.
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
This is a basic example using OpenAI's [text-embedding-ada-002](https://platform.openai.com/docs/guides/embeddings) embedding model and a [Pinecone](https://www.pinecone.io/) datastore to index and query a set of documents.
```ts
import 'dotenv/config';
import { EmbeddingModel } from '@dexaai/dexter/model';
import { PineconeDatastore } from '@dexaai/dexter/datastore/pinecone';
async function example() {
const embeddingModel = new EmbeddingModel({
params: { model: 'text-embedding-ada-002' },
});
const store = new PineconeDatastore({
contentKey: 'content',
embeddingModel,
});
await store.upsert([
{ id: '1', metadata: { content: 'cat' } },
{ id: '2', metadata: { content: 'dog' } },
{ id: '3', metadata: { content: 'whale' } },
{ id: '4', metadata: { content: 'shark' } },
{ id: '5', metadata: { content: 'computer' } },
{ id: '6', metadata: { content: 'laptop' } },
{ id: '7', metadata: { content: 'phone' } },
{ id: '8', metadata: { content: 'tablet' } },
]);
const result = await store.query({ query: 'dolphin' });
console.log(result);
}
```
## Docs
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
View File
@@ -0,0 +1,14 @@
{
"exports": "API Reference",
"namespaces": "Namespaces",
"classes": "Classes",
"interfaces": "Interfaces",
"functions": "Functions",
"type-aliases": {
"title": "Type Aliases",
"display": "hidden"
},
"README": {
"display": "hidden"
}
}
@@ -0,0 +1,116 @@
# Class: `abstract` AbstractDatastore`<DocMeta, Filter>`
## Extended By
- [`AbstractHybridDatastore`](AbstractHybridDatastore.md)
- [`PineconeDatastore`](PineconeDatastore.md)
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../namespaces/Datastore/type-aliases/BaseMeta.md) |
| `Filter` extends [`BaseFilter`](../namespaces/Datastore/type-aliases/BaseFilter.md)\<`DocMeta`\> |
## Constructors
### new AbstractDatastore(args)
> **new AbstractDatastore**\<`DocMeta`, `Filter`\>(`args`): [`AbstractDatastore`](AbstractDatastore.md)\<`DocMeta`, `Filter`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `args` | [`Opts`](../namespaces/Datastore/interfaces/Opts.md)\<`DocMeta`, `Filter`\> |
#### Returns
[`AbstractDatastore`](AbstractDatastore.md)\<`DocMeta`, `Filter`\>
#### Source
[src/datastore/datastore.ts:36](https://github.com/dexaai/llm-tools/blob/98f7fd5/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/98f7fd5/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/98f7fd5/src/datastore/datastore.ts#L25) |
## Methods
### `abstract` delete()
> **`abstract`** **delete**(`docIds`): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docIds` | `string`[] |
#### Returns
`Promise`\<`void`\>
#### Source
[src/datastore/datastore.ts:22](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L22)
***
### `abstract` deleteAll()
> **`abstract`** **deleteAll**(): `Promise`\<`void`\>
#### Returns
`Promise`\<`void`\>
#### Source
[src/datastore/datastore.ts:23](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L23)
***
### query()
> **query**(`query`, `context`?): `Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `query` | [`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `Filter`\> |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Source
[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L53)
***
### `abstract` upsert()
> **`abstract`** **upsert**(`docs`, `context`?): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docs` | [`Doc`](../namespaces/Datastore/interfaces/Doc.md)\<`DocMeta`\>[] |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<`void`\>
#### Source
[src/datastore/datastore.ts:18](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L18)
@@ -0,0 +1,135 @@
# Class: `abstract` AbstractHybridDatastore`<DocMeta, Filter>`
## Extends
- [`AbstractDatastore`](AbstractDatastore.md)\<`DocMeta`, `Filter`\>
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../namespaces/Datastore/type-aliases/BaseMeta.md) |
| `Filter` extends [`BaseFilter`](../namespaces/Datastore/type-aliases/BaseFilter.md)\<`DocMeta`\> |
## Constructors
### new AbstractHybridDatastore(args)
> **new AbstractHybridDatastore**\<`DocMeta`, `Filter`\>(`args`): [`AbstractHybridDatastore`](AbstractHybridDatastore.md)\<`DocMeta`, `Filter`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `args` | [`OptsHybrid`](../namespaces/Datastore/interfaces/OptsHybrid.md)\<`DocMeta`, `Filter`\> |
#### Returns
[`AbstractHybridDatastore`](AbstractHybridDatastore.md)\<`DocMeta`, `Filter`\>
#### Overrides
[`AbstractDatastore`](AbstractDatastore.md).[`constructor`](AbstractDatastore.md#Constructors)
#### Source
[src/datastore/hybrid-datastore.ts:11](https://github.com/dexaai/llm-tools/blob/98f7fd5/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/98f7fd5/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/98f7fd5/src/datastore/datastore.ts#L25) |
## Methods
### `abstract` delete()
> **`abstract`** **delete**(`docIds`): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docIds` | `string`[] |
#### Returns
`Promise`\<`void`\>
#### Inherited from
[`AbstractDatastore`](AbstractDatastore.md).[`delete`](AbstractDatastore.md#abstract-delete)
#### Source
[src/datastore/datastore.ts:22](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L22)
***
### `abstract` deleteAll()
> **`abstract`** **deleteAll**(): `Promise`\<`void`\>
#### Returns
`Promise`\<`void`\>
#### Inherited from
[`AbstractDatastore`](AbstractDatastore.md).[`deleteAll`](AbstractDatastore.md#abstract-deleteAll)
#### Source
[src/datastore/datastore.ts:23](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L23)
***
### query()
> **query**(`query`, `context`?): `Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `query` | [`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `Filter`\> |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Inherited from
[`AbstractDatastore`](AbstractDatastore.md).[`query`](AbstractDatastore.md#query)
#### Source
[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L53)
***
### `abstract` upsert()
> **`abstract`** **upsert**(`docs`, `context`?): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docs` | [`Doc`](../namespaces/Datastore/interfaces/Doc.md)\<`DocMeta`\>[] |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<`void`\>
#### Inherited from
[`AbstractDatastore`](AbstractDatastore.md).[`upsert`](AbstractDatastore.md#abstract-upsert)
#### Source
[src/datastore/datastore.ts:18](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L18)
+336
View File
@@ -0,0 +1,336 @@
# Class: `abstract` AbstractModel`<MClient, MConfig, MRun, MResponse, AResponse>`
## Extended By
- [`ChatModel`](ChatModel.md)
- [`CompletionModel`](CompletionModel.md)
- [`EmbeddingModel`](EmbeddingModel.md)
- [`SparseVectorModel`](SparseVectorModel.md)
## Type parameters
| Parameter | Default |
| :------ | :------ |
| `MClient` extends [`Client`](../namespaces/Model/namespaces/Base/type-aliases/Client.md) | - |
| `MConfig` extends [`Config`](../namespaces/Model/namespaces/Base/interfaces/Config.md) | - |
| `MRun` extends [`Run`](../namespaces/Model/namespaces/Base/interfaces/Run.md) | - |
| `MResponse` extends [`Response`](../namespaces/Model/namespaces/Base/interfaces/Response.md) | - |
| `AResponse` extends `any` | `any` |
## Constructors
### new AbstractModel(args)
> **new AbstractModel**\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>(`args`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `args` | [`ModelArgs`](../interfaces/ModelArgs.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`\> |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:67](https://github.com/dexaai/llm-tools/blob/98f7fd5/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/98f7fd5/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/98f7fd5/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/98f7fd5/src/model/model.ts#L65) |
## Methods
### addEvents()
> **addEvents**(`events`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Add event handlers to the model.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<`MRun` & `MConfig`, `MResponse`, `AResponse`\> |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L235)
***
### addParams()
> **addParams**(`params`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Add the params. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `Partial`\<`MConfig` & `Partial`\<`MRun`\>\> |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L213)
***
### `abstract` clone()
> **`abstract`** **clone**\<`Args`\>(`args`?): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Clone the model, optionally adding new arguments
#### Type parameters
| Parameter |
| :------ |
| `Args` extends [`ModelArgs`](../interfaces/ModelArgs.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`\> |
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `args`? | `Args` |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:52](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L52)
***
### getClient()
> **getClient**(): `MClient`
Get the current client
#### Returns
`MClient`
#### Source
[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L180)
***
### getContext()
> **getContext**(): [`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
Get the current context
#### Returns
[`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
#### Source
[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L191)
***
### getEvents()
> **getEvents**(): [`Events`](../namespaces/Model/interfaces/Events.md)\<`MRun` & `MConfig`, `MResponse`, `AResponse`\>
Get the current event handlers
#### Returns
[`Events`](../namespaces/Model/interfaces/Events.md)\<`MRun` & `MConfig`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L230)
***
### getParams()
> **getParams**(): `MConfig` & `Partial`\<`MRun`\>
Get the current params
#### Returns
`MConfig` & `Partial`\<`MRun`\>
#### Source
[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L208)
***
### run()
> **run**(`params`, `context`?): `Promise`\<`MResponse`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `{ [K in string | number | symbol]: (MRun & Partial<MConfig>)[K] }` |
| `context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
`Promise`\<`MResponse`\>
#### Source
[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L78)
***
### setCache()
> **setCache**(`cache`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Set the cache to a new cache. Set to undefined to remove existing.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `cache` | `undefined` \| [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, `MResponse`\> |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L174)
***
### setClient()
> **setClient**(`client`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Set the client to a new OpenAI API client.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `client` | `MClient` |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L185)
***
### setContext()
> **setContext**(`context`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Set the context to a new context. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L202)
***
### setEvents()
> **setEvents**(`events`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Set the event handlers to a new set of events. Removes all existing event handlers.
Set to empty object `{}` to remove all events.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<`MRun` & `MConfig`, `MResponse`, `AResponse`\> |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L244)
***
### setParams()
> **setParams**(`params`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Set the params to a new params. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `MConfig` & `Partial`\<`MRun`\> |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L223)
***
### updateContext()
> **updateContext**(`context`): [`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
Add the context. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`AbstractModel`](AbstractModel.md)\<`MClient`, `MConfig`, `MRun`, `MResponse`, `AResponse`\>
#### Source
[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L196)
+403
View File
@@ -0,0 +1,403 @@
# Class: ChatModel
## Extends
- [`AbstractModel`](AbstractModel.md)\<[`Client`](../namespaces/Model/namespaces/Chat/type-aliases/Client.md), [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), [`ApiResponse`](../namespaces/Model/namespaces/Chat/type-aliases/ApiResponse.md)\>
## Constructors
### new ChatModel(args)
> **new ChatModel**(`args`?): [`ChatModel`](ChatModel.md)
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.client`? | [`Client`](../namespaces/Model/namespaces/Chat/type-aliases/Client.md) | - |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md)\> | - |
#### Returns
[`ChatModel`](ChatModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`constructor`](AbstractModel.md#Constructors)
#### Source
[src/model/chat.ts:29](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/chat.ts#L29)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `modelProvider` | `"openai"` | - | [`AbstractModel`](AbstractModel.md).`modelProvider` | [src/model/chat.ts:27](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/chat.ts#L27) |
| `modelType` | `"chat"` | - | [`AbstractModel`](AbstractModel.md).`modelType` | [src/model/chat.ts:26](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/chat.ts#L26) |
| `tokenizer` | [`ITokenizer`](../namespaces/Model/interfaces/ITokenizer.md) | - | [`AbstractModel`](AbstractModel.md).`tokenizer` | [src/model/model.ts:65](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L65) |
## Methods
### addEvents()
> **addEvents**(`events`): [`ChatModel`](ChatModel.md)
Add event handlers to the model.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), `ChatCompletion`\> |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addEvents`](AbstractModel.md#addEvents)
#### Source
[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L235)
***
### addParams()
> **addParams**(`params`): [`ChatModel`](ChatModel.md)
Add the params. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `Partial`\<[`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md)\>\> |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addParams`](AbstractModel.md#addParams)
#### Source
[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L213)
***
### clone()
> **clone**(`args`?): [`ChatModel`](ChatModel.md)
Clone the model and merge/orverride the given properties.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.client`? | [`Client`](../namespaces/Model/namespaces/Chat/type-aliases/Client.md) | - |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md)\> | - |
#### Returns
[`ChatModel`](ChatModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`clone`](AbstractModel.md#abstract-clone)
#### Source
[src/model/chat.ts:184](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/chat.ts#L184)
***
### getClient()
> **getClient**(): [`Client`](../namespaces/Model/namespaces/Chat/type-aliases/Client.md)
Get the current client
#### Returns
[`Client`](../namespaces/Model/namespaces/Chat/type-aliases/Client.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getClient`](AbstractModel.md#getClient)
#### Source
[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L180)
***
### getContext()
> **getContext**(): [`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
Get the current context
#### Returns
[`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getContext`](AbstractModel.md#getContext)
#### Source
[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L191)
***
### getEvents()
> **getEvents**(): [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), `ChatCompletion`\>
Get the current event handlers
#### Returns
[`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), `ChatCompletion`\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getEvents`](AbstractModel.md#getEvents)
#### Source
[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L230)
***
### getParams()
> **getParams**(): [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md)\>
Get the current params
#### Returns
[`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getParams`](AbstractModel.md#getParams)
#### Source
[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L208)
***
### run()
> **run**(`params`, `context`?): `Promise`\<[`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md)\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `object` |
| `params.frequency_penalty`? | `null` \| `number` |
| `params.function_call`? | `"none"` \| `"auto"` \| `FunctionCallOption` |
| `params.functions`? | `Function`[] |
| `params.handleUpdate`? | (`chunk`) => `void` |
| `params.logit_bias`? | `null` \| `Record`\<`string`, `number`\> |
| `params.max_tokens`? | `null` \| `number` |
| `params.messages`? | `ChatCompletionMessageParam`[] |
| `params.model`? | `"gpt-4"` \| `"gpt-4-32k"` \| `"gpt-3.5-turbo"` \| `"gpt-3.5-turbo-16k"` \| `string` & `object` \| `"gpt-4-0314"` \| `"gpt-4-0613"` \| `"gpt-4-32k-0314"` \| `"gpt-4-32k-0613"` \| `"gpt-3.5-turbo-0301"` \| `"gpt-3.5-turbo-0613"` \| `"gpt-3.5-turbo-16k-0613"` |
| `params.presence_penalty`? | `null` \| `number` |
| `params.stop`? | `null` \| `string` \| `string`[] |
| `params.temperature`? | `null` \| `number` |
| `params.top_p`? | `null` \| `number` |
| `context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`run`](AbstractModel.md#run)
#### Source
[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L78)
***
### setCache()
> **setCache**(`cache`): [`ChatModel`](ChatModel.md)
Set the cache to a new cache. Set to undefined to remove existing.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `cache` | `undefined` \| [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md)\> |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setCache`](AbstractModel.md#setCache)
#### Source
[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L174)
***
### setClient()
> **setClient**(`client`): [`ChatModel`](ChatModel.md)
Set the client to a new OpenAI API client.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `client` | [`Client`](../namespaces/Model/namespaces/Chat/type-aliases/Client.md) |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setClient`](AbstractModel.md#setClient)
#### Source
[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L185)
***
### setContext()
> **setContext**(`context`): [`ChatModel`](ChatModel.md)
Set the context to a new context. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setContext`](AbstractModel.md#setContext)
#### Source
[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L202)
***
### setEvents()
> **setEvents**(`events`): [`ChatModel`](ChatModel.md)
Set the event handlers to a new set of events. Removes all existing event handlers.
Set to empty object `{}` to remove all events.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Chat/interfaces/Response.md), `ChatCompletion`\> |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setEvents`](AbstractModel.md#setEvents)
#### Source
[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L244)
***
### setParams()
> **setParams**(`params`): [`ChatModel`](ChatModel.md)
Set the params to a new params. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | [`Config`](../namespaces/Model/namespaces/Chat/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Chat/interfaces/Run.md)\> |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setParams`](AbstractModel.md#setParams)
#### Source
[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L223)
***
### updateContext()
> **updateContext**(`context`): [`ChatModel`](ChatModel.md)
Add the context. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`ChatModel`](ChatModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`updateContext`](AbstractModel.md#updateContext)
#### Source
[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L196)
+393
View File
@@ -0,0 +1,393 @@
# Class: CompletionModel
## Extends
- [`AbstractModel`](AbstractModel.md)\<[`Client`](../namespaces/Model/namespaces/Completion/type-aliases/Client.md), [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), [`ApiResponse`](../namespaces/Model/namespaces/Completion/type-aliases/ApiResponse.md)\>
## Constructors
### new CompletionModel(args)
> **new CompletionModel**(`args`?): [`CompletionModel`](CompletionModel.md)
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.client`? | [`Client`](../namespaces/Model/namespaces/Completion/type-aliases/Client.md) | - |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md)\> | - |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`constructor`](AbstractModel.md#Constructors)
#### Source
[src/model/completion.ts:28](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/completion.ts#L28)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `modelProvider` | `"openai"` | - | [`AbstractModel`](AbstractModel.md).`modelProvider` | [src/model/completion.ts:26](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/completion.ts#L26) |
| `modelType` | `"completion"` | - | [`AbstractModel`](AbstractModel.md).`modelType` | [src/model/completion.ts:25](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/completion.ts#L25) |
| `tokenizer` | [`ITokenizer`](../namespaces/Model/interfaces/ITokenizer.md) | - | [`AbstractModel`](AbstractModel.md).`tokenizer` | [src/model/model.ts:65](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L65) |
## Methods
### addEvents()
> **addEvents**(`events`): [`CompletionModel`](CompletionModel.md)
Add event handlers to the model.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), `Completion`\> |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addEvents`](AbstractModel.md#addEvents)
#### Source
[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L235)
***
### addParams()
> **addParams**(`params`): [`CompletionModel`](CompletionModel.md)
Add the params. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `Partial`\<[`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md)\>\> |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addParams`](AbstractModel.md#addParams)
#### Source
[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L213)
***
### clone()
> **clone**(`args`?): [`CompletionModel`](CompletionModel.md)
Clone the model and merge/orverride the given properties.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.client`? | [`Client`](../namespaces/Model/namespaces/Completion/type-aliases/Client.md) | - |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md)\> | - |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`clone`](AbstractModel.md#abstract-clone)
#### Source
[src/model/completion.ts:73](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/completion.ts#L73)
***
### getClient()
> **getClient**(): [`Client`](../namespaces/Model/namespaces/Completion/type-aliases/Client.md)
Get the current client
#### Returns
[`Client`](../namespaces/Model/namespaces/Completion/type-aliases/Client.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getClient`](AbstractModel.md#getClient)
#### Source
[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L180)
***
### getContext()
> **getContext**(): [`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
Get the current context
#### Returns
[`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getContext`](AbstractModel.md#getContext)
#### Source
[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L191)
***
### getEvents()
> **getEvents**(): [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), `Completion`\>
Get the current event handlers
#### Returns
[`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), `Completion`\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getEvents`](AbstractModel.md#getEvents)
#### Source
[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L230)
***
### getParams()
> **getParams**(): [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md)\>
Get the current params
#### Returns
[`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getParams`](AbstractModel.md#getParams)
#### Source
[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L208)
***
### run()
> **run**(`params`, `context`?): `Promise`\<[`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md)\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `object` |
| `params.model`? | `"gpt-3.5-turbo-instruct"` \| `"babbage-002"` \| `"davinci-002"` \| `string` & `object` \| `"text-davinci-003"` \| `"text-davinci-002"` \| `"text-davinci-001"` \| `"code-davinci-002"` \| `"text-curie-001"` \| `"text-babbage-001"` \| `"text-ada-001"` |
| `params.prompt`? | `null` \| `string` \| `string`[] \| `number`[] \| `number`[][] |
| `context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`run`](AbstractModel.md#run)
#### Source
[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L78)
***
### setCache()
> **setCache**(`cache`): [`CompletionModel`](CompletionModel.md)
Set the cache to a new cache. Set to undefined to remove existing.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `cache` | `undefined` \| [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md)\> |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setCache`](AbstractModel.md#setCache)
#### Source
[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L174)
***
### setClient()
> **setClient**(`client`): [`CompletionModel`](CompletionModel.md)
Set the client to a new OpenAI API client.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `client` | [`Client`](../namespaces/Model/namespaces/Completion/type-aliases/Client.md) |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setClient`](AbstractModel.md#setClient)
#### Source
[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L185)
***
### setContext()
> **setContext**(`context`): [`CompletionModel`](CompletionModel.md)
Set the context to a new context. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setContext`](AbstractModel.md#setContext)
#### Source
[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L202)
***
### setEvents()
> **setEvents**(`events`): [`CompletionModel`](CompletionModel.md)
Set the event handlers to a new set of events. Removes all existing event handlers.
Set to empty object `{}` to remove all events.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Completion/interfaces/Response.md), `Completion`\> |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setEvents`](AbstractModel.md#setEvents)
#### Source
[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L244)
***
### setParams()
> **setParams**(`params`): [`CompletionModel`](CompletionModel.md)
Set the params to a new params. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | [`Config`](../namespaces/Model/namespaces/Completion/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Completion/interfaces/Run.md)\> |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setParams`](AbstractModel.md#setParams)
#### Source
[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L223)
***
### updateContext()
> **updateContext**(`context`): [`CompletionModel`](CompletionModel.md)
Add the context. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`CompletionModel`](CompletionModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`updateContext`](AbstractModel.md#updateContext)
#### Source
[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L196)
+398
View File
@@ -0,0 +1,398 @@
# Class: EmbeddingModel
## Extends
- [`AbstractModel`](AbstractModel.md)\<[`Client`](../namespaces/Model/namespaces/Embedding/type-aliases/Client.md), [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), [`ApiResponse`](../namespaces/Model/namespaces/Embedding/type-aliases/ApiResponse.md)\>
## Constructors
### new EmbeddingModel(args)
> **new EmbeddingModel**(`args`?): [`EmbeddingModel`](EmbeddingModel.md)
Doesn't accept OpenAIClient because retry needs to be handled at the model level.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.client`? | [`Client`](../namespaces/Model/namespaces/Embedding/type-aliases/Client.md) | - |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md)\> | - |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`constructor`](AbstractModel.md#Constructors)
#### Source
[src/model/embedding.ts:48](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/embedding.ts#L48)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `modelProvider` | `"openai"` | - | [`AbstractModel`](AbstractModel.md).`modelProvider` | [src/model/embedding.ts:44](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/embedding.ts#L44) |
| `modelType` | `"embedding"` | - | [`AbstractModel`](AbstractModel.md).`modelType` | [src/model/embedding.ts:43](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/embedding.ts#L43) |
| `throttledModel` | `BulkEmbedder` | - | - | [src/model/embedding.ts:45](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/embedding.ts#L45) |
| `tokenizer` | [`ITokenizer`](../namespaces/Model/interfaces/ITokenizer.md) | - | [`AbstractModel`](AbstractModel.md).`tokenizer` | [src/model/model.ts:65](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L65) |
## Methods
### addEvents()
> **addEvents**(`events`): [`EmbeddingModel`](EmbeddingModel.md)
Add event handlers to the model.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), `CreateEmbeddingResponse`\> |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addEvents`](AbstractModel.md#addEvents)
#### Source
[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L235)
***
### addParams()
> **addParams**(`params`): [`EmbeddingModel`](EmbeddingModel.md)
Add the params. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `Partial`\<[`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md)\>\> |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addParams`](AbstractModel.md#addParams)
#### Source
[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L213)
***
### clone()
> **clone**(`args`?): [`EmbeddingModel`](EmbeddingModel.md)
Clone the model and merge/orverride the given properties.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.client`? | [`Client`](../namespaces/Model/namespaces/Embedding/type-aliases/Client.md) | - |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md)\> | - |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`clone`](AbstractModel.md#abstract-clone)
#### Source
[src/model/embedding.ts:154](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/embedding.ts#L154)
***
### getClient()
> **getClient**(): [`Client`](../namespaces/Model/namespaces/Embedding/type-aliases/Client.md)
Get the current client
#### Returns
[`Client`](../namespaces/Model/namespaces/Embedding/type-aliases/Client.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getClient`](AbstractModel.md#getClient)
#### Source
[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L180)
***
### getContext()
> **getContext**(): [`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
Get the current context
#### Returns
[`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getContext`](AbstractModel.md#getContext)
#### Source
[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L191)
***
### getEvents()
> **getEvents**(): [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), `CreateEmbeddingResponse`\>
Get the current event handlers
#### Returns
[`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), `CreateEmbeddingResponse`\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getEvents`](AbstractModel.md#getEvents)
#### Source
[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L230)
***
### getParams()
> **getParams**(): [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md)\>
Get the current params
#### Returns
[`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getParams`](AbstractModel.md#getParams)
#### Source
[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L208)
***
### run()
> **run**(`params`, `context`?): `Promise`\<[`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md)\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `object` |
| `params.batch`? | `Partial`\<[`BatchOptions`](../namespaces/Model/namespaces/Embedding/interfaces/BatchOptions.md)\> |
| `params.input`? | `string`[] |
| `params.model`? | `"text-embedding-ada-002"` \| `string` & `object` |
| `params.throttle`? | `Partial`\<`ThrottleOptions`\> |
| `context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`run`](AbstractModel.md#run)
#### Source
[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L78)
***
### setCache()
> **setCache**(`cache`): [`EmbeddingModel`](EmbeddingModel.md)
Set the cache to a new cache. Set to undefined to remove existing.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `cache` | `undefined` \| [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md)\> |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setCache`](AbstractModel.md#setCache)
#### Source
[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L174)
***
### setClient()
> **setClient**(`client`): [`EmbeddingModel`](EmbeddingModel.md)
Set the client to a new OpenAI API client.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `client` | [`Client`](../namespaces/Model/namespaces/Embedding/type-aliases/Client.md) |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setClient`](AbstractModel.md#setClient)
#### Source
[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L185)
***
### setContext()
> **setContext**(`context`): [`EmbeddingModel`](EmbeddingModel.md)
Set the context to a new context. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setContext`](AbstractModel.md#setContext)
#### Source
[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L202)
***
### setEvents()
> **setEvents**(`events`): [`EmbeddingModel`](EmbeddingModel.md)
Set the event handlers to a new set of events. Removes all existing event handlers.
Set to empty object `{}` to remove all events.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/Embedding/interfaces/Response.md), `CreateEmbeddingResponse`\> |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setEvents`](AbstractModel.md#setEvents)
#### Source
[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L244)
***
### setParams()
> **setParams**(`params`): [`EmbeddingModel`](EmbeddingModel.md)
Set the params to a new params. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | [`Config`](../namespaces/Model/namespaces/Embedding/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/Embedding/interfaces/Run.md)\> |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setParams`](AbstractModel.md#setParams)
#### Source
[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L223)
***
### updateContext()
> **updateContext**(`context`): [`EmbeddingModel`](EmbeddingModel.md)
Add the context. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`EmbeddingModel`](EmbeddingModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`updateContext`](AbstractModel.md#updateContext)
#### Source
[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L196)
+387
View File
@@ -0,0 +1,387 @@
# Class: Msg
Utility class for creating and checking message types.
## Constructors
### new Msg()
> **new Msg**(): [`Msg`](Msg.md)
#### Returns
[`Msg`](Msg.md)
## Methods
### assistant()
> **`static`** **assistant**(`content`, `opts`?): [`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md)
Create an assistant message. Cleans indentation and newlines by default.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `content` | `string` | - |
| `opts`? | `object` | - |
| `opts.cleanContent`? | `boolean` | Whether to clean extra newlines and indentation. Defaults to true. |
| `opts.name`? | `string` | Custom name for the message. |
#### Returns
[`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md)
#### Source
[src/prompt/utils/message.ts:52](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L52)
***
### funcCall()
> **`static`** **funcCall**(`function_call`, `opts`?): [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
Create a function call message with argumets.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `function_call` | `object` | - |
| `function_call.arguments` | `string` | Arguments to pass to the function. |
| `function_call.name`? | `string` | Name of the function to call. |
| `opts`? | `object` | - |
| `opts.name`? | `string` | The name descriptor for the message.(message.name) |
#### Returns
[`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
#### Source
[src/prompt/utils/message.ts:70](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L70)
***
### funcResult()
> **`static`** **funcResult**(`content`, `name`): [`FuncResult`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncResult.md)
Create a function result message.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `content` | `string` \| `object` \| `unknown`[] |
| `name` | `string` |
#### Returns
[`FuncResult`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncResult.md)
#### Source
[src/prompt/utils/message.ts:92](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L92)
***
### getMessage()
> **`static`** **getMessage**(`response`): [`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md) \| [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
Get the narrowed message from an EnrichedResponse.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `response` | `any` |
#### Returns
[`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md) \| [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
#### Source
[src/prompt/utils/message.ts:102](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L102)
***
### isAssistant()
> **`static`** **isAssistant**(`message`): `message is Assistant`
Check if a message is an assistant message.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`Msg`](../namespaces/Prompt/interfaces/Msg.md) |
#### Returns
`message is Assistant`
#### Source
[src/prompt/utils/message.ts:135](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L135)
***
### isFuncCall()
> **`static`** **isFuncCall**(`message`): `message is FuncCall`
Check if a message is a function call message with arguments.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`Msg`](../namespaces/Prompt/interfaces/Msg.md) |
#### Returns
`message is FuncCall`
#### Source
[src/prompt/utils/message.ts:139](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L139)
***
### isFuncResult()
> **`static`** **isFuncResult**(`message`): `message is FuncResult`
Check if a message is a function result message.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`Msg`](../namespaces/Prompt/interfaces/Msg.md) |
#### Returns
`message is FuncResult`
#### Source
[src/prompt/utils/message.ts:143](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L143)
***
### isSystem()
> **`static`** **isSystem**(`message`): `message is System`
Check if a message is a system message.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`Msg`](../namespaces/Prompt/interfaces/Msg.md) |
#### Returns
`message is System`
#### Source
[src/prompt/utils/message.ts:127](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L127)
***
### isUser()
> **`static`** **isUser**(`message`): `message is User`
Check if a message is a user message.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`Msg`](../namespaces/Prompt/interfaces/Msg.md) |
#### Returns
`message is User`
#### Source
[src/prompt/utils/message.ts:131](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L131)
***
### narrow()
#### narrow(message)
> **`static`** **narrow**(`message`): [`System`](../namespaces/Prompt/namespaces/Msg/type-aliases/System.md)
Narrow a ChatModel.Message to a specific type.
##### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`System`](../namespaces/Prompt/namespaces/Msg/type-aliases/System.md) |
##### Returns
[`System`](../namespaces/Prompt/namespaces/Msg/type-aliases/System.md)
##### Source
[src/prompt/utils/message.ts:148](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L148)
#### narrow(message)
> **`static`** **narrow**(`message`): [`User`](../namespaces/Prompt/namespaces/Msg/type-aliases/User.md)
##### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`User`](../namespaces/Prompt/namespaces/Msg/type-aliases/User.md) |
##### Returns
[`User`](../namespaces/Prompt/namespaces/Msg/type-aliases/User.md)
##### Source
[src/prompt/utils/message.ts:149](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L149)
#### narrow(message)
> **`static`** **narrow**(`message`): [`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md)
##### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md) |
##### Returns
[`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md)
##### Source
[src/prompt/utils/message.ts:150](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L150)
#### narrow(message)
> **`static`** **narrow**(`message`): [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
##### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md) |
##### Returns
[`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
##### Source
[src/prompt/utils/message.ts:151](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L151)
#### narrow(message)
> **`static`** **narrow**(`message`): [`FuncResult`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncResult.md)
##### Parameters
| Parameter | Type |
| :------ | :------ |
| `message` | [`FuncResult`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncResult.md) |
##### Returns
[`FuncResult`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncResult.md)
##### Source
[src/prompt/utils/message.ts:152](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L152)
***
### narrowResponseMessage()
> **`static`** **narrowResponseMessage**(`msg`): [`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md) \| [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
Narrow a message received from the API. It only responds with role=assistant
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `msg` | [`Msg`](../namespaces/Prompt/interfaces/Msg.md) |
#### Returns
[`Assistant`](../namespaces/Prompt/namespaces/Msg/type-aliases/Assistant.md) \| [`FuncCall`](../namespaces/Prompt/namespaces/Msg/type-aliases/FuncCall.md)
#### Source
[src/prompt/utils/message.ts:112](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L112)
***
### system()
> **`static`** **system**(`content`, `opts`?): [`System`](../namespaces/Prompt/namespaces/Msg/type-aliases/System.md)
Create a system message. Cleans indentation and newlines by default.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `content` | `string` | - |
| `opts`? | `object` | - |
| `opts.cleanContent`? | `boolean` | Whether to clean extra newlines and indentation. Defaults to true. |
| `opts.name`? | `string` | Custom name for the message. |
#### Returns
[`System`](../namespaces/Prompt/namespaces/Msg/type-aliases/System.md)
#### Source
[src/prompt/utils/message.ts:16](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L16)
***
### user()
> **`static`** **user**(`content`, `opts`?): [`User`](../namespaces/Prompt/namespaces/Msg/type-aliases/User.md)
Create a user message. Cleans indentation and newlines by default.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `content` | `string` | - |
| `opts`? | `object` | - |
| `opts.cleanContent`? | `boolean` | Whether to clean extra newlines and indentation. Defaults to true. |
| `opts.name`? | `string` | Custom name for the message. |
#### Returns
[`User`](../namespaces/Prompt/namespaces/Msg/type-aliases/User.md)
#### Source
[src/prompt/utils/message.ts:34](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/utils/message.ts#L34)
@@ -0,0 +1,168 @@
# Class: PineconeDatastore`<DocMeta>`
## Extends
- [`AbstractDatastore`](AbstractDatastore.md)\<`DocMeta`, `Pinecone.QueryFilter`\<`DocMeta`\>\>
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../namespaces/Datastore/type-aliases/BaseMeta.md) |
## Constructors
### new PineconeDatastore(args)
> **new PineconeDatastore**\<`DocMeta`\>(`args`): [`PineconeDatastore`](PineconeDatastore.md)\<`DocMeta`\>
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args` | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\> | Enables caching for queries. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\>, `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.contentKey` | keyof `DocMeta` | The metadata key of the content that is embedded.<br />The value associated with the key must be a string. |
| `args.context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.embeddingModel` | [`EmbeddingModel`](EmbeddingModel.md) | - |
| `args.events`? | [`Events`](../namespaces/Datastore/interfaces/Events.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\> | - |
| `args.namespace`? | `string` | - |
| `args.pinecone`? | `PineconeClient`\<`DocMeta`\> | - |
#### Returns
[`PineconeDatastore`](PineconeDatastore.md)\<`DocMeta`\>
#### Overrides
[`AbstractDatastore`](AbstractDatastore.md).[`constructor`](AbstractDatastore.md#Constructors)
#### Source
[src/datastore/pinecone/datastore.ts:14](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L14)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `datastoreProvider` | `"pinecone"` | - | [`AbstractDatastore`](AbstractDatastore.md).`datastoreProvider` | [src/datastore/pinecone/datastore.ts:11](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L11) |
| `datastoreType` | `"embedding"` | - | [`AbstractDatastore`](AbstractDatastore.md).`datastoreType` | [src/datastore/pinecone/datastore.ts:10](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L10) |
## Methods
### delete()
> **delete**(`docIds`): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docIds` | `string`[] |
#### Returns
`Promise`\<`void`\>
#### Overrides
[`AbstractDatastore`](AbstractDatastore.md).[`delete`](AbstractDatastore.md#abstract-delete)
#### Source
[src/datastore/pinecone/datastore.ts:153](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L153)
***
### deleteAll()
> **deleteAll**(): `Promise`\<`void`\>
#### Returns
`Promise`\<`void`\>
#### Overrides
[`AbstractDatastore`](AbstractDatastore.md).[`deleteAll`](AbstractDatastore.md#abstract-deleteAll)
#### Source
[src/datastore/pinecone/datastore.ts:157](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L157)
***
### query()
> **query**(`query`, `context`?): `Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `query` | [`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\> |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Inherited from
[`AbstractDatastore`](AbstractDatastore.md).[`query`](AbstractDatastore.md#query)
#### Source
[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L53)
***
### runQuery()
> **runQuery**(`query`, `context`?): `Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `query` | [`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\> |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Overrides
AbstractDatastore.runQuery
#### Source
[src/datastore/pinecone/datastore.ts:30](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L30)
***
### upsert()
> **upsert**(`docs`, `context`?): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docs` | [`Doc`](../namespaces/Datastore/interfaces/Doc.md)\<`DocMeta`\>[] |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<`void`\>
#### Overrides
[`AbstractDatastore`](AbstractDatastore.md).[`upsert`](AbstractDatastore.md#abstract-upsert)
#### Source
[src/datastore/pinecone/datastore.ts:74](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/datastore.ts#L74)
@@ -0,0 +1,169 @@
# Class: PineconeHybridDatastore`<DocMeta>`
## Extends
- [`AbstractHybridDatastore`](AbstractHybridDatastore.md)\<`DocMeta`, `Pinecone.QueryFilter`\<`DocMeta`\>\>
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../namespaces/Datastore/type-aliases/BaseMeta.md) |
## Constructors
### new PineconeHybridDatastore(args)
> **new PineconeHybridDatastore**\<`DocMeta`\>(`args`): [`PineconeHybridDatastore`](PineconeHybridDatastore.md)\<`DocMeta`\>
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args` | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\> | Enables caching for queries. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\>, `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.contentKey` | keyof `DocMeta` | The metadata key of the content that is embedded.<br />The value associated with the key must be a string. |
| `args.context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.embeddingModel` | [`EmbeddingModel`](EmbeddingModel.md) | - |
| `args.events`? | [`Events`](../namespaces/Datastore/interfaces/Events.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\> | - |
| `args.namespace`? | `string` | - |
| `args.pinecone`? | `PineconeClient`\<`DocMeta`\> | - |
| `args.spladeModel` | [`SparseVectorModel`](SparseVectorModel.md) | Splade instance for creating sparse vectors |
#### Returns
[`PineconeHybridDatastore`](PineconeHybridDatastore.md)\<`DocMeta`\>
#### Overrides
[`AbstractHybridDatastore`](AbstractHybridDatastore.md).[`constructor`](AbstractHybridDatastore.md#Constructors)
#### Source
[src/datastore/pinecone/hybrid-datastore.ts:15](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L15)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `datastoreProvider` | `"pinecone"` | - | [`AbstractHybridDatastore`](AbstractHybridDatastore.md).`datastoreProvider` | [src/datastore/pinecone/hybrid-datastore.ts:12](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L12) |
| `datastoreType` | `"hybrid"` | - | [`AbstractHybridDatastore`](AbstractHybridDatastore.md).`datastoreType` | [src/datastore/pinecone/hybrid-datastore.ts:11](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L11) |
## Methods
### delete()
> **delete**(`docIds`): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docIds` | `string`[] |
#### Returns
`Promise`\<`void`\>
#### Overrides
[`AbstractHybridDatastore`](AbstractHybridDatastore.md).[`delete`](AbstractHybridDatastore.md#abstract-delete)
#### Source
[src/datastore/pinecone/hybrid-datastore.ts:176](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L176)
***
### deleteAll()
> **deleteAll**(): `Promise`\<`void`\>
#### Returns
`Promise`\<`void`\>
#### Overrides
[`AbstractHybridDatastore`](AbstractHybridDatastore.md).[`deleteAll`](AbstractHybridDatastore.md#abstract-deleteAll)
#### Source
[src/datastore/pinecone/hybrid-datastore.ts:180](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L180)
***
### query()
> **query**(`query`, `context`?): `Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `query` | [`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\> |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Inherited from
[`AbstractHybridDatastore`](AbstractHybridDatastore.md).[`query`](AbstractHybridDatastore.md#query)
#### Source
[src/datastore/datastore.ts:53](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/datastore.ts#L53)
***
### runQuery()
> **runQuery**(`query`, `context`?): `Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `query` | [`Query`](../namespaces/Datastore/interfaces/Query.md)\<`DocMeta`, `QueryFilter`\<`DocMeta`\>\> |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`QueryResult`](../namespaces/Datastore/interfaces/QueryResult.md)\<`DocMeta`\>\>
#### Overrides
AbstractHybridDatastore.runQuery
#### Source
[src/datastore/pinecone/hybrid-datastore.ts:31](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L31)
***
### upsert()
> **upsert**(`docs`, `context`?): `Promise`\<`void`\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `docs` | [`Doc`](../namespaces/Datastore/interfaces/Doc.md)\<`DocMeta`\>[] |
| `context`? | [`Ctx`](../namespaces/Datastore/type-aliases/Ctx.md) |
#### Returns
`Promise`\<`void`\>
#### Overrides
[`AbstractHybridDatastore`](AbstractHybridDatastore.md).[`upsert`](AbstractHybridDatastore.md#abstract-upsert)
#### Source
[src/datastore/pinecone/hybrid-datastore.ts:89](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/hybrid-datastore.ts#L89)
@@ -0,0 +1,397 @@
# Class: SparseVectorModel
## Extends
- [`AbstractModel`](AbstractModel.md)\<[`Client`](../namespaces/Model/namespaces/SparseVector/type-aliases/Client.md), [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md)\>
## Constructors
### new SparseVectorModel(args)
> **new SparseVectorModel**(`args`): [`SparseVectorModel`](SparseVectorModel.md)
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args` | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md), `any`\> | - |
| `args.params` | [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md)\> | - |
| `args.serviceUrl`? | `string` | - |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`constructor`](AbstractModel.md#Constructors)
#### Source
[src/model/sparse-vector.ts:33](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/sparse-vector.ts#L33)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `modelProvider` | `"custom"` | - | [`AbstractModel`](AbstractModel.md).`modelProvider` | [src/model/sparse-vector.ts:30](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/sparse-vector.ts#L30) |
| `modelType` | `"sparse-vector"` | - | [`AbstractModel`](AbstractModel.md).`modelType` | [src/model/sparse-vector.ts:29](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/sparse-vector.ts#L29) |
| `serviceUrl` | `string` | - | - | [src/model/sparse-vector.ts:31](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/sparse-vector.ts#L31) |
| `tokenizer` | [`ITokenizer`](../namespaces/Model/interfaces/ITokenizer.md) | - | [`AbstractModel`](AbstractModel.md).`tokenizer` | [src/model/model.ts:65](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L65) |
## Methods
### addEvents()
> **addEvents**(`events`): [`SparseVectorModel`](SparseVectorModel.md)
Add event handlers to the model.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md), `any`\> |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addEvents`](AbstractModel.md#addEvents)
#### Source
[src/model/model.ts:235](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L235)
***
### addParams()
> **addParams**(`params`): [`SparseVectorModel`](SparseVectorModel.md)
Add the params. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `Partial`\<[`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md)\>\> |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`addParams`](AbstractModel.md#addParams)
#### Source
[src/model/model.ts:213](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L213)
***
### clone()
> **clone**(`args`?): [`SparseVectorModel`](SparseVectorModel.md)
Clone the model and merge/orverride the given properties.
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args`? | `object` | - |
| `args.cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md)\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). |
| `args.cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. |
| `args.context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - |
| `args.debug`? | `boolean` | Whether or not to add default `console.log` event handlers |
| `args.events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md), `any`\> | - |
| `args.params`? | [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md)\> | - |
| `args.serviceUrl`? | `string` | - |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Overrides
[`AbstractModel`](AbstractModel.md).[`clone`](AbstractModel.md#abstract-clone)
#### Source
[src/model/sparse-vector.ts:105](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/sparse-vector.ts#L105)
***
### getClient()
> **getClient**(): [`Client`](../namespaces/Model/namespaces/SparseVector/type-aliases/Client.md)
Get the current client
#### Returns
[`Client`](../namespaces/Model/namespaces/SparseVector/type-aliases/Client.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getClient`](AbstractModel.md#getClient)
#### Source
[src/model/model.ts:180](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L180)
***
### getContext()
> **getContext**(): [`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
Get the current context
#### Returns
[`Ctx`](../namespaces/Model/type-aliases/Ctx.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getContext`](AbstractModel.md#getContext)
#### Source
[src/model/model.ts:191](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L191)
***
### getEvents()
> **getEvents**(): [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md), `any`\>
Get the current event handlers
#### Returns
[`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md), `any`\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getEvents`](AbstractModel.md#getEvents)
#### Source
[src/model/model.ts:230](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L230)
***
### getParams()
> **getParams**(): [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md)\>
Get the current params
#### Returns
[`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`getParams`](AbstractModel.md#getParams)
#### Source
[src/model/model.ts:208](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L208)
***
### run()
> **run**(`params`, `context`?): `Promise`\<[`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md)\>
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `object` |
| `params.concurrency`? | `number` |
| `params.input`? | `string`[] |
| `params.model`? | `string` |
| `params.throttleInterval`? | `number` |
| `params.throttleLimit`? | `number` |
| `context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
`Promise`\<[`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md)\>
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`run`](AbstractModel.md#run)
#### Source
[src/model/model.ts:78](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L78)
***
### setCache()
> **setCache**(`cache`): [`SparseVectorModel`](SparseVectorModel.md)
Set the cache to a new cache. Set to undefined to remove existing.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `cache` | `undefined` \| [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md)\> |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setCache`](AbstractModel.md#setCache)
#### Source
[src/model/model.ts:174](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L174)
***
### setClient()
> **setClient**(`client`): [`SparseVectorModel`](SparseVectorModel.md)
Set the client to a new OpenAI API client.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `client` | [`Client`](../namespaces/Model/namespaces/SparseVector/type-aliases/Client.md) |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setClient`](AbstractModel.md#setClient)
#### Source
[src/model/model.ts:185](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L185)
***
### setContext()
> **setContext**(`context`): [`SparseVectorModel`](SparseVectorModel.md)
Set the context to a new context. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setContext`](AbstractModel.md#setContext)
#### Source
[src/model/model.ts:202](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L202)
***
### setEvents()
> **setEvents**(`events`): [`SparseVectorModel`](SparseVectorModel.md)
Set the event handlers to a new set of events. Removes all existing event handlers.
Set to empty object `{}` to remove all events.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `events` | [`Events`](../namespaces/Model/interfaces/Events.md)\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md) & [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md), [`Response`](../namespaces/Model/namespaces/SparseVector/interfaces/Response.md), `any`\> |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setEvents`](AbstractModel.md#setEvents)
#### Source
[src/model/model.ts:244](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L244)
***
### setParams()
> **setParams**(`params`): [`SparseVectorModel`](SparseVectorModel.md)
Set the params to a new params. Removes all existing values.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | [`Config`](../namespaces/Model/namespaces/SparseVector/interfaces/Config.md) & `Partial`\<[`Run`](../namespaces/Model/namespaces/SparseVector/interfaces/Run.md)\> |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`setParams`](AbstractModel.md#setParams)
#### Source
[src/model/model.ts:223](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L223)
***
### updateContext()
> **updateContext**(`context`): [`SparseVectorModel`](SparseVectorModel.md)
Add the context. Overrides existing keys.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `context` | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) |
#### Returns
[`SparseVectorModel`](SparseVectorModel.md)
#### Inherited from
[`AbstractModel`](AbstractModel.md).[`updateContext`](AbstractModel.md#updateContext)
#### Source
[src/model/model.ts:196](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L196)
+93
View File
@@ -0,0 +1,93 @@
# Class: VectorUtils
Utilities for working with vectors/embeddings.
## Constructors
### new VectorUtils()
> **new VectorUtils**(): [`VectorUtils`](VectorUtils.md)
#### Returns
[`VectorUtils`](VectorUtils.md)
## Methods
### cosineSimilarity()
> **`static`** **cosineSimilarity**(`a`, `b`): `number`
Calculate the cosine similarity between two vectors.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `a` | `number`[] |
| `b` | `number`[] |
#### Returns
`number`
#### Source
[src/datastore/utils/vectors.ts:4](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/utils/vectors.ts#L4)
***
### dotProduct()
> **`static`** **dotProduct**(`a`, `b`): `number`
Calculate the dot product of two vectors
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `a` | `number`[] |
| `b` | `number`[] |
#### Returns
`number`
#### Source
[src/datastore/utils/vectors.ts:34](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/utils/vectors.ts#L34)
***
### nearestNeighbors()
> **`static`** **nearestNeighbors**\<`D`\>(`args`): `D` & `object`[]
Find the nearest neighbors of a vector in a set of documents with embeddings.
#### Type parameters
| Parameter |
| :------ |
| `D` extends `object` |
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `args` | `object` |
| `args.distanceFunction`? | `"cosineSimilarity"` \| `"dotProduct"` |
| `args.docs` | `D`[] |
| `args.topK` | `number` |
| `args.vector` | `number`[] |
#### Returns
`D` & `object`[]
The k nearest neighbors of the vector with the similarity score added (sorted by similarity).
#### Source
[src/datastore/utils/vectors.ts:59](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/utils/vectors.ts#L59)
+13
View File
@@ -0,0 +1,13 @@
{
"AbstractDatastore": "AbstractDatastore",
"AbstractHybridDatastore": "AbstractHybridDatastore",
"AbstractModel": "AbstractModel",
"ChatModel": "ChatModel",
"CompletionModel": "CompletionModel",
"EmbeddingModel": "EmbeddingModel",
"Msg": "Msg",
"PineconeDatastore": "PineconeDatastore",
"PineconeHybridDatastore": "PineconeHybridDatastore",
"SparseVectorModel": "SparseVectorModel",
"VectorUtils": "VectorUtils"
}
+52
View File
@@ -0,0 +1,52 @@
# API Reference
## Exports
### Namespaces
- [Datastore](namespaces/Datastore/README.md)
- [Model](namespaces/Model/README.md)
- [Prompt](namespaces/Prompt/README.md)
### Classes
- [AbstractDatastore](classes/AbstractDatastore.md)
- [AbstractHybridDatastore](classes/AbstractHybridDatastore.md)
- [AbstractModel](classes/AbstractModel.md)
- [ChatModel](classes/ChatModel.md)
- [CompletionModel](classes/CompletionModel.md)
- [EmbeddingModel](classes/EmbeddingModel.md)
- [Msg](classes/Msg.md)
- [PineconeDatastore](classes/PineconeDatastore.md)
- [PineconeHybridDatastore](classes/PineconeHybridDatastore.md)
- [SparseVectorModel](classes/SparseVectorModel.md)
- [VectorUtils](classes/VectorUtils.md)
### Interfaces
- [ModelArgs](interfaces/ModelArgs.md)
### Type Aliases
- [CacheKey](type-aliases/CacheKey.md)
- [CacheStorage](type-aliases/CacheStorage.md)
- [ChatModelArgs](type-aliases/ChatModelArgs.md)
- [CompletionModelArgs](type-aliases/CompletionModelArgs.md)
- [EmbeddingModelArgs](type-aliases/EmbeddingModelArgs.md)
- [Prettify](type-aliases/Prettify.md)
- [SparseVectorModelArgs](type-aliases/SparseVectorModelArgs.md)
### Functions
- [calculateCost](functions/calculateCost.md)
- [createAIFunction](functions/createAIFunction.md)
- [createOpenAIClient](functions/createOpenAIClient.md)
- [createPineconeClient](functions/createPineconeClient.md)
- [createTokenizer](functions/createTokenizer.md)
- [deepMerge](functions/deepMerge.md)
- [defaultCacheKey](functions/defaultCacheKey.md)
- [extractJsonObject](functions/extractJsonObject.md)
- [extractZodObject](functions/extractZodObject.md)
- [omit](functions/omit.md)
- [pick](functions/pick.md)
- [zodToJsonSchema](functions/zodToJsonSchema.md)
+14
View File
@@ -0,0 +1,14 @@
{
"calculateCost": "calculateCost",
"createAIFunction": "createAIFunction",
"createOpenAIClient": "createOpenAIClient",
"createPineconeClient": "createPineconeClient",
"createTokenizer": "createTokenizer",
"deepMerge": "deepMerge",
"defaultCacheKey": "defaultCacheKey",
"extractJsonObject": "extractJsonObject",
"extractZodObject": "extractZodObject",
"omit": "omit",
"pick": "pick",
"zodToJsonSchema": "zodToJsonSchema"
}
@@ -0,0 +1,23 @@
# Function: calculateCost()
> **calculateCost**(`args`): `number` \| `undefined`
Calculate the cost (in cents) for the given model and tokens.
## Parameters
| Parameter | Type |
| :------ | :------ |
| `args` | `object` |
| `args.model` | `string` |
| `args.tokens`? | `object` |
| `args.tokens.completion_tokens`? | `number` |
| `args.tokens.prompt_tokens` | `number` |
## Returns
`number` \| `undefined`
## Source
[src/model/utils/calculate-cost.ts:60](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/utils/calculate-cost.ts#L60)
@@ -0,0 +1,36 @@
# Function: createAIFunction()
> **createAIFunction**\<`Schema`, `Return`\>(`spec`, `implementation`): [`AIFunction`](../namespaces/Prompt/interfaces/AIFunction.md)\<`Schema`, `Return`\>
Create a function meant to be used with OpenAI function calling.
The returned function will parse the arguments string and call the
implementation function with the parsed arguments.
The `spec` property of the returned function is the spec for adding the
function to the OpenAI API `functions` property.
## Type parameters
| Parameter |
| :------ |
| `Schema` extends `ZodObject`\<`any`, `UnknownKeysParam`, `ZodTypeAny`, `object`, `object`\> |
| `Return` extends `unknown` |
## Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `spec` | `object` | - |
| `spec.argsSchema` | `Schema` | Zod schema for the arguments string. |
| `spec.description`? | `string` | Description of the function. |
| `spec.name` | `string` | Name of the function. |
| `implementation` | (`params`) => `Promise`\<`Return`\> | Implementation of the function to call with the parsed arguments. |
## Returns
[`AIFunction`](../namespaces/Prompt/interfaces/AIFunction.md)\<`Schema`, `Return`\>
## Source
[src/prompt/functions/ai-function.ts:16](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/functions/ai-function.ts#L16)
@@ -0,0 +1,20 @@
# Function: createOpenAIClient()
> **createOpenAIClient**(`opts`?, `forceNew`?): `OpenAIClient`
Create a new openai-fetch OpenAIClient.
## Parameters
| Parameter | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `opts`? | `ConfigOpts` | `undefined` | Options to pass to the OpenAI client. |
| `forceNew`? | `boolean` | `false` | Force a new client to be created. |
## Returns
`OpenAIClient`
## Source
[src/model/clients/openai.ts:8](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/clients/openai.ts#L8)
@@ -0,0 +1,25 @@
# Function: createPineconeClient()
> **createPineconeClient**\<`Meta`\>(`config`): `PineconeClient`\<`Meta`\>
Create a new Pinecone client instance.
## Type parameters
| Parameter | Default |
| :------ | :------ |
| `Meta` extends `JsonObject` | `object` |
## Parameters
| Parameter | Type |
| :------ | :------ |
| `config` | `ConfigOpts` |
## Returns
`PineconeClient`\<`Meta`\>
## Source
[src/datastore/pinecone/client.ts:7](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/pinecone/client.ts#L7)
@@ -0,0 +1,19 @@
# Function: createTokenizer()
> **createTokenizer**(`model`): `Tokenizer`
Create a tokenizer for a specific model
## Parameters
| Parameter | Type |
| :------ | :------ |
| `model` | `string` |
## Returns
`Tokenizer`
## Source
[src/model/utils/tokenizer.ts:10](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/utils/tokenizer.ts#L10)
+25
View File
@@ -0,0 +1,25 @@
# Function: deepMerge()
> **deepMerge**\<`T1`, `T2`\>(`target`, `source`): `DeepMerge`\<`T1`, `T2`\>
## Type parameters
| Parameter |
| :------ |
| `T1` |
| `T2` |
## Parameters
| Parameter | Type |
| :------ | :------ |
| `target` | `T1` |
| `source` | `T2` |
## Returns
`DeepMerge`\<`T1`, `T2`\>
## Source
node\_modules/.pnpm/@fastify+deepmerge@1.3.0/node\_modules/@fastify/deepmerge/types/index.d.ts:1
@@ -0,0 +1,23 @@
# Function: defaultCacheKey()
> **defaultCacheKey**\<`Params`\>(`params`): `string`
## Type parameters
| Parameter |
| :------ |
| `Params` extends `Record`\<`string`, `any`\> |
## Parameters
| Parameter | Type |
| :------ | :------ |
| `params` | `Params` |
## Returns
`string`
## Source
[src/utils/cache.ts:12](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/utils/cache.ts#L12)
@@ -0,0 +1,19 @@
# Function: extractJsonObject()
> **extractJsonObject**(`str`): `JsonObject`
Extract a JSON object from a string.
## Parameters
| Parameter | Type |
| :------ | :------ |
| `str` | `string` |
## Returns
`JsonObject`
## Source
[src/prompt/functions/extract-json.ts:6](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/functions/extract-json.ts#L6)
@@ -0,0 +1,28 @@
# Function: extractZodObject()
> **extractZodObject**\<`Schema`\>(`args`): `z.infer`\<`Schema`\>
Extract an object from a JSON string and validate it against a Zod schema.
Throws an error with a message optimized for GPT readability if it fails.
## Type parameters
| Parameter |
| :------ |
| `Schema` extends `ZodObject`\<`any`, `UnknownKeysParam`, `ZodTypeAny`, `object`, `object`\> |
## Parameters
| Parameter | Type |
| :------ | :------ |
| `args` | `object` |
| `args.json` | `string` |
| `args.schema` | `Schema` |
## Returns
`z.infer`\<`Schema`\>
## Source
[src/prompt/functions/extract-zod-object.ts:9](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/functions/extract-zod-object.ts#L9)
+33
View File
@@ -0,0 +1,33 @@
# Function: omit()
> **omit**\<`T`, `K`\>(`obj`, ...`keys`): `Omit`\<`T`, `K`\>
From `obj`, create a new object that does not include `keys`.
## Type parameters
| Parameter |
| :------ |
| `T` extends `Record`\<`any`, `unknown`\> |
| `K` extends `string` \| `number` \| `symbol` |
## Parameters
| Parameter | Type |
| :------ | :------ |
| `obj` | `T` |
| ...`keys` | `K`[] |
## Returns
`Omit`\<`T`, `K`\>
## Example
```
omit({ a: 1, b: 2, c: 3 }, 'a', 'c') // { b: 2 }
```
## Source
[src/utils/helpers.ts:17](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/utils/helpers.ts#L17)
+33
View File
@@ -0,0 +1,33 @@
# Function: pick()
> **pick**\<`T`, `K`\>(`obj`, ...`keys`): `Pick`\<`T`, `K`\>
From `obj`, create a new object that only includes `keys`.
## Type parameters
| Parameter |
| :------ |
| `T` extends `Record`\<`any`, `unknown`\> |
| `K` extends `string` \| `number` \| `symbol` |
## Parameters
| Parameter | Type |
| :------ | :------ |
| `obj` | `T` |
| ...`keys` | `K`[] |
## Returns
`Pick`\<`T`, `K`\>
## Example
```
pick({ a: 1, b: 2, c: 3 }, 'a', 'c') // { a: 1, c: 3 }
```
## Source
[src/utils/helpers.ts:33](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/utils/helpers.ts#L33)
@@ -0,0 +1,19 @@
# Function: zodToJsonSchema()
> **zodToJsonSchema**(`schema`): `Record`\<`string`, `unknown`\>
Generate a JSON Schema from a Zod schema.
## Parameters
| Parameter | Type |
| :------ | :------ |
| `schema` | `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
## Returns
`Record`\<`string`, `unknown`\>
## Source
[src/prompt/functions/zod-to-json.ts:6](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/prompt/functions/zod-to-json.ts#L6)
+22
View File
@@ -0,0 +1,22 @@
# Interface: ModelArgs`<MClient, MConfig, MRun, MResponse>`
## Type parameters
| Parameter |
| :------ |
| `MClient` extends [`Client`](../namespaces/Model/namespaces/Base/type-aliases/Client.md) |
| `MConfig` extends [`Config`](../namespaces/Model/namespaces/Base/interfaces/Config.md) |
| `MRun` extends [`Run`](../namespaces/Model/namespaces/Base/interfaces/Run.md) |
| `MResponse` extends [`Response`](../namespaces/Model/namespaces/Base/interfaces/Response.md) |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `cache`? | [`CacheStorage`](../type-aliases/CacheStorage.md)\<`string`, `MResponse`\> | Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). | [src/model/model.ts:29](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L29) |
| `cacheKey`? | [`CacheKey`](../type-aliases/CacheKey.md)\<`MRun` & `MConfig`, `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. | [src/model/model.ts:23](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L23) |
| `client` | `MClient` | - | [src/model/model.ts:30](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L30) |
| `context`? | [`Ctx`](../namespaces/Model/type-aliases/Ctx.md) | - | [src/model/model.ts:31](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L31) |
| `debug`? | `boolean` | Whether or not to add default `console.log` event handlers | [src/model/model.ts:35](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L35) |
| `events`? | [`Events`](../namespaces/Model/interfaces/Events.md)\<`MRun` & `MConfig`, `MResponse`, `any`\> | - | [src/model/model.ts:33](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L33) |
| `params` | `MConfig` & `Partial`\<`MRun`\> | - | [src/model/model.ts:32](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/model.ts#L32) |
@@ -0,0 +1,24 @@
# Namespace: Datastore
Generic Datastore extended by provider-specific implementations.
## Index
### Interfaces
- [Doc](interfaces/Doc.md)
- [Events](interfaces/Events.md)
- [Opts](interfaces/Opts.md)
- [OptsHybrid](interfaces/OptsHybrid.md)
- [Query](interfaces/Query.md)
- [QueryResult](interfaces/QueryResult.md)
- [ScoredDoc](interfaces/ScoredDoc.md)
### Type Aliases
- [BaseFilter](type-aliases/BaseFilter.md)
- [BaseMeta](type-aliases/BaseMeta.md)
- [Ctx](type-aliases/Ctx.md)
- [Datastore](type-aliases/Datastore.md)
- [Provider](type-aliases/Provider.md)
- [Type](type-aliases/Type.md)
@@ -0,0 +1,23 @@
# Interface: Doc`<Meta>`
A Doc is the unit of storage for data in a Datastore
## Extended By
- [`ScoredDoc`](ScoredDoc.md)
## Type parameters
| Parameter | Default |
| :------ | :------ |
| `Meta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) | [`BaseMeta`](../type-aliases/BaseMeta.md) |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `embedding`? | `number`[] | - | [src/datastore/types.ts:22](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L22) |
| `id` | `string` | - | [src/datastore/types.ts:20](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L20) |
| `metadata` | `Meta` | - | [src/datastore/types.ts:21](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L21) |
| `score`? | `number` | - | [src/datastore/types.ts:24](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L24) |
| `sparseVector`? | [`Vector`](../../Model/namespaces/SparseVector/type-aliases/Vector.md) | - | [src/datastore/types.ts:23](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L23) |
@@ -0,0 +1,18 @@
# Interface: Events`<DocMeta, Filter>`
Event handlers for logging and debugging
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) |
| `Filter` extends [`BaseFilter`](../type-aliases/BaseFilter.md)\<`DocMeta`\> |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `onError`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/datastore/types.ts:51](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L51) |
| `onQueryComplete`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/datastore/types.ts:41](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L41) |
| `onQueryStart`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/datastore/types.ts:34](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L34) |
@@ -0,0 +1,27 @@
# Interface: Opts`<DocMeta, Filter>`
Options for creating a Datastore instance.
## Extended By
- [`OptsHybrid`](OptsHybrid.md)
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) |
| `Filter` extends [`BaseFilter`](../type-aliases/BaseFilter.md)\<`DocMeta`\> |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `cache`? | [`CacheStorage`](../../../type-aliases/CacheStorage.md)\<`string`, [`QueryResult`](QueryResult.md)\<`DocMeta`\>\> | Enables caching for queries. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). | [src/datastore/types.ts:95](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L95) |
| `cacheKey`? | [`CacheKey`](../../../type-aliases/CacheKey.md)\<[`Query`](Query.md)\<`DocMeta`, `Filter`\>, `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. | [src/datastore/types.ts:89](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L89) |
| `contentKey` | keyof `DocMeta` | The metadata key of the content that is embedded.<br />The value associated with the key must be a string. | [src/datastore/types.ts:79](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L79) |
| `context`? | [`Ctx`](../type-aliases/Ctx.md) | - | [src/datastore/types.ts:97](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L97) |
| `debug`? | `boolean` | Whether or not to add default `console.log` event handlers | [src/datastore/types.ts:99](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L99) |
| `embeddingModel` | [`EmbeddingModel`](../../../classes/EmbeddingModel.md) | - | [src/datastore/types.ts:81](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L81) |
| `events`? | [`Events`](Events.md)\<`DocMeta`, `Filter`\> | - | [src/datastore/types.ts:96](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L96) |
| `namespace`? | `string` | - | [src/datastore/types.ts:80](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L80) |
@@ -0,0 +1,28 @@
# Interface: OptsHybrid`<DocMeta, Filter>`
Options for creating a hybrid Datastore instance (with Splade).
## Extends
- [`Opts`](Opts.md)\<`DocMeta`, `Filter`\>
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) |
| `Filter` extends [`BaseFilter`](../type-aliases/BaseFilter.md)\<`DocMeta`\> |
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `cache`? | [`CacheStorage`](../../../type-aliases/CacheStorage.md)\<`string`, [`QueryResult`](QueryResult.md)\<`DocMeta`\>\> | Enables caching for queries. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async.<br /><br />Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). | [`Opts`](Opts.md).`cache` | [src/datastore/types.ts:95](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L95) |
| `cacheKey`? | [`CacheKey`](../../../type-aliases/CacheKey.md)\<[`Query`](Query.md)\<`DocMeta`, `Filter`\>, `string`\> | A function that returns a cache key for the given params.<br /><br />A simple example would be: `(params) => JSON.stringify(params)`<br /><br />The default `cacheKey` function uses [hash-obj](https://github.com/sindresorhus/hash-obj) to create a stable sha256 hash of the params. | [`Opts`](Opts.md).`cacheKey` | [src/datastore/types.ts:89](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L89) |
| `contentKey` | keyof `DocMeta` | The metadata key of the content that is embedded.<br />The value associated with the key must be a string. | [`Opts`](Opts.md).`contentKey` | [src/datastore/types.ts:79](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L79) |
| `context`? | [`Ctx`](../type-aliases/Ctx.md) | - | [`Opts`](Opts.md).`context` | [src/datastore/types.ts:97](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L97) |
| `debug`? | `boolean` | Whether or not to add default `console.log` event handlers | [`Opts`](Opts.md).`debug` | [src/datastore/types.ts:99](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L99) |
| `embeddingModel` | [`EmbeddingModel`](../../../classes/EmbeddingModel.md) | - | [`Opts`](Opts.md).`embeddingModel` | [src/datastore/types.ts:81](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L81) |
| `events`? | [`Events`](Events.md)\<`DocMeta`, `Filter`\> | - | [`Opts`](Opts.md).`events` | [src/datastore/types.ts:96](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L96) |
| `namespace`? | `string` | - | [`Opts`](Opts.md).`namespace` | [src/datastore/types.ts:80](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L80) |
| `spladeModel` | [`SparseVectorModel`](../../../classes/SparseVectorModel.md) | Splade instance for creating sparse vectors | - | [src/datastore/types.ts:110](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L110) |
@@ -0,0 +1,23 @@
# Interface: Query`<Meta, Filter>`
Arguments to run a query.
## Type parameters
| Parameter |
| :------ |
| `Meta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) |
| `Filter` extends [`BaseFilter`](../type-aliases/BaseFilter.md)\<`Meta`\> |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `embedding`? | `number`[] | - | [src/datastore/types.ts:124](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L124) |
| `filter`? | `Filter` | - | [src/datastore/types.ts:128](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L128) |
| `hybridAlpha`? | `number` | - | [src/datastore/types.ts:130](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L130) |
| `includeValues`? | `boolean` | - | [src/datastore/types.ts:129](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L129) |
| `minScore`? | `number` | - | [src/datastore/types.ts:127](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L127) |
| `query` | `string` | - | [src/datastore/types.ts:123](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L123) |
| `sparseVector`? | [`Vector`](../../Model/namespaces/SparseVector/type-aliases/Vector.md) | - | [src/datastore/types.ts:125](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L125) |
| `topK`? | `number` | - | [src/datastore/types.ts:126](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L126) |
@@ -0,0 +1,17 @@
# Interface: QueryResult`<Meta>`
The results of running a query.
## Type parameters
| Parameter |
| :------ |
| `Meta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `cached`? | `boolean` | - | [src/datastore/types.ts:143](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L143) |
| `docs` | [`ScoredDoc`](ScoredDoc.md)\<`Meta`\>[] | - | [src/datastore/types.ts:142](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L142) |
| `query` | `string` | - | [src/datastore/types.ts:141](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L141) |
@@ -0,0 +1,23 @@
# Interface: ScoredDoc`<Meta>`
Document with a query score (vector distance/similarity).
## Extends
- [`Doc`](Doc.md)\<`Meta`\>
## Type parameters
| Parameter | Default |
| :------ | :------ |
| `Meta` extends [`BaseMeta`](../type-aliases/BaseMeta.md) | [`BaseMeta`](../type-aliases/BaseMeta.md) |
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `embedding`? | `number`[] | - | [`Doc`](Doc.md).`embedding` | [src/datastore/types.ts:22](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L22) |
| `id` | `string` | - | [`Doc`](Doc.md).`id` | [src/datastore/types.ts:20](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L20) |
| `metadata` | `Meta` | - | [`Doc`](Doc.md).`metadata` | [src/datastore/types.ts:21](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L21) |
| `score` | `number` | - | [`Doc`](Doc.md).`score` | [src/datastore/types.ts:151](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L151) |
| `sparseVector`? | [`Vector`](../../Model/namespaces/SparseVector/type-aliases/Vector.md) | - | [`Doc`](Doc.md).`sparseVector` | [src/datastore/types.ts:23](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L23) |
@@ -0,0 +1,9 @@
{
"Doc": "Doc",
"Events": "Events",
"Opts": "Opts",
"OptsHybrid": "OptsHybrid",
"Query": "Query",
"QueryResult": "QueryResult",
"ScoredDoc": "ScoredDoc"
}
@@ -0,0 +1,13 @@
# Type alias: BaseFilter`<Meta>`
> **BaseFilter**\<`Meta`\>: `any`
## Type parameters
| Parameter |
| :------ |
| `Meta` extends [`BaseMeta`](BaseMeta.md) |
## Source
[src/datastore/types.ts:135](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L135)
@@ -0,0 +1,9 @@
# Type alias: BaseMeta
> **BaseMeta**: `object`
Base document metadata to be extended
## Source
[src/datastore/types.ts:13](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L13)
@@ -0,0 +1,13 @@
# Type alias: Ctx
> **Ctx**: `object`
Generic metadata object.
## Index signature
\[`key`: `string`\]: `any`
## Source
[src/datastore/types.ts:16](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L16)
@@ -0,0 +1,16 @@
# Type alias: Datastore`<DocMeta, Filter>`
> **Datastore**\<`DocMeta`, `Filter`\>: [`AbstractDatastore`](../../../classes/AbstractDatastore.md)\<`DocMeta`, `Filter`\>
Abstract Datastore extended by provider specific implementations.
## Type parameters
| Parameter |
| :------ |
| `DocMeta` extends [`BaseMeta`](BaseMeta.md) |
| `Filter` extends [`BaseFilter`](BaseFilter.md)\<`DocMeta`\> |
## Source
[src/datastore/types.ts:63](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L63)
@@ -0,0 +1,9 @@
# Type alias: Provider
> **Provider**: `string` & `object` \| `"pinecone"` \| `"custom"`
The provider of the vector database.
## Source
[src/datastore/types.ts:114](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L114)
@@ -0,0 +1,9 @@
# Type alias: Type
> **Type**: `string` & `object` \| `"embedding"` \| `"hybrid"`
The type of embedding model.
## Source
[src/datastore/types.ts:155](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/datastore/types.ts#L155)
@@ -0,0 +1,8 @@
{
"BaseFilter": "BaseFilter",
"BaseMeta": "BaseMeta",
"Ctx": "Ctx",
"Datastore": "Datastore",
"Provider": "Provider",
"Type": "Type"
}
@@ -0,0 +1,25 @@
# Namespace: Model
Generic Model extended by provider specific implementations.
## Index
### Namespaces
- [Base](namespaces/Base/README.md)
- [Chat](namespaces/Chat/README.md)
- [Completion](namespaces/Completion/README.md)
- [Embedding](namespaces/Embedding/README.md)
- [SparseVector](namespaces/SparseVector/README.md)
### Interfaces
- [Events](interfaces/Events.md)
- [ITokenizer](interfaces/ITokenizer.md)
### Type Aliases
- [Ctx](type-aliases/Ctx.md)
- [Message](type-aliases/Message.md)
- [Provider](type-aliases/Provider.md)
- [Type](type-aliases/Type.md)
@@ -0,0 +1,20 @@
# Interface: Events`<MParams, MResponse, AResponse>`
Event handlers for logging and debugging
## Type parameters
| Parameter | Default |
| :------ | :------ |
| `MParams` extends [`Params`](../namespaces/Base/interfaces/Params.md) | - |
| `MResponse` extends [`Response`](../namespaces/Base/interfaces/Response.md) | - |
| `AResponse` extends `any` | `any` |
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `onApiResponse`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/model/types.ts:157](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L157) |
| `onComplete`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/model/types.ts:166](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L166) |
| `onError`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/model/types.ts:175](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L175) |
| `onStart`? | (`event`) => `void` \| `Promise`\<`void`\>[] | - | [src/model/types.ts:150](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L150) |
@@ -0,0 +1,96 @@
# Interface: ITokenizer
Generic interface for a model tokenizer
## Methods
### countTokens()
> **countTokens**(`input`?): `number`
Count the number of tokens in a string or ChatMessage(s).
A single ChatMessage is counted as a completion and an array as a prompt.
Strings are counted as is.
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `input`? | `string` \| `ChatCompletionMessageParam` \| `ChatCompletionMessageParam`[] |
#### Returns
`number`
#### Source
[src/model/types.ts:198](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L198)
***
### decode()
> **decode**(`tokens`): `string`
Decode an array of integer tokens into a string
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `tokens` | `number`[] \| `Uint32Array` |
#### Returns
`string`
#### Source
[src/model/types.ts:192](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L192)
***
### encode()
> **encode**(`text`): `Uint32Array`
Tokenize a string into an array of integer tokens
#### Parameters
| Parameter | Type |
| :------ | :------ |
| `text` | `string` |
#### Returns
`Uint32Array`
#### Source
[src/model/types.ts:190](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L190)
***
### truncate()
> **truncate**(`args`): `string`
Truncate a string to a maximum number of tokens
#### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| `args` | `object` | - |
| `args.from`? | `"start"` \| `"end"` | Truncate from the start or end of the text |
| `args.max` | `number` | Maximum number of tokens to keep (inclusive) |
| `args.text` | `string` | Text to truncate |
#### Returns
`string`
#### Source
[src/model/types.ts:200](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L200)
@@ -0,0 +1,4 @@
{
"Events": "Events",
"ITokenizer": "ITokenizer"
}
@@ -0,0 +1,17 @@
# Namespace: Base
Base model
## Index
### Interfaces
- [Config](interfaces/Config.md)
- [Params](interfaces/Params.md)
- [Response](interfaces/Response.md)
- [Run](interfaces/Run.md)
### Type Aliases
- [Client](type-aliases/Client.md)
- [Model](type-aliases/Model.md)
@@ -0,0 +1,15 @@
# Interface: Config
## Extended By
- [`Params`](Params.md)
- [`Config`](../../Chat/interfaces/Config.md)
- [`Config`](../../Completion/interfaces/Config.md)
- [`Config`](../../Embedding/interfaces/Config.md)
- [`Config`](../../SparseVector/interfaces/Config.md)
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `model` | `string` | - | [src/model/types.ts:31](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L31) |
@@ -0,0 +1,11 @@
# Interface: Params
## Extends
- [`Config`](Config.md).[`Run`](Run.md)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `model` | `string` | - | [`Config`](Config.md).`model` | [src/model/types.ts:31](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L31) |
@@ -0,0 +1,15 @@
# Interface: Response
## Extended By
- [`Response`](../../Chat/interfaces/Response.md)
- [`Response`](../../Completion/interfaces/Response.md)
- [`Response`](../../Embedding/interfaces/Response.md)
- [`Response`](../../SparseVector/interfaces/Response.md)
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `cached` | `boolean` | - | [src/model/types.ts:36](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L36) |
| `cost`? | `number` | - | [src/model/types.ts:37](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L37) |
@@ -0,0 +1,9 @@
# Interface: Run
## Extended By
- [`Params`](Params.md)
- [`Run`](../../Chat/interfaces/Run.md)
- [`Run`](../../Completion/interfaces/Run.md)
- [`Run`](../../Embedding/interfaces/Run.md)
- [`Run`](../../SparseVector/interfaces/Run.md)
@@ -0,0 +1,6 @@
{
"Config": "Config",
"Params": "Params",
"Response": "Response",
"Run": "Run"
}
@@ -0,0 +1,9 @@
# Type alias: Client
> **Client**: `any`
Client for making API calls. Extended by specific model clients.
## Source
[src/model/types.ts:29](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L29)
@@ -0,0 +1,7 @@
# Type alias: Model
> **Model**: [`AbstractModel`](../../../../../classes/AbstractModel.md)\<[`Client`](Client.md), [`Config`](../interfaces/Config.md), [`Run`](../interfaces/Run.md), [`Response`](../interfaces/Response.md), `any`\>
## Source
[src/model/types.ts:39](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L39)
@@ -0,0 +1,4 @@
{
"Client": "Client",
"Model": "Model"
}
@@ -0,0 +1,18 @@
# Namespace: Chat
Chat Model
## Index
### Interfaces
- [Config](interfaces/Config.md)
- [Response](interfaces/Response.md)
- [Run](interfaces/Run.md)
### Type Aliases
- [ApiResponse](type-aliases/ApiResponse.md)
- [Client](type-aliases/Client.md)
- [CompletionChunk](type-aliases/CompletionChunk.md)
- [Model](type-aliases/Model.md)
@@ -0,0 +1,21 @@
# Interface: Config
## Extends
- [`Config`](../../Base/interfaces/Config.md)
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `frequency_penalty`? | `null` \| `number` | - | - | [src/model/types.ts:56](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L56) |
| `function_call`? | `"none"` \| `"auto"` \| `FunctionCallOption` | - | - | [src/model/types.ts:57](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L57) |
| `functions`? | `Function`[] | - | - | [src/model/types.ts:58](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L58) |
| `handleUpdate`? | (`chunk`) => `void` | - | - | [src/model/types.ts:55](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L55) |
| `logit_bias`? | `null` \| `Record`\<`string`, `number`\> | - | - | [src/model/types.ts:59](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L59) |
| `max_tokens`? | `null` \| `number` | - | - | [src/model/types.ts:60](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L60) |
| `model` | `"gpt-4"` \| `"gpt-4-32k"` \| `"gpt-3.5-turbo"` \| `"gpt-3.5-turbo-16k"` \| `string` & `object` \| `"gpt-4-0314"` \| `"gpt-4-0613"` \| `"gpt-4-32k-0314"` \| `"gpt-4-32k-0613"` \| `"gpt-3.5-turbo-0301"` \| `"gpt-3.5-turbo-0613"` \| `"gpt-3.5-turbo-16k-0613"` | - | [`Config`](../../Base/interfaces/Config.md).`model` | [src/model/types.ts:61](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L61) |
| `presence_penalty`? | `null` \| `number` | - | - | [src/model/types.ts:62](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L62) |
| `stop`? | `null` \| `string` \| `string`[] | - | - | [src/model/types.ts:63](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L63) |
| `temperature`? | `null` \| `number` | - | - | [src/model/types.ts:64](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L64) |
| `top_p`? | `null` \| `number` | - | - | [src/model/types.ts:65](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L65) |
@@ -0,0 +1,13 @@
# Interface: Response
## Extends
- [`Response`](../../Base/interfaces/Response.md).`ChatResponse`
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `cached` | `boolean` | - | [`Response`](../../Base/interfaces/Response.md).`cached` | [src/model/types.ts:36](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L36) |
| `cost`? | `number` | - | [`Response`](../../Base/interfaces/Response.md).`cost` | [src/model/types.ts:37](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L37) |
| `message` | `ChatCompletionMessageParam` | - | - | [src/model/types.ts:68](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L68) |
@@ -0,0 +1,11 @@
# Interface: Run
## Extends
- [`Run`](../../Base/interfaces/Run.md)
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `messages` | `ChatCompletionMessageParam`[] | - | [src/model/types.ts:51](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L51) |
@@ -0,0 +1,5 @@
{
"Config": "Config",
"Response": "Response",
"Run": "Run"
}
@@ -0,0 +1,7 @@
# Type alias: ApiResponse
> **ApiResponse**: `ChatResponse`
## Source
[src/model/types.ts:74](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L74)
@@ -0,0 +1,17 @@
# Type alias: Client
> **Client**: `object`
## Type declaration
### createChatCompletion
> **createChatCompletion**: `OpenAIClient`\[`"createChatCompletion"`\]
### streamChatCompletion
> **streamChatCompletion**: `OpenAIClient`\[`"streamChatCompletion"`\]
## Source
[src/model/types.ts:46](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L46)
@@ -0,0 +1,9 @@
# Type alias: CompletionChunk
> **CompletionChunk**: `InnerType`\<`StreamResponse`\>
A chunk recieved from a streaming response
## Source
[src/model/types.ts:73](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L73)
@@ -0,0 +1,7 @@
# Type alias: Model
> **Model**: [`ChatModel`](../../../../../classes/ChatModel.md)
## Source
[src/model/types.ts:75](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L75)
@@ -0,0 +1,6 @@
{
"ApiResponse": "ApiResponse",
"Client": "Client",
"CompletionChunk": "CompletionChunk",
"Model": "Model"
}
@@ -0,0 +1,17 @@
# Namespace: Completion
Completion model
## Index
### Interfaces
- [Config](interfaces/Config.md)
- [Response](interfaces/Response.md)
- [Run](interfaces/Run.md)
### Type Aliases
- [ApiResponse](type-aliases/ApiResponse.md)
- [Client](type-aliases/Client.md)
- [Model](type-aliases/Model.md)
@@ -0,0 +1,11 @@
# Interface: Config
## Extends
- [`Config`](../../Base/interfaces/Config.md).`Omit`\<`CompletionParams`, `"prompt"` \| `"user"`\>
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `model` | `"gpt-3.5-turbo-instruct"` \| `"babbage-002"` \| `"davinci-002"` \| `string` & `object` \| `"text-davinci-003"` \| `"text-davinci-002"` \| `"text-davinci-001"` \| `"code-davinci-002"` \| `"text-curie-001"` \| `"text-babbage-001"` \| `"text-ada-001"` | - | [`Config`](../../Base/interfaces/Config.md).`model` | [src/model/types.ts:96](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L96) |
@@ -0,0 +1,13 @@
# Interface: Response
## Extends
- [`Response`](../../Base/interfaces/Response.md).`CompletionResponse`
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `cached` | `boolean` | - | [`Response`](../../Base/interfaces/Response.md).`cached` | [src/model/types.ts:36](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L36) |
| `completion` | `string` | - | - | [src/model/types.ts:99](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L99) |
| `cost`? | `number` | - | [`Response`](../../Base/interfaces/Response.md).`cost` | [src/model/types.ts:37](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L37) |
@@ -0,0 +1,11 @@
# Interface: Run
## Extends
- [`Run`](../../Base/interfaces/Run.md)
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `prompt` | `null` \| `string` \| `string`[] \| `number`[] \| `number`[][] | - | [src/model/types.ts:86](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L86) |
@@ -0,0 +1,5 @@
{
"Config": "Config",
"Response": "Response",
"Run": "Run"
}
@@ -0,0 +1,7 @@
# Type alias: ApiResponse
> **ApiResponse**: `CompletionResponse`
## Source
[src/model/types.ts:101](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L101)
@@ -0,0 +1,13 @@
# Type alias: Client
> **Client**: `object`
## Type declaration
### createCompletions
> **createCompletions**: `OpenAIClient`\[`"createCompletions"`\]
## Source
[src/model/types.ts:82](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L82)
@@ -0,0 +1,7 @@
# Type alias: Model
> **Model**: [`CompletionModel`](../../../../../classes/CompletionModel.md)
## Source
[src/model/types.ts:102](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L102)
@@ -0,0 +1,5 @@
{
"ApiResponse": "ApiResponse",
"Client": "Client",
"Model": "Model"
}
@@ -0,0 +1,18 @@
# Namespace: Embedding
Embedding Model
## Index
### Interfaces
- [BatchOptions](interfaces/BatchOptions.md)
- [Config](interfaces/Config.md)
- [Response](interfaces/Response.md)
- [Run](interfaces/Run.md)
### Type Aliases
- [ApiResponse](type-aliases/ApiResponse.md)
- [Client](type-aliases/Client.md)
- [Model](type-aliases/Model.md)
@@ -0,0 +1,10 @@
# Interface: BatchOptions
API request batching options
## Properties
| Property | Type | Description | Source |
| :------ | :------ | :------ | :------ |
| `maxBatchSize` | `number` | - | [src/model/types.ts:121](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L121) |
| `maxTokensPerBatch` | `number` | - | [src/model/types.ts:120](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L120) |
@@ -0,0 +1,13 @@
# Interface: Config
## Extends
- [`Config`](../../Base/interfaces/Config.md).`Omit`\<`EmbeddingParams`, `"input"` \| `"user"`\>
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `batch`? | `Partial`\<[`BatchOptions`](BatchOptions.md)\> | - | - | [src/model/types.ts:132](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L132) |
| `model` | `"text-embedding-ada-002"` \| `string` & `object` | - | [`Config`](../../Base/interfaces/Config.md).`model` | [src/model/types.ts:131](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L131) |
| `throttle`? | `Partial`\<`ThrottleOptions`\> | - | - | [src/model/types.ts:133](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L133) |
@@ -0,0 +1,13 @@
# Interface: Response
## Extends
- [`Response`](../../Base/interfaces/Response.md).`EmbeddingResponse`
## Properties
| Property | Type | Description | Inheritance | Source |
| :------ | :------ | :------ | :------ | :------ |
| `cached` | `boolean` | - | [`Response`](../../Base/interfaces/Response.md).`cached` | [src/model/types.ts:36](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L36) |
| `cost`? | `number` | - | [`Response`](../../Base/interfaces/Response.md).`cost` | [src/model/types.ts:37](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L37) |
| `embeddings` | `number`[][] | - | - | [src/model/types.ts:136](https://github.com/dexaai/llm-tools/blob/98f7fd5/src/model/types.ts#L136) |

Some files were not shown because too many files have changed in this diff Show More