
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Ragify is a CLI tool that allows you to upload PDF documents and store their embeddings in a vector database (Pinecone or ChromaDB) for Retrieval-Augmented Generation (RAG) applications. It also provides a function to retrieve relevant responses from the vector database and pass them through an LLM to generate answers based on the uploaded document.
✅ Supports Pinecone and ChromaDB as vector databases.
✅ Splits PDF documents into chunks using LangChain.
✅ Generates embeddings using OpenAI's text-embedding-3-large model.
✅ Stores embeddings in the selected vector database for efficient retrieval.
Install Ragify using npm:
npm i ragify
This package provides two key functions:
uploadFile(filePath): Uploads a PDF file, generates embeddings, and stores them in the selected vector database.askQuestion(query): Retrieves relevant information from the stored embeddings and uses an LLM to generate a response.Currently, Pinecone and ChromaDB are the supported vector databases.
Before using the library, set up your .env file with the required credentials.
DB_TYPE=pinecone
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=your_index_name
PINECONE_ENV=your_pinecone_environment
OPENAI_API_KEY=your_open_ai_api_key
OPENAI_MODEL=your_desired_model by default the 'gpt-4' model will be used
OPENAI_EMBEDDING_MODEL=your_desired_model by default the text-embedding-3-large will be used
DB_TYPE=chroma
CHROMA_DB_URL=http://localhost:8000
COLLECTION_NAME=pdf_embeddings
OPENAI_API_KEY=your_open_ai_api_key
OPENAI_MODEL=your_desired_model by default the 'gpt-4' model will be used
To run the CLI tool:
node cli.js
Follow the prompts to select a database and provide the necessary details.
Alternatively, you can use the functions in your Node.js project:
import { uploadFile, askQuestion } from "ragify";
// Upload a PDF file
await uploadFile("./documents/example.pdf");
// Ask a question based on the document
const response = await askQuestion("What is the summary of the document?");
console.log(response);
1️⃣ User selects a vector database (Pinecone/ChromaDB).
2️⃣ User provides the necessary database details.
3️⃣ PDF file is loaded and split into chunks using LangChain.
4️⃣ Embeddings are generated using the OpenAI API.
5️⃣ Embeddings are stored in the selected vector database.
6️⃣ When a query is made, relevant embeddings are retrieved and passed through an LLM to generate a response.
If embeddings are not being stored correctly in Pinecone:
curl -X GET "https://api.pinecone.io/v1/whoami" -H "Api-Key: ${PINECONE_API_KEY}"
curl -X GET "https://controller.${PINECONE_ENV}.pinecone.io/databases" -H "Api-Key: ${PINECONE_API_KEY}"
Modify uploadFile() to inspect document chunks:
console.log(allSplits[0]);
Contributions are welcome! Feel free to submit issues and pull requests to improve this library.
A powerful conversational question-answering system built on LangGraph and LangChain that maintains conversation history and performs retrieval-augmented generation (RAG).
npm install langchain-conversational-qa
Create a .env file with your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4 # Optional, defaults to gpt-4
import { ConversationalAgent } from 'langchain-conversational-qa';
// Create a conversational agent instance
const agent = new ConversationalAgent();
// Ask questions
const response = await agent.query("What is LangChain?");
console.log(response);
// Follow-up questions maintain context
const followUp = await agent.query("Can you give me an example?");
console.log(followUp);
// Create an agent with custom options
const customAgent = new ConversationalAgent({
model: "gpt-4-turbo",
apiKey: "your-openai-api-key",
minHistorySize: 15 // Keep at least 15 conversation turns
});
import express from 'express';
import { ConversationalAgent } from 'langchain-conversational-qa';
const app = express();
const PORT = process.env.PORT || 3000;
const agent = new ConversationalAgent();
app.use(express.json());
app.post('/api/query', async (req, res) => {
try {
const { query } = req.body;
const response = await agent.query(query);
res.json({ answer: response });
} catch (error) {
console.error(error);
res.status(500).json({ error: 'An error occurred' });
}
});
app.post('/api/reset', async (req, res) => {
try {
await agent.resetConversation();
res.json({ status: 'Conversation history reset' });
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Failed to reset conversation' });
}
});
app.get('/api/history', async (req, res) => {
try {
const history = await agent.getConversationHistory();
res.json({ history });
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Failed to retrieve conversation history' });
}
});
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
The agent automatically maintains conversation history across multiple queries as long as you're using the same agent instance. This is particularly important in server environments where you need to create the agent once, outside of your request handlers.
// CORRECT: Create once at server startup
const agent = new ConversationalAgent();
// INCORRECT: Creating a new agent for each request will lose history
app.post('/api/query', async (req, res) => {
const agent = new ConversationalAgent(); // Don't do this!
// ...
});
ConversationalAgentnew ConversationalAgent(options?)
Options:
model: OpenAI model to use (default: "gpt-4" or value from OPENAI_MODEL env variable)apiKey: OpenAI API key (default: value from OPENAI_API_KEY env variable)minHistorySize: Minimum conversation turns to maintain (default: 10)query(question: string): Process a question and return the answerresetConversation(): Clear conversation historygetConversationHistory(): Get the current conversation historycreateExecutorCreates a stateful executor function that can be used for standalone processing.
const executor = createExecutor();
const result = await executor("What is LangChain?");
The library uses LangGraph to define a processing workflow:
initialize_history: Sets up the conversation historyretrieve: Fetches relevant context from your data sourcesgenerate: Creates a response using the LLM, context, and conversation historyThe conversation history is maintained between calls by storing it within the agent instance.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
This project is licensed under the MIT License.
FAQs
RAG Chat bot library
The npm package ragify receives a total of 1 weekly downloads. As such, ragify popularity was classified as not popular.
We found that ragify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.