Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Split into multiple libraries. #10

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
with: { node-version: 20.x }
- run: npm install -g pnpm@9
- run: pnpm install --frozen-lockfile
- run: pnpm run -r test
- run: pnpm run -r build
- run: pnpm run test
- run: pnpm run build
# - run: pnpm run -r release
# env:
# GITHUB_TOKEN: ${{ github.token }}
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/dist
/.env
node_modules
dist
.env
.turbo
33 changes: 9 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
{
"name": "@formula-monks/kurt",
"description": "A wrapper for AI SDKs, for building LLM-agnostic structured AI applications",
"license": "MIT",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"scripts": {
"test": "jest",
"build": "tsc",
"prepack": "pnpm run build",
"prepare": "husky"
},
"dependencies": {
"@google-cloud/vertexai": "1.1.0",
"openai": "^4.40.0",
"zod": "^3.23.5",
"zod-to-json-schema": "^3.23.0"
},
"devDependencies": {
"@biomejs/biome": "^1.7.3",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@jest/globals": "^29.7.0",
"czg": "^1.9.1",
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
"ts-jest": "^29.1.2",
"type-fest": "^4.18.1",
"typescript": "^5.4.5"
"turbo": "^1.13.3"
},
"scripts": {
"prepare": "husky",
"build": "pnpm turbo build",
"test": "pnpm turbo test",
"check": "pnpm turbo check",
"lint": "pnpm turbo lint",
"format": "pnpm turbo format"
}
}
File renamed without changes.
31 changes: 31 additions & 0 deletions packages/kurt-open-ai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@formula-monks/kurt-open-ai",
"description": "OpenAI plugin for Kurt - A wrapper for AI SDKs, for building LLM-agnostic structured AI applications",
"license": "MIT",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"scripts": {
"test": "jest",
"build": "tsc --build",
"prepack": "pnpm run build",
"format": "pnpm biome format --write .",
"lint": "pnpm biome lint --apply .",
"check": "pnpm biome check ."
},
"dependencies": {
"@formula-monks/kurt": "workspace:^",
"openai": "^4.40.0",
"zod": "^3.23.5",
"zod-to-json-schema": "^3.23.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/node": "^18.19.32",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"type-fest": "^4.18.1",
"typescript": "^5.4.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
OpenAIResponse,
OpenAIResponseChunk,
} from "../src/OpenAI.types"
import { arrayFromAsync } from "./util"

const USE_REAL_API = false // set to true to validate against actual OpenAI

Expand Down Expand Up @@ -41,6 +40,12 @@ function setupExpectingCall(
})
}

async function arrayFromAsync<T>(iter: AsyncIterable<T>): Promise<T[]> {
const array: T[] = []
for await (const item of iter) array.push(item)
return array
}

describe("KurtOpenAI", () => {
test("generateNaturalLanguage", async () => {
const req = {
Expand Down
8 changes: 3 additions & 5 deletions src/KurtOpenAI.ts → packages/kurt-open-ai/src/KurtOpenAI.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { zodToJsonSchema } from "zod-to-json-schema"
import { KurtStream } from "@formula-monks/kurt"
import type {
Kurt,
KurtCreateOptions,
KurtGenerateNaturalLanguageOptions,
KurtGenerateStructuredDataOptions,
KurtMessage,
} from "./Kurt"
import { KurtStream, type KurtStreamEvent } from "./KurtStream"
import type {
KurtSchema,
KurtStreamEvent,
KurtSchemaInner,
KurtSchemaInnerMaybe,
KurtSchemaMaybe,
KurtSchemaResult,
KurtSchemaResultMaybe,
} from "./KurtSchema"
} from "@formula-monks/kurt"
import type { OpenAI, OpenAIMessage, OpenAIResponse } from "./OpenAI.types"

// These models support function calling.
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/kurt-open-ai/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { KurtOpenAI } from "./KurtOpenAI"
15 changes: 15 additions & 0 deletions packages/kurt-open-ai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"outDir": "dist",
"strict": true,
"noUncheckedIndexedAccess": true,
"downlevelIteration": true,
"lib": ["esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2015",
"esModuleInterop": true
},
"include": ["src/*.ts"],
"exclude": ["node_modules", "dist"]
}
5 changes: 5 additions & 0 deletions packages/kurt-vertex-ai/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
}
31 changes: 31 additions & 0 deletions packages/kurt-vertex-ai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@formula-monks/kurt-vertex-ai",
"description": "VertexAI plugin for Kurt - A wrapper for AI SDKs, for building LLM-agnostic structured AI applications",
"license": "MIT",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"scripts": {
"test": "jest",
"build": "tsc",
"prepack": "pnpm run build",
"format": "pnpm biome format --write .",
"lint": "pnpm biome lint --apply .",
"check": "pnpm biome check ."
},
"dependencies": {
"@formula-monks/kurt": "workspace:^",
"@google-cloud/vertexai": "1.1.0",
"zod": "^3.23.5",
"zod-to-json-schema": "^3.23.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/node": "^18.19.32",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"type-fest": "^4.18.1",
"typescript": "^5.4.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {
VertexAIResponseChunkCandidate,
VertexAISchema,
} from "../src/VertexAI.types"
import { arrayFromAsync } from "./util"

const USE_REAL_API = false // set to true to validate against actual VertexAI

Expand Down Expand Up @@ -55,6 +54,12 @@ function setupExpectingCall(
})
}

async function arrayFromAsync<T>(iter: AsyncIterable<T>): Promise<T[]> {
const array: T[] = []
for await (const item of iter) array.push(item)
return array
}

describe("KurtVertexAI", () => {
test("generateNaturalLanguage", async () => {
const req = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import "./VertexAI.patch.generateContentStream" // monkey-patches VertexAI GenerativeModel.prototype.generateContentStream

import zodToJsonSchema from "zod-to-json-schema"
import { KurtStream } from "@formula-monks/kurt"
import type {
Kurt,
KurtCreateOptions,
KurtGenerateNaturalLanguageOptions,
KurtGenerateStructuredDataOptions,
KurtMessage,
} from "./Kurt"
import { KurtResult, KurtStream, type KurtStreamEvent } from "./KurtStream"
import type {
KurtStreamEvent,
KurtSchema,
KurtSchemaInner,
KurtSchemaInnerMaybe,
KurtSchemaMaybe,
KurtSchemaResult,
KurtSchemaResultMaybe,
} from "./KurtSchema"
} from "@formula-monks/kurt"
import type {
VertexAI,
VertexAIGenerativeModel,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/kurt-vertex-ai/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { KurtVertexAI } from "./KurtVertexAI"
5 changes: 3 additions & 2 deletions tsconfig.json → packages/kurt-vertex-ai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"include": ["src/*.ts"],
"compilerOptions": {
"outDir": "dist",
"declaration": true,
Expand All @@ -11,5 +10,7 @@
"moduleResolution": "NodeNext",
"target": "ES2015",
"esModuleInterop": true
}
},
"include": ["src/*.ts"],
"exclude": ["node_modules", "dist"]
}
5 changes: 5 additions & 0 deletions packages/kurt/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
}
27 changes: 27 additions & 0 deletions packages/kurt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@formula-monks/kurt",
"description": "A wrapper for AI SDKs, for building LLM-agnostic structured AI applications",
"license": "MIT",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"scripts": {
"test": "jest",
"build": "tsc --build",
"prepack": "pnpm run build",
"format": "pnpm biome format --write .",
"lint": "pnpm biome lint --apply .",
"check": "pnpm biome check ."
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/node": "^18.19.32",
"czg": "^1.9.1",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"type-fest": "^4.18.1",
"typescript": "^5.4.5",
"zod": "^3.23.5"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/kurt/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./Kurt"
export * from "./KurtStream"
export * from "./KurtSchema"
16 changes: 16 additions & 0 deletions packages/kurt/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"outDir": "dist",
"declaration": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"downlevelIteration": true,
"lib": ["esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2015",
"esModuleInterop": true
},
"include": ["src/*.ts"],
"exclude": ["node_modules", "dist"]
}
Loading
Loading