Closed csgulati09 closed 7 months ago
🤖
Based on your requirements, you'll need to modify the Portkey Node SDK to function as a wrapper around the OpenAI SDK. This involves replacing the calls to the Portkey Gateway with calls to the OpenAI SDK. Here's a general approach you can follow:
Install the OpenAI SDK: You can do this by running the command npm install openai
in your terminal.
Modify the Portkey Node SDK: You'll need to replace the calls to the Portkey Gateway with calls to the OpenAI SDK. Here's a simplified example of how you might do this:
import { config } from 'dotenv';
import { OpenAI } from 'openai';
config({ override: true })
const client = new OpenAI(process.env["OPENAI_API_KEY"] ?? "");
describe('Completions APIs', () => {
test('model: gpt-3.5-turbo-instruct', async () => {
const completion = await client.createCompletion({ model: 'gpt-3.5-turbo-instruct', prompt: 'This is a test.' });
expect(completion).toBeDefined();
expect(completion.choices).toBeDefined();
expect(completion.choices.length).toBeGreaterThan(0);
});
// ... rest of the tests
});
In this example, we're importing the OpenAI SDK and creating a new instance of it using the OpenAI API key. Then, we're using the createCompletion
method of the OpenAI SDK to create completions, instead of the completions.create
method of the Portkey SDK.
Please note that this is a simplified example and the actual implementation might require additional changes based on the specific requirements of your application. You can refer to the OpenAI SDK documentation for more details on how to use the OpenAI SDK.
Regarding the current structure of the Portkey Node SDK codebase, it's structured around a main class named Portkey
which extends from the ApiClient
class. This class has several properties and methods corresponding to different APIs. You can refer to the Portkey Node SDK source code for more details.
I hope this helps! If you have any more questions or need further clarification, feel free to ask.
Building our SDK in a way that it is a wrapper around OpenAI SDK.
Instead of calling our Gateway, making a call to OpenAI SDK with all the needed changes