From f0c568c18c53aba02b028c033781849649a11f44 Mon Sep 17 00:00:00 2001 From: tedspare Date: Wed, 9 Oct 2024 14:13:55 -0400 Subject: [PATCH] Add TSConfig --- CHANGELOG.md | 1 + package.json | 6 +++--- {evals => src/evals}/index.ts | 4 ++-- {evals => src/evals}/multi-turn/examples.ts | 0 {evals => src/evals}/multi-turn/index.ts | 0 {evals => src/evals}/one-shot/examples.ts | 7 +------ {evals => src/evals}/one-shot/index.ts | 6 +++--- index.ts => src/index.ts | 2 +- {tests => src/tests}/index.test.ts | 2 +- src/types/index.ts | 6 ++++++ {utils => src/utils}/string.ts | 0 tsconfig.json | 10 ++++++++++ 12 files changed, 28 insertions(+), 16 deletions(-) rename {evals => src/evals}/index.ts (84%) rename {evals => src/evals}/multi-turn/examples.ts (100%) rename {evals => src/evals}/multi-turn/index.ts (100%) rename {evals => src/evals}/one-shot/examples.ts (89%) rename {evals => src/evals}/one-shot/index.ts (93%) rename index.ts => src/index.ts (97%) rename {tests => src/tests}/index.test.ts (80%) create mode 100644 src/types/index.ts rename {utils => src/utils}/string.ts (100%) create mode 100644 tsconfig.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 8474e43..310301a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- [2024-10-09] [Add TSConfig](https://github.com/RubricLab/memory/commit/ed521824cc492e46adff6d38a994e18cc08166b2) - [2024-10-09] [Extract memory to class](https://github.com/RubricLab/memory/commit/5e165608ffad822c5b77ee03f1dfc308dcb1787a) - [2024-10-09] [Fix precision calc](https://github.com/RubricLab/memory/commit/52fc41e151c47e276c37a24b3489ba414d032a0b) - [2024-10-09] [Generalize eval arch](https://github.com/RubricLab/memory/commit/bf80487850e840525a1521925a439d7d9fc8d638) diff --git a/package.json b/package.json index c1fc0b0..0760c27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@rubriclab/memory", - "module": "index.ts", - "version": "0.0.8", + "module": "src/index.ts", + "version": "0.0.9", "private": false, "type": "module", "devDependencies": { @@ -30,7 +30,7 @@ "bleed": "bun x npm-check-updates -u", "clean": "rm -rf .next && rm -rf node_modules", "format": "bun x biome format --write .", - "eval": "bun evals/index.ts", + "eval": "bun src/evals/index.ts", "lint": "bun x biome check . && bun x biome lint .", "lint:fix": "bun x biome check --fix --unsafe . && bun x biome lint --write --unsafe ." } diff --git a/evals/index.ts b/src/evals/index.ts similarity index 84% rename from evals/index.ts rename to src/evals/index.ts index 97b1b21..2f705a1 100644 --- a/evals/index.ts +++ b/src/evals/index.ts @@ -1,6 +1,6 @@ import { parseArgs } from 'node:util' -import { runOneShotExamples } from './one-shot' -import { runMultiTurnExamples } from './multi-turn' +import { runMultiTurnExamples } from '@/evals/multi-turn' +import { runOneShotExamples } from '@/evals/one-shot' const args = parseArgs({ args: Bun.argv, diff --git a/evals/multi-turn/examples.ts b/src/evals/multi-turn/examples.ts similarity index 100% rename from evals/multi-turn/examples.ts rename to src/evals/multi-turn/examples.ts diff --git a/evals/multi-turn/index.ts b/src/evals/multi-turn/index.ts similarity index 100% rename from evals/multi-turn/index.ts rename to src/evals/multi-turn/index.ts diff --git a/evals/one-shot/examples.ts b/src/evals/one-shot/examples.ts similarity index 89% rename from evals/one-shot/examples.ts rename to src/evals/one-shot/examples.ts index f8deea8..853aa57 100644 --- a/evals/one-shot/examples.ts +++ b/src/evals/one-shot/examples.ts @@ -1,9 +1,4 @@ -type Fact = { - subject: string - relation: string - object: string - data?: Record -} +import type { Fact } from '@/types' type Example = { content: string diff --git a/evals/one-shot/index.ts b/src/evals/one-shot/index.ts similarity index 93% rename from evals/one-shot/index.ts rename to src/evals/one-shot/index.ts index b596b3e..28d7249 100644 --- a/evals/one-shot/index.ts +++ b/src/evals/one-shot/index.ts @@ -1,8 +1,8 @@ +import { Memory } from '@/' +import { format } from '@/utils/string' import type { openai } from '@ai-sdk/openai' import chalk from 'chalk' -import { Memory } from '../../index.ts' -import { format } from '../../utils/string.ts' -import { EXAMPLES } from './examples.ts' +import { EXAMPLES } from './examples' export const runOneShotExamples = async ({ model }: { model: Parameters[0] }) => { let totalFacts = 0 diff --git a/index.ts b/src/index.ts similarity index 97% rename from index.ts rename to src/index.ts index 9c7b2ea..5b353ff 100644 --- a/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ +import { clean } from '@/utils/string' import { openai } from '@ai-sdk/openai' import { generateObject } from 'ai' import { z } from 'zod' -import { clean } from './utils/string' export class Memory { model: Parameters[0] diff --git a/tests/index.test.ts b/src/tests/index.test.ts similarity index 80% rename from tests/index.test.ts rename to src/tests/index.test.ts index b090710..9d6b595 100644 --- a/tests/index.test.ts +++ b/src/tests/index.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'bun:test' -import { memory } from '../' +import { memory } from '@' test('exports a function', () => { expect(typeof memory).toBe('function') diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 0000000..cae7666 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,6 @@ +export type Fact = { + subject: string + relation: string + object: string + data?: Record +} diff --git a/utils/string.ts b/src/utils/string.ts similarity index 100% rename from utils/string.ts rename to src/utils/string.ts diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..1330331 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } + }, + "exclude": ["node_modules"], + "extends": "@rubriclab/config/tsconfig" +}