[Bug]: Rag does not tokenise PDF upload #3046
Replies: 4 comments 1 reply
-
The local lmstudio server is able to answer queries from code: import { OpenAI, OpenAIEmbeddings } from "@langchain/openai";
import { GithubRepoLoader } from "langchain/document_loaders/web/github";
import { HNSWLib } from "@langchain/community/vectorstores/hnswlib";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import { RetrievalQAChain } from "langchain/chains";
import { Document } from "langchain/document";
import * as fs from "fs";
import { Chroma } from "@langchain/community/vectorstores/chroma";
const fields = {
openAIApiKey: 'lmstudio', // process.env.OPENAI_API_KEY,
temperature: 0.1,
}
const config = {
//apiKey: 'lmstudio', // process.env.OPENAI_API_KEY,
// baseURL: "http://192.168.1.107:1234/v1",
baseURL: "https://abd9-31-22-13-147.ngrok-free.app/v1", // proxy in order to debug payload...
modelName: "lmstudio-community/Meta-Llama-3-8B-Instruct-GGUF/Meta-Llama-3-8B-Instruct-Q4_K_M.gguf",
}
const model = new OpenAI(fields, config) as any;
const embeddings = new OpenAIEmbeddings(fields, config);
export const run = async () => {
console.log("Running");
try {
// create vector store from chroma
const vectorStore = new Chroma(embeddings, { url: 'http://localhost:8000', collectionName: 'polkadot-sdk' });
// Create a chain that uses the OpenAI LLM and HNSWLib vector store.
const chain = RetrievalQAChain.fromLLM(
model,
vectorStore.asRetriever(5),
{
returnSourceDocuments: true,
}
);
const followUp = await chain.call({
temperature: 0.1,
query: 'hi, tell me about the polkadot sdk',
});
console.log({ followUp });
console.log(JSON.stringify(followUp.sourceDocuments, null, 2));
} catch (error) {
console.error("An error occurred:", error);
}
};
run(); in ngrok I see this request:
|
Beta Was this translation helpful? Give feedback.
-
I ran into the same problem. @dcolley : Did you find a solution for that? |
Beta Was this translation helpful? Give feedback.
-
After some digging, I found a workaround: In the rag-api container edit the file: config.py Add the parameter "check_embedding_ctx_length=False" to the OpenAIEmbeddings() call, it will then look like this:
|
Beta Was this translation helpful? Give feedback.
-
I added a feature request here: danny-avila/rag_api#115 |
Beta Was this translation helpful? Give feedback.
-
What happened?
Unable to load a PDF file as message context or in Attached Files
Steps to Reproduce
What browsers are you seeing the problem on?
Chrome
Relevant log output
Screenshots
Error processing file
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions