Skip to content

Commit

Permalink
evaluate require statement on runtime (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
abubakarsohail authored Apr 25, 2024
1 parent 0221bdf commit 5918f3e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "promptlayer",
"license": "MIT",
"version": "0.0.15",
"version": "0.0.16",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const promptlayer = new Proxy<{
get: (target, prop, receiver) => {
if (["OpenAI", "Anthropic"].includes(prop.toString())) {
const moduleName = prop === "OpenAI" ? "openai" : "@anthropic-ai/sdk";
const module = require(moduleName).default;
const requireDynamically = eval(`require('${moduleName}')`);
const module = requireDynamically.default;
return promptLayerBase(
module,
prop.toString().toLowerCase(),
Expand Down

0 comments on commit 5918f3e

Please sign in to comment.