kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
old-agentic-v1^2
rodzic
7850c96f52
commit
02bf952659
|
@ -35,16 +35,14 @@
|
||||||
"test:prettier": "prettier '**/*.{js,jsx,ts,tsx}' --check"
|
"test:prettier": "prettier '**/*.{js,jsx,ts,tsx}' --check"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.1.3",
|
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"js-tiktoken": "^1.0.6",
|
"js-tiktoken": "^1.0.6",
|
||||||
"jsonrepair": "^3.1.0",
|
"jsonrepair": "^3.1.0",
|
||||||
"ky": "^0.33.3",
|
"ky": "^0.33.3",
|
||||||
"openai-fetch": "^1.3.0",
|
"openai-fetch": "^1.5.0",
|
||||||
"p-map": "^6.0.0",
|
"p-map": "^6.0.0",
|
||||||
"quick-lru": "^6.1.1",
|
"quick-lru": "^6.1.1",
|
||||||
"ts-dedent": "^2.2.0",
|
"ts-dedent": "^2.2.0",
|
||||||
"type-fest": "^3.11.0",
|
|
||||||
"zod": "^3.21.4",
|
"zod": "^3.21.4",
|
||||||
"zod-to-ts": "^1.1.4",
|
"zod-to-ts": "^1.1.4",
|
||||||
"zod-validation-error": "^1.3.0"
|
"zod-validation-error": "^1.3.0"
|
||||||
|
@ -54,12 +52,15 @@
|
||||||
"@types/node": "^20.2.5",
|
"@types/node": "^20.2.5",
|
||||||
"ava": "^5.3.0",
|
"ava": "^5.3.0",
|
||||||
"del-cli": "^5.0.0",
|
"del-cli": "^5.0.0",
|
||||||
|
"dotenv": "^16.1.3",
|
||||||
|
"expect-type": "^0.16.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^13.2.2",
|
"lint-staged": "^13.2.2",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"tsup": "^6.7.0",
|
"tsup": "^6.7.0",
|
||||||
"tsx": "^3.12.7",
|
"tsx": "^3.12.7",
|
||||||
|
"type-fest": "^3.11.1",
|
||||||
"typescript": "^5.0.4"
|
"typescript": "^5.0.4"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
lockfileVersion: '6.0'
|
lockfileVersion: '6.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
dotenv:
|
|
||||||
specifier: ^16.1.3
|
|
||||||
version: 16.1.3
|
|
||||||
handlebars:
|
handlebars:
|
||||||
specifier: ^4.7.7
|
specifier: ^4.7.7
|
||||||
version: 4.7.7
|
version: 4.7.7
|
||||||
|
@ -17,8 +14,8 @@ dependencies:
|
||||||
specifier: ^0.33.3
|
specifier: ^0.33.3
|
||||||
version: 0.33.3
|
version: 0.33.3
|
||||||
openai-fetch:
|
openai-fetch:
|
||||||
specifier: ^1.3.0
|
specifier: ^1.5.0
|
||||||
version: 1.3.0
|
version: 1.5.0
|
||||||
p-map:
|
p-map:
|
||||||
specifier: ^6.0.0
|
specifier: ^6.0.0
|
||||||
version: 6.0.0
|
version: 6.0.0
|
||||||
|
@ -28,9 +25,6 @@ dependencies:
|
||||||
ts-dedent:
|
ts-dedent:
|
||||||
specifier: ^2.2.0
|
specifier: ^2.2.0
|
||||||
version: 2.2.0
|
version: 2.2.0
|
||||||
type-fest:
|
|
||||||
specifier: ^3.11.0
|
|
||||||
version: 3.11.0
|
|
||||||
zod:
|
zod:
|
||||||
specifier: ^3.21.4
|
specifier: ^3.21.4
|
||||||
version: 3.21.4
|
version: 3.21.4
|
||||||
|
@ -54,6 +48,12 @@ devDependencies:
|
||||||
del-cli:
|
del-cli:
|
||||||
specifier: ^5.0.0
|
specifier: ^5.0.0
|
||||||
version: 5.0.0
|
version: 5.0.0
|
||||||
|
dotenv:
|
||||||
|
specifier: ^16.1.3
|
||||||
|
version: 16.1.3
|
||||||
|
expect-type:
|
||||||
|
specifier: ^0.16.0
|
||||||
|
version: 0.16.0
|
||||||
husky:
|
husky:
|
||||||
specifier: ^8.0.3
|
specifier: ^8.0.3
|
||||||
version: 8.0.3
|
version: 8.0.3
|
||||||
|
@ -72,6 +72,9 @@ devDependencies:
|
||||||
tsx:
|
tsx:
|
||||||
specifier: ^3.12.7
|
specifier: ^3.12.7
|
||||||
version: 3.12.7
|
version: 3.12.7
|
||||||
|
type-fest:
|
||||||
|
specifier: ^3.11.1
|
||||||
|
version: 3.11.1
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.0.4
|
specifier: ^5.0.4
|
||||||
version: 5.0.4
|
version: 5.0.4
|
||||||
|
@ -1027,7 +1030,7 @@ packages:
|
||||||
/dotenv@16.1.3:
|
/dotenv@16.1.3:
|
||||||
resolution: {integrity: sha512-FYssxsmCTtKL72fGBSvb1K9dRz0/VZeWqFme/vSb7r7323x4CRaHu4LvQ5JG3+s6yt2YPbBrkpiEODktfyjI9A==}
|
resolution: {integrity: sha512-FYssxsmCTtKL72fGBSvb1K9dRz0/VZeWqFme/vSb7r7323x4CRaHu4LvQ5JG3+s6yt2YPbBrkpiEODktfyjI9A==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: false
|
dev: true
|
||||||
|
|
||||||
/eastasianwidth@0.2.0:
|
/eastasianwidth@0.2.0:
|
||||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||||
|
@ -1201,6 +1204,11 @@ packages:
|
||||||
strip-final-newline: 3.0.0
|
strip-final-newline: 3.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/expect-type@0.16.0:
|
||||||
|
resolution: {integrity: sha512-wCpFeVBiAPGiYkQZzaqvGuuBnNCHbtnowMOBpBGY8a27XbG8VAit3lklWph1r8VmgsH61mOZqI3NuGm8bZnUlw==}
|
||||||
|
engines: {node: '>=12.0.0'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/fast-diff@1.3.0:
|
/fast-diff@1.3.0:
|
||||||
resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}
|
resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -2121,8 +2129,8 @@ packages:
|
||||||
mimic-fn: 4.0.0
|
mimic-fn: 4.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/openai-fetch@1.3.0:
|
/openai-fetch@1.5.0:
|
||||||
resolution: {integrity: sha512-p3U4bZzAqfG0kkN9Z2fze0jqL2cZkbUSPI7oyzaVoms4T/Rovlar+ZaUf8evStgFH6p7WoBmeqnH6tt/Y50/+Q==}
|
resolution: {integrity: sha512-GSCt5JPNWTADNeip9DUXlkZMwwxczKBRokKLInTQbbX0t81VqTBBUYis36XZeWHQP4eWeWMLe9nGiTtciqZ1HA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
ky: 0.33.3
|
ky: 0.33.3
|
||||||
zod: 3.21.4
|
zod: 3.21.4
|
||||||
|
@ -2897,10 +2905,10 @@ packages:
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/type-fest@3.11.0:
|
/type-fest@3.11.1:
|
||||||
resolution: {integrity: sha512-JaPw5U9ixP0XcpUbQoVSbxSDcK/K4nww20C3kjm9yE6cDRRhptU28AH60VWf9ltXmCrIfIbtt9J+2OUk2Uqiaw==}
|
resolution: {integrity: sha512-aCuRNRERRVh33lgQaJRlUxZqzfhzwTrsE98Mc3o3VXqmiaQdHacgUtJ0esp+7MvZ92qhtzKPeusaX6vIEcoreA==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
dev: false
|
dev: true
|
||||||
|
|
||||||
/typed-array-length@1.0.4:
|
/typed-array-length@1.0.4:
|
||||||
resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==}
|
resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
|
import { expectTypeOf } from 'expect-type'
|
||||||
import { OpenAIClient } from 'openai-fetch'
|
import { OpenAIClient } from 'openai-fetch'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
@ -17,22 +18,10 @@ test('OpenAIChatModel ⇒ json output', async (t) => {
|
||||||
}).output(z.object({ foo: z.string(), bar: z.number() }))
|
}).output(z.object({ foo: z.string(), bar: z.number() }))
|
||||||
|
|
||||||
const result = await builder.call()
|
const result = await builder.call()
|
||||||
type verify = Expect<
|
t.truthy(result)
|
||||||
Equal<
|
t.truthy(typeof result.foo === 'string')
|
||||||
typeof result,
|
t.truthy(typeof result.bar === 'number')
|
||||||
{
|
t.is(Object.keys(result).length, 2)
|
||||||
foo: string
|
|
||||||
bar: number
|
|
||||||
}
|
|
||||||
>
|
|
||||||
>
|
|
||||||
})
|
|
||||||
|
|
||||||
// Ensure parsed results are typed correctly
|
expectTypeOf(result).toMatchTypeOf<{ foo: string; bar: number }>()
|
||||||
// https://github.com/total-typescript/zod-tutorial/blob/main/src/helpers/type-utils.ts
|
})
|
||||||
type Expect<T extends true> = T
|
|
||||||
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y
|
|
||||||
? 1
|
|
||||||
: 2
|
|
||||||
? true
|
|
||||||
: false
|
|
||||||
|
|
Ładowanie…
Reference in New Issue