import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const client = new OpenAI({
apiKey: "YOUR_AZURE_OPENAI_API_KEY",
baseURL: `https://YOUR_AZURE_OPENAI_RESOURCE.openai.azure.com/openai/deployments/YOUR_AZURE_OPENAI_DEPLOYMENT`,
defaultQuery: { 'api-version': "2024-02-01" },
defaultHeaders: { 'api-key': "YOUR_AZURE_OPENAI_API_KEY" },
});
const azureModelDeployment = 'YOUR_AZURE_OPENAI_DEPLOYMENT';
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
async function main() {
const embedding = await client.embeddings.create({
model: azureModelDeployment,
input: "The quick brown fox jumped over the lazy dog",
encoding_format: "float",
});
console.log(embedding);
}
main();