rhachet-brains-openai 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,7 +48,7 @@ const CONFIG_BY_SLUG = {
|
|
|
48
48
|
*/
|
|
49
49
|
const genBrainAtom = (input) => {
|
|
50
50
|
const config = CONFIG_BY_SLUG[input.slug];
|
|
51
|
-
return {
|
|
51
|
+
return new rhachet_1.BrainAtom({
|
|
52
52
|
repo: 'openai',
|
|
53
53
|
slug: input.slug,
|
|
54
54
|
description: config.description,
|
|
@@ -72,26 +72,37 @@ const genBrainAtom = (input) => {
|
|
|
72
72
|
messages.push({ role: 'user', content: askInput.prompt });
|
|
73
73
|
// convert zod schema to json schema for structured output
|
|
74
74
|
const jsonSchema = zod_1.z.toJSONSchema(askInput.schema.output);
|
|
75
|
-
//
|
|
75
|
+
// check if schema is an object type (openai only supports object schemas for response_format)
|
|
76
|
+
const isObjectSchema = typeof jsonSchema === 'object' &&
|
|
77
|
+
jsonSchema !== null &&
|
|
78
|
+
'type' in jsonSchema &&
|
|
79
|
+
jsonSchema.type === 'object';
|
|
80
|
+
// call openai api, with response_format only for object schemas
|
|
76
81
|
const response = await openai.chat.completions.create({
|
|
77
82
|
model: config.model,
|
|
78
83
|
messages,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
...(isObjectSchema && {
|
|
85
|
+
response_format: {
|
|
86
|
+
type: 'json_schema',
|
|
87
|
+
json_schema: {
|
|
88
|
+
name: 'response',
|
|
89
|
+
strict: true,
|
|
90
|
+
schema: jsonSchema,
|
|
91
|
+
},
|
|
85
92
|
},
|
|
86
|
-
},
|
|
93
|
+
}),
|
|
87
94
|
});
|
|
88
95
|
// extract content from response
|
|
89
96
|
const content = response.choices[0]?.message?.content ?? '';
|
|
90
|
-
// parse
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
// parse response based on schema type
|
|
98
|
+
if (isObjectSchema) {
|
|
99
|
+
const parsed = JSON.parse(content);
|
|
100
|
+
return askInput.schema.output.parse(parsed);
|
|
101
|
+
}
|
|
102
|
+
// for non-object schemas, validate the raw content directly
|
|
103
|
+
return askInput.schema.output.parse(content);
|
|
93
104
|
},
|
|
94
|
-
};
|
|
105
|
+
});
|
|
95
106
|
};
|
|
96
107
|
exports.genBrainAtom = genBrainAtom;
|
|
97
108
|
//# sourceMappingURL=genBrainAtom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atoms/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atoms/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,qCAAwD;AAIxD,6BAAwB;AAcxB;;;GAGG;AACH,MAAM,cAAc,GAGhB;IACF,eAAe,EAAE;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,oDAAoD;KAClE;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,wDAAwD;KACtE;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,mDAAmD;KACjE;IACD,WAAW,EAAE;QACX,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,oDAAoD;KAClE;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,oDAAoD;KAClE;IACD,mBAAmB,EAAE;QACnB,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,yDAAyD;KACvE;CACF,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,YAAY,GAAG,CAAC,KAA+B,EAAa,EAAE;IACzE,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC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BACpD,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,QAAQ;gBACR,GAAG,CAAC,cAAc,IAAI;oBACpB,eAAe,EAAE;wBACf,IAAI,EAAE,aAAa;wBACnB,WAAW,EAAE;4BACX,IAAI,EAAE,UAAU;4BAChB,MAAM,EAAE,IAAI;4BACZ,MAAM,EAAE,UAAU;yBACnB;qBACF;iBACF,CAAC;aACH,CAAC,CAAC;YAEH,gCAAgC;YAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;YAE5D,sCAAsC;YACtC,IAAI,cAAc,EAAE,CAAC;gBACnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACnC,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;YAED,4DAA4D;YAC5D,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA5EW,QAAA,YAAY,gBA4EvB"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rhachet-brains-openai",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
|
-
"description": "rhachet
|
|
5
|
-
"version": "0.
|
|
4
|
+
"description": "rhachet brain.atom and brain.repl adapter for openai",
|
|
5
|
+
"version": "0.1.1",
|
|
6
6
|
"repository": "ehmpathy/rhachet-brains-openai",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/rhachet-brains-openai",
|
|
8
8
|
"keywords": [
|
|
@@ -20,18 +20,47 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"/dist"
|
|
22
22
|
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:ts": "tsc -p ./tsconfig.build.json",
|
|
25
|
+
"commit:with-cli": "npx cz",
|
|
26
|
+
"fix:format:biome": "biome check --write",
|
|
27
|
+
"fix:format": "npm run fix:format:biome",
|
|
28
|
+
"fix:lint": "biome check --write",
|
|
29
|
+
"fix": "npm run fix:format && npm run fix:lint",
|
|
30
|
+
"build:clean:bun": "rm -f ./bin/*.bc",
|
|
31
|
+
"build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
|
|
32
|
+
"build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
|
|
33
|
+
"build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
34
|
+
"build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
|
|
35
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
36
|
+
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
37
|
+
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
38
|
+
"test:format:biome": "biome format",
|
|
39
|
+
"test:format": "npm run test:format:biome",
|
|
40
|
+
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
41
|
+
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
42
|
+
"test:lint:biome:all": "biome check",
|
|
43
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
44
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
45
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
46
|
+
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
47
|
+
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
48
|
+
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
49
|
+
"prepush": "npm run test && npm run build",
|
|
50
|
+
"prepublish": "npm run build",
|
|
51
|
+
"preversion": "npm run prepush",
|
|
52
|
+
"postversion": "git push origin HEAD --tags --no-verify",
|
|
53
|
+
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
54
|
+
"prepare:rhachet": "rhachet init --mode upsert && rhachet roles link --repo ehmpathy --role mechanic && rhachet roles link --repo bhuild --role behaver && rhachet roles link --repo bhrain --role reviewer && rhachet roles init --role mechanic && rhachet roles init --role behaver",
|
|
55
|
+
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
|
|
56
|
+
},
|
|
23
57
|
"dependencies": {
|
|
24
|
-
"@ehmpathy/uni-time": "1.8.1",
|
|
25
58
|
"@openai/codex-sdk": "0.77.0",
|
|
26
|
-
"as-procedure": "1.1.7",
|
|
27
59
|
"domain-objects": "0.31.9",
|
|
28
|
-
"find-up": "5.0.0",
|
|
29
|
-
"hash-fns": "1.1.0",
|
|
30
60
|
"helpful-errors": "1.5.3",
|
|
31
61
|
"openai": "5.8.2",
|
|
32
62
|
"rhachet-artifact": "1.0.1",
|
|
33
63
|
"rhachet-artifact-git": "1.1.5",
|
|
34
|
-
"serde-fns": "1.3.0",
|
|
35
64
|
"type-fns": "1.21.0",
|
|
36
65
|
"wrapper-fns": "1.1.7",
|
|
37
66
|
"zod": "4.3.4"
|
|
@@ -70,37 +99,5 @@
|
|
|
70
99
|
"path": "./node_modules/cz-conventional-changelog"
|
|
71
100
|
}
|
|
72
101
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"commit:with-cli": "npx cz",
|
|
76
|
-
"fix:format:biome": "biome check --write",
|
|
77
|
-
"fix:format": "npm run fix:format:biome",
|
|
78
|
-
"fix:lint": "biome check --write",
|
|
79
|
-
"fix": "npm run fix:format && npm run fix:lint",
|
|
80
|
-
"build:clean:bun": "rm -f ./bin/*.bc",
|
|
81
|
-
"build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
|
|
82
|
-
"build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
|
|
83
|
-
"build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
84
|
-
"build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
|
|
85
|
-
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
86
|
-
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
87
|
-
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
88
|
-
"test:format:biome": "biome format",
|
|
89
|
-
"test:format": "npm run test:format:biome",
|
|
90
|
-
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
91
|
-
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
92
|
-
"test:lint:biome:all": "biome check",
|
|
93
|
-
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
94
|
-
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
95
|
-
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
96
|
-
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
97
|
-
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
98
|
-
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
99
|
-
"prepush": "npm run test && npm run build",
|
|
100
|
-
"prepublish": "npm run build",
|
|
101
|
-
"preversion": "npm run prepush",
|
|
102
|
-
"postversion": "git push origin HEAD --tags --no-verify",
|
|
103
|
-
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
104
|
-
"prepare:rhachet": "rhachet init --mode upsert && rhachet roles link --repo ehmpathy --role mechanic && rhachet roles link --repo bhuild --role behaver && rhachet roles link --repo bhrain --role reviewer && rhachet roles init --role mechanic && rhachet roles init --role behaver"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
102
|
+
"packageManager": "pnpm@10.24.0"
|
|
103
|
+
}
|