Skip to content

Commit

Permalink
docs: add OpenAIEmbedding to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusschiesser committed Feb 29, 2024
1 parent e9c2366 commit 7055d6f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/openai.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "llamaindex";
import { OpenAI, OpenAIEmbedding } from "llamaindex";

(async () => {
const llm = new OpenAI({ model: "gpt-4-1106-preview", temperature: 0.1 });
Expand All @@ -12,4 +12,10 @@ import { OpenAI } from "llamaindex";
messages: [{ content: "Tell me a joke.", role: "user" }],
});
console.log(response2.message.content);

// embeddings
const embedModel = new OpenAIEmbedding();
const texts = ["hello", "world"];
const embeddings = await embedModel.getTextEmbeddingsBatch(texts);
console.log(`\nWe have ${embeddings.length} embeddings`);
})();

0 comments on commit 7055d6f

Please sign in to comment.