|
2 | 2 |
|
3 | 3 | <div align="center"> |
4 | 4 |
|
| 5 | +**TypeScript NLP pipeline for fast, structured text understanding** |
| 6 | + |
| 7 | +[](https://github.com/dev-dami/Qirrel/actions/workflows/ci.yml) |
| 8 | +[](https://github.com/dev-dami/Qirrel/actions/workflows/release.yml) |
5 | 9 | [](https://www.npmjs.com/package/qirrel) |
6 | 10 | [](https://www.npmjs.com/package/qirrel) |
7 | 11 | [](./LICENSE) |
8 | 12 | [](https://www.typescriptlang.org/) |
9 | 13 |
|
| 14 | +[GitHub](https://github.com/dev-dami/Qirrel) · [NPM](https://www.npmjs.com/package/qirrel) · Author: [Damilare Osibanjo](https://github.com/dev-dami) |
| 15 | + |
10 | 16 | </div> |
11 | 17 |
|
12 | | -Qirrel is a TypeScript NLP library for tokenization, rule-based entity extraction, optional LLM enrichment, and pipeline orchestration. |
| 18 | +## Why Qirrel |
| 19 | + |
| 20 | +Qirrel gives you a production-ready pipeline for extracting structure from raw text: |
13 | 21 |
|
14 | | -[GitHub](https://github.com/dev-dami/qirrel) | [NPM](https://www.npmjs.com/package/qirrel) | Author: [Damilare Osibanjo](https://github.com/dev-dami) |
| 22 | +- Tokenization with positional metadata. |
| 23 | +- Rule-based extraction for email, phone, URL, and number entities. |
| 24 | +- Optional LLM enrichment via adapter pattern. |
| 25 | +- Built-in caching and lifecycle events. |
| 26 | +- Batch processing with controllable concurrency. |
15 | 27 |
|
16 | 28 | ## Install |
17 | 29 |
|
18 | 30 | ```bash |
19 | 31 | bun add qirrel |
20 | 32 | ``` |
21 | 33 |
|
22 | | -## Quick Start |
| 34 | +## 30-Second Start |
23 | 35 |
|
24 | 36 | ```ts |
25 | 37 | import { processText } from 'qirrel'; |
26 | 38 |
|
27 | | -const result = await processText('Contact John at john@example.com or call +1 415 555 2671'); |
| 39 | +const result = await processText( |
| 40 | + 'Contact Jane at jane@example.com or +44 20 7946 0958', |
| 41 | +); |
| 42 | + |
28 | 43 | console.log(result.data?.entities); |
29 | 44 | ``` |
30 | 45 |
|
31 | | -## Batch Processing |
| 46 | +## Core Features |
| 47 | + |
| 48 | +| Feature | API | Notes | |
| 49 | +| --- | --- | --- | |
| 50 | +| Single-text processing | `processText(text)` | Returns `QirrelContext` | |
| 51 | +| Batch processing | `processTexts(texts, configPath?, { concurrency })` | Keeps input order | |
| 52 | +| Custom pipeline | `new Pipeline(configPath?)` | Add processors and hooks | |
| 53 | +| Events | `pipeline.on(PipelineEvent.*, handler)` | Run/processor/error telemetry | |
| 54 | +| Caching | `pipeline.isCached/getCached/setCached` | LRU + TTL | |
| 55 | +| LLM adapter | `pipeline.getLLMAdapter()` | `gemini`, `openai`, `generic` | |
| 56 | + |
| 57 | +## Batch Example |
32 | 58 |
|
33 | 59 | ```ts |
34 | | -import { processTexts, Pipeline } from 'qirrel'; |
| 60 | +import { processTexts } from 'qirrel'; |
35 | 61 |
|
36 | | -const results = await processTexts(['first input', 'second input'], undefined, { concurrency: 2 }); |
| 62 | +const inputs = [ |
| 63 | + 'US: +1 415 555 2671', |
| 64 | + 'URL: https://example.com', |
| 65 | + 'Email: team@example.com', |
| 66 | +]; |
37 | 67 |
|
38 | | -const pipeline = new Pipeline(); |
39 | | -const ordered = await pipeline.processBatch(['a', 'b', 'c'], { concurrency: 3 }); |
| 68 | +const outputs = await processTexts(inputs, undefined, { concurrency: 2 }); |
| 69 | +console.log(outputs.map((o) => o.data?.entities)); |
40 | 70 | ``` |
41 | 71 |
|
42 | | -## LLM Integration |
| 72 | +## LLM Example |
43 | 73 |
|
44 | 74 | ```ts |
45 | 75 | import { Pipeline } from 'qirrel'; |
46 | 76 |
|
47 | 77 | const pipeline = new Pipeline('./config-with-llm.yaml'); |
48 | 78 | await pipeline.init(); |
49 | 79 |
|
50 | | -const llmAdapter = pipeline.getLLMAdapter(); |
51 | | -if (llmAdapter) { |
52 | | - const response = await llmAdapter.generate('Summarize this text: Hello world'); |
| 80 | +const adapter = pipeline.getLLMAdapter(); |
| 81 | +if (adapter) { |
| 82 | + const response = await adapter.generate('Summarize: Qirrel is an NLP pipeline.'); |
53 | 83 | console.log(response.content); |
54 | 84 | } |
55 | 85 | ``` |
56 | 86 |
|
57 | | -## Caching |
| 87 | +## Minimal LLM Config |
58 | 88 |
|
59 | | -```ts |
60 | | -import { Pipeline } from 'qirrel'; |
| 89 | +```yaml |
| 90 | +llm: |
| 91 | + enabled: true |
| 92 | + provider: openai |
| 93 | + apiKey: ${QIRREL_LLM_API_KEY} |
| 94 | + model: gpt-4o-mini |
| 95 | + timeout: 30000 |
| 96 | + cacheTtl: 300000 |
| 97 | +``` |
61 | 98 |
|
62 | | -const pipeline = new Pipeline(); |
| 99 | +## Quality Gates (CI/CD) |
63 | 100 |
|
64 | | -if (pipeline.isCached('some text')) { |
65 | | - console.log(pipeline.getCached('some text')); |
66 | | -} else { |
67 | | - const result = await pipeline.process('some text'); |
68 | | - console.log(result.data?.entities); |
69 | | -} |
70 | | -``` |
| 101 | +This repository includes GitHub Actions workflows: |
| 102 | +
|
| 103 | +- `ci.yml`: runs install, build, tests, and coverage on push/PR. |
| 104 | +- `release.yml`: runs release checks and can publish to npm on version tags (`v*`) when `NPM_TOKEN` is configured. |
71 | 105 |
|
72 | 106 | ## Documentation |
73 | 107 |
|
74 | | -- [API Reference](./docs/api.md) |
75 | | -- [Configuration Guide](./docs/configuration.md) |
76 | | -- [Usage Examples](./docs/examples.md) |
77 | | -- [Basic Usage](./docs/usage/basic.md) |
78 | | -- [LLM Integration](./docs/integrations/llm.md) |
79 | | -- [Pipeline Events](./docs/events.md) |
80 | | -- [Caching](./docs/usage/caching.md) |
| 108 | +- [Docs Home (Styled)](./docs/index.html) |
| 109 | +- [API Reference](./docs/pages/api.html) |
| 110 | +- [Configuration Guide](./docs/pages/configuration.html) |
| 111 | +- [Usage Examples](./docs/pages/examples.html) |
| 112 | +- [Basic Usage](./docs/pages/basic.html) |
| 113 | +- [Caching](./docs/pages/caching.html) |
| 114 | +- [Pipeline Events](./docs/pages/events.html) |
| 115 | +- [LLM Integration](./docs/pages/llm.html) |
| 116 | +- [Architecture Walkthrough](./docs/pages/walkthrough.html) |
| 117 | + |
| 118 | +Markdown source docs are still available under `./docs/`. |
81 | 119 |
|
82 | 120 | ## Contributing |
83 | 121 |
|
|
0 commit comments