Skip to content
jmerelnycPublic

About

AI-powered document analysis and question answering system

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

doc-clerk

AI-powered document analysis and question answering system

npm install doc-clerk
const DocClerk = require('doc-clerk');

const clerk = new DocClerk({ apiKey: process.env.OPENAI_KEY });

clerk.ingest('./documents/report.pdf');
const answer = await clerk.ask('What were Q3 revenues?');
console.log(answer);

notes

Chunks documents, builds embeddings, retrieves relevant context for LLM queries. Supports PDF, DOCX, TXT, MD. Uses OpenAI by default but works with local models via Ollama.

Indexing happens in memory by default. For persistence, pass { storage: 'sqlite' } or implement custom storage adapter.

const clerk = new DocClerk({
  apiKey: process.env.OPENAI_KEY,
  storage: 'sqlite',
  dbPath: './doc-index.db',
  chunkSize: 1000,
  chunkOverlap: 200,
  model: 'gpt-4'
});

// Batch ingest
await clerk.ingestDir('./docs', { recursive: true });

// Stream responses
const stream = clerk.askStream('Summarize key findings');
for await (const chunk of stream) {
  process.stdout.write(chunk);
}

// Get citations
const result = await clerk.ask('What is the policy?', { citations: true });
console.log(result.answer);
console.log(result.sources); // [{ file: 'policy.pdf', page: 3, snippet: '...' }]

// Use local model
const localClerk = new DocClerk({
  provider: 'ollama',
  model: 'llama2',
  embedModel: 'nomic-embed-text'
});

MIT

About

AI-powered document analysis and question answering system

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages