Portkey-AI / portkey-node-sdk

Build reliable, secure, and production-ready AI apps easily.
https://portkey.ai/docs
22 stars 8 forks source link

Remove custom path imports #21

Closed VisargD closed 9 months ago

VisargD commented 9 months ago

This SDK currently has paths defined in tsconfig.json with this mapping

"paths": {
            "portkey-ai/*": [
                "src/*"
            ],
            "portkey-ai": [
                "src/index.ts"
            ],
        },

But this is only used to resolve imports during runtime. This is not taken into consideration by tsc while emitting code. Due to this behaviour, some build errors pop up due to these import. The affected files are:

https://github.com/Portkey-AI/portkey-node-sdk/blob/a1adf914a5f7e2622153618a2a77120b84090b2a/src/apis/postMethod.ts#L1

https://github.com/Portkey-AI/portkey-node-sdk/blob/a1adf914a5f7e2622153618a2a77120b84090b2a/src/apis/embeddings.ts#L1

https://github.com/Portkey-AI/portkey-node-sdk/blob/a1adf914a5f7e2622153618a2a77120b84090b2a/src/apis/generations.ts#L1

Related Gihub issue which points out this typescript behaviour: https://github.com/microsoft/TypeScript/issues/10866

dosubot[bot] commented 9 months ago

🤖

Hello @VisargD!

I'm Dosu, a friendly bot designed to assist with issues just like this one while we're waiting for a human maintainer to jump in. I'm here to help you work through bugs, answer any questions you might have, and even guide you in becoming a contributor.

Looking forward to assisting you!

Yes, the custom path imports defined in the tsconfig.json file of the Portkey Node SDK can be removed to resolve the build errors that are occurring due to TypeScript's behavior of not considering these paths while emitting code.

You can remove the "paths" section from the "compilerOptions" in the tsconfig.json file. Here's how your tsconfig.json file should look after removing the "paths":

{
    "include": [
        "src",
        "tests",
        "examples",
    ],
    "compilerOptions": {
        "sourceMap": true,
        "declaration": true,
        "target": "ES2015",
        "lib": [
            "ES2015",
            "dom"
        ],
        "module": "CommonJS",
        "esModuleInterop": true,
        "baseUrl": ".",
        "resolveJsonModule": true,
        "strict": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "strictBindCallApply": true,
        "strictPropertyInitialization": true,
        "noImplicitThis": true,
        "alwaysStrict": true,
        "exactOptionalPropertyTypes": true,
        "noUncheckedIndexedAccess": true,
        "noImplicitOverride": true,
        "noPropertyAccessFromIndexSignature": true,
        "skipLibCheck": true,
        "outDir": "./dist",
    },
    "exclude": [
        "./node_modules" // Files/folders to exclude from compilation
    ],
    "jest": {
        "preset": "ts-jest"
    }
}

Please note that after removing these paths, you will need to update any import statements in your code that were using these paths to use relative paths instead.

As for the specific build errors that are being generated due to the current custom path imports in the Portkey Node SDK, I'm afraid I don't have that information. Could you please provide more details about the errors you're encountering? This will help me provide a more accurate solution.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.