Closed arhaang13 closed 3 months ago
You'll have to update the scripts/background.ts
file.
@langchain/openai
: npm install @langchain/openai
OpenAIEmbeddings
. See docs.
import { OpenAIEmbeddings } from "@langchain/openai";
OllamaEmbeddings
instance with OpenAIEmbeddings
instance.
// load documents into vector store
vectorStore = new EnhancedMemoryVectorStore(
new OpenAIEmbeddings({
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.OPENAI_API_KEY
batchSize: 512, // Default value if omitted is 512. Max is 2048
model: "text-embedding-3-large",
});
);
npm run build
.That's it! Let me know if that helps.
Thank you so much, this helped me a lot!
In addition, I would like to ask if there is a way that I could integrate and call the openAI API instead of using Ollama models with Lumos itself because using the Ollama models on my local system is making my system way slower, so I would like to use the complete RAG using openAI option.
Kindly help me out with the same.
Thank you,
if there is a way that I could integrate and call the openAI API
Again, you'll have to update the scripts/background.ts
file.
@langchain/openai
: npm install @langchain/openai
ChatOpenAI
and OpenAI
.import { ChatOpenAI } from "@langchain/openai";
import { OpenAI } from "@langchain/openai";
ChatOllama
instance with ChatOpenAI
instance.
const getChatModel = (options: LumosOptions): Runnable => {
return new ChatOpenAI({
apiKey: "YOUR-API-KEY",
callbacks: [new ConsoleCallbackHandler()],
}).bind({
signal: controller.signal,
});
};
Replace Ollama
instance with OpenAI
instance.
const classifyPrompt = async (
options: LumosOptions,
type: string,
originalPrompt: string,
classifcationPrompt: string,
prefixTrigger?: string,
): Promise<boolean> => {
...
// otherwise, attempt to classify prompt
const openai = new OpenAI({
apiKey: "YOUR-API-KEY",
temperature: 0,
stop: [".", ","],
}).bind({
signal: controller.signal,
});
...
};
npm run build
.Closing this issue for now. @arhaang13, let me know if you need more help.
Can you please help me navigating how to change and experiment the same application with the openAI embeddings API.