Quickstart
Node.js
The prompt engineering, prompt management, and prompt evaluation tool for TypeScript, JavaScript, and NodeJS.
Installation
Install the Prompt Foundry SDK
npm install @prompt-foundry/typescript-sdk
Usage
The full API of this library can be found in the API Reference page by selecting JavaScript in the interactive examples.
OpenAI Integration
Install the OpenAI SDK
npm install openai
Import the OpenAI and Prompt Foundry SDKs
import PromptFoundry from "@prompt-foundry/typescript-sdk";
import { Configuration, OpenAIApi } from "openai";
// Initialize Prompt Foundry SDK with your API key
const promptFoundry = new PromptFoundry({
apiKey: process.env["PROMPT_FOUNDRY_API_KEY"],
});
// Initialize OpenAI SDK with your API key
const configuration = new Configuration({
apiKey: process.env["OPENAI_API_KEY"],
});
const openai = new OpenAIApi(configuration);
async function main() {
// Retrieve model parameters for the prompt
const modelParameters = await promptFoundry.prompts.getParameters("1212121", {
variables: { hello: "world" },
});
// check if provider is Open AI
if (modelParameters.provider === "openai") {
// Use the retrieved parameters to create a chat completion request
const modelResponse = await openai.chat.completions.create(
modelParameters.parameters
);
// Print the response from OpenAI
console.log(modelResponse.data);
}
}
main().catch(console.error);
Additional Information
For more details, visit the GitHub Repo.