You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a total typescript and javascript noob and can't figure out how to run the examples. I've been able to compile the library code in src using npm run build (though I had to comment out "incremental": true, since that was causing errors). But that doesn't compile the examples. I also tried adding the examples directory to the tsup.config.ts entry point like so:
And that got the examples to show up in dist/. However trying to run something like node dist/examples/extract_user/index.js just results in this nice mess:
instructor-js/dist/examples/extract_user/index.js:1
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunk5TOWEZOFjs = require('../../chunk-5TOWEZOF.js');require('../../chunk-FENE22EL.js');require('../../chunk-QNGW3BHK.js');require('../../chunk-BT2OLEUH.js');var _openai = require('openai'); var _openai2 = _interopRequireDefault(_openai);var _zod = require('zod');var r=_zod.z.object({age:_zod.z.number(),name:_zod.z.string().refine(s=>s.includes(" "),{message:"Name must contain a space"})}),t=new (0, _openai2.default)({apiKey:_nullishCoalesce(process.env.OPENAI_API_KEY, () => (void 0)),organization:_nullishCoalesce(process.env.OPENAI_ORG_ID, () => (void 0))}),a=_chunk5TOWEZOFjs.a.call(void 0, {client:t,mode:"FUNCTIONS"}),i=await a.chat.completions.create({messages:[{role:"user",content:"Jason Liu is 30 years old"}],model:"gpt-3.5-turbo",response_model:r,max_retries:3});console.log(i);
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1153:20)
at Module._compile (node:internal/modules/cjs/loader:1205:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.7.0
Appreciate any help on this and general advice on what a workflow for local development on the library might look like
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm a total typescript and javascript noob and can't figure out how to run the examples. I've been able to compile the library code in
src
usingnpm run build
(though I had to comment out"incremental": true,
since that was causing errors). But that doesn't compile the examples. I also tried adding the examples directory to thetsup.config.ts
entry point like so:And that got the examples to show up in
dist/
. However trying to run something likenode dist/examples/extract_user/index.js
just results in this nice mess:Appreciate any help on this and general advice on what a workflow for local development on the library might look like
Beta Was this translation helpful? Give feedback.
All reactions