Skip to content

Commit 8f61a2b

Browse files
authored
Merge pull request #25 from ca-srg/feature/csv-s3-source-support
feat: add CSV, S3, and Spreadsheet source support for vectorization
2 parents 3a33fab + 82bb875 commit 8f61a2b

36 files changed

+6323
-162
lines changed

CLAUDE.md renamed to AGENTS.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ RAGent は Markdownドキュメントからハイブリッド検索(BM25 + ベ
3535
- 環境変数からの設定読み込み
3636
- 設定検証とデフォルト値
3737
- **internal/scanner/**: ファイルスキャナー
38-
- markdownファイルの再帰的発見
38+
- ソースファイル(markdown/CSV)の再帰的発見
3939
- ファイルフィルタリング機能
4040
- **internal/metadata/**: メタデータ抽出
4141
- FrontMatter解析
4242
- ファイル情報抽出
43+
- **internal/csv/**: CSVファイル処理
44+
- `config.go`: CSV設定構造体(YAMLベース)
45+
- `reader.go`: CSVファイル読み込み・行展開
46+
- `column_detector.go`: 自動カラム検出
4347
- **internal/filter/**: フィルタ機能
4448
- RAG検索時の除外フィルタロジック
4549
- S3 Vector対応フィルタ構築
@@ -70,7 +74,7 @@ RAGent は Markdownドキュメントからハイブリッド検索(BM25 + ベ
7074
- ハイブリッド検索ツール提供
7175

7276
### Directories
73-
- **markdown/**: RAGシステムで使用するMarkdownドキュメントを配置(使用前に準備が必要)
77+
- **source/**: RAGシステムで使用するソースドキュメント(MarkdownおよびCSV)を配置(使用前に準備が必要)
7478
- **export/**: Kibelaノートエクスポート用の別ツール(独立したツール)
7579
- **doc/**: プロジェクト文書(S3 Vector設定推奨など)
7680
- **reference/**: 参考実装とサンプルコード
@@ -146,6 +150,7 @@ go vet ./...
146150
# 各コマンドの実行例
147151
go run main.go vectorize --dry-run # ベクトル化(ドライラン)
148152
go run main.go vectorize # ベクトル化実行
153+
go run main.go vectorize --csv-config csv-config.yaml # CSV設定を指定してベクトル化
149154
go run main.go vectorize --follow # フォローモード(30分間隔)
150155
go run main.go vectorize --follow --interval 15m # カスタム間隔のフォローモード
151156
go run main.go query -q "検索クエリ" # セマンティック検索
@@ -165,18 +170,28 @@ go run main.go mcp-server # MCP Server起動 [NEW]
165170

166171
## Prerequisites
167172

168-
Markdownドキュメントを`markdown/`ディレクトリに準備する必要があります。Kibelaからのエクスポートには`export/`ディレクトリの別ツールを使用してください。
173+
ソースドキュメント(MarkdownまたはCSV)を`source/`ディレクトリに準備する必要があります。
174+
175+
**対応ファイル形式:**
176+
- Markdown (.md, .markdown): 各ファイルが1つのドキュメントになります
177+
- CSV (.csv): 各行が1つのドキュメントになります(ヘッダー行が必須)
178+
179+
CSVファイルのカラムマッピングは `--csv-config` オプションで設定できます。
180+
Kibelaからのエクスポートには`export/`ディレクトリの別ツールを使用してください。
169181

170182
## Usage Examples
171183

172184
```bash
173185
# 1. ベクトル化とS3保存
174-
./RAGent vectorize --directory ./markdown --concurrency 10
186+
./RAGent vectorize --directory ./source --concurrency 10
187+
188+
# 1a. CSV設定を指定してベクトル化
189+
./RAGent vectorize --csv-config csv-config.yaml
175190

176-
# 1a. フォローモードで継続的にベクトル化(30分間隔)
191+
# 1b. フォローモードで継続的にベクトル化(30分間隔)
177192
./RAGent vectorize --follow
178193

179-
# 1b. フォローモードで15分間隔に設定
194+
# 1c. フォローモードで15分間隔に設定
180195
./RAGent vectorize --follow --interval 15m
181196
# ※ `--follow` は `--dry-run` および `--clear` と併用不可
182197

README.md

Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RAGent is a CLI tool for building a RAG (Retrieval-Augmented Generation) system
3333

3434
## Features
3535

36-
- **Vectorization**: Convert markdown files to embeddings using Amazon Bedrock
36+
- **Vectorization**: Convert source files (markdown and CSV) to embeddings using Amazon Bedrock
3737
- **S3 Vector Integration**: Store generated vectors in Amazon S3 Vectors
3838
- **Hybrid Search**: Combined BM25 + vector search using OpenSearch
3939
- **Slack Search Integration**: Blend document results with Slack conversations via an iterative enrichment pipeline
@@ -313,18 +313,57 @@ flowchart TD
313313

314314
## Prerequisites
315315

316-
### Prepare Markdown Documents
316+
### Prepare Source Documents
317317

318-
Before using RAGent, you need to prepare markdown documents in a `markdown/` directory. These documents should contain the content you want to make searchable through the RAG system.
318+
Before using RAGent, you need to prepare source documents in a `source/` directory. These documents should contain the content you want to make searchable through the RAG system.
319319

320+
**Supported file types:**
321+
- **Markdown (.md, .markdown)**: Each file becomes one document
322+
- **CSV (.csv)**: Each row becomes one document (header row required)
323+
324+
```bash
325+
# Create source directory
326+
mkdir source
327+
328+
# Place your files in this directory
329+
cp /path/to/your/documents/*.md source/
330+
cp /path/to/your/data/*.csv source/
331+
```
332+
333+
For CSV files, you can optionally provide a configuration file to specify column mappings:
320334
```bash
321-
# Create markdown directory
322-
mkdir markdown
335+
# Copy example configuration
336+
cp csv-config.yaml.example csv-config.yaml
337+
338+
# Run with CSV configuration
339+
RAGent vectorize --csv-config csv-config.yaml
340+
```
341+
342+
#### CSV Configuration Options
343+
344+
The `csv-config.yaml` supports the following options:
345+
346+
**header_row (Header Row Position):**
347+
348+
Use this option when your CSV file has metadata or summary rows before the actual header row.
349+
When `header_row` is specified, that row is used as the column headers, and all preceding rows are skipped.
323350

324-
# Place your markdown files in this directory
325-
cp /path/to/your/documents/*.md markdown/
351+
```yaml
352+
csv:
353+
files:
354+
- pattern: "sample.csv"
355+
header_row: 7 # Row 7 is the header (1-indexed)
356+
# Rows 1-6 are skipped, data starts from row 8
357+
content:
358+
columns: ["task", "category"]
359+
metadata:
360+
title: "task"
361+
category: "category"
326362
```
327363
364+
- If `header_row` is not specified, the default is `1` (first row is the header)
365+
- Row numbers are 1-indexed
366+
328367
For exporting notes from Kibela, use the separate export tool available in the `export/` directory.
329368

330369
## Required Environment Variables
@@ -607,20 +646,41 @@ All entries should report `OK`. If a mismatch occurs, re-download the artifact.
607646

608647
### 1. vectorize - Vectorization and S3 Storage
609648

610-
Read markdown files, extract metadata, generate embeddings using Amazon Bedrock, and store them in Amazon S3 Vectors.
649+
Read source files (markdown and CSV), extract metadata, generate embeddings using Amazon Bedrock, and store them in Amazon S3 Vectors.
611650

612651
```bash
613652
RAGent vectorize
614653
```
615654

616655
**Options:**
617-
- `-d, --directory`: Directory containing markdown files to process (default: `./markdown`)
656+
- `-d, --directory`: Directory containing source files to process (default: `./source`)
618657
- `--dry-run`: Display processing details without making actual API calls
619658
- `-c, --concurrency`: Number of concurrent processes (0 = use default value from config file)
659+
- `--csv-config`: Path to CSV configuration YAML file (for column mapping)
660+
- `--enable-s3`: Enable S3 source file fetching
661+
- `--s3-bucket`: S3 bucket name for source files (required when `--enable-s3` is set)
662+
- `--s3-prefix`: S3 prefix (directory) to scan (optional, defaults to bucket root)
663+
664+
**S3 Source Examples:**
665+
```bash
666+
# S3 only (with prefix)
667+
RAGent vectorize --enable-s3 --s3-bucket my-docs-bucket --s3-prefix source/
668+
669+
# S3 only (flat structure)
670+
RAGent vectorize --enable-s3 --s3-bucket my-docs-bucket
671+
672+
# Local + S3 combined
673+
RAGent vectorize --directory ./local-docs --enable-s3 --s3-bucket my-docs-bucket --s3-prefix remote/
674+
675+
# Dry run with S3 source
676+
RAGent vectorize --enable-s3 --s3-bucket my-docs-bucket --dry-run
677+
```
620678

621679
**Features:**
622-
- Recursive scanning of markdown files
680+
- Recursive scanning of markdown and CSV files
623681
- Automatic metadata extraction
682+
- CSV row expansion (each row becomes a document)
683+
- Automatic column detection for CSV files (or explicit configuration)
624684
- Embedding generation using Amazon Titan Text Embedding v2
625685
- Safe storage to S3 Vectors
626686
- High-speed processing through concurrency
@@ -879,13 +939,14 @@ RAGent/
879939
│ └── vectorize.go # vectorize command
880940
├── internal/ # Internal libraries
881941
│ ├── config/ # Configuration management
942+
│ ├── csv/ # CSV file processing
882943
│ ├── embedding/ # Embedding generation
883944
│ ├── s3vector/ # S3 Vector integration
884945
│ ├── opensearch/ # OpenSearch integration
885946
│ ├── vectorizer/ # Vectorization service
886947
│ ├── slackbot/ # Slack Bot integration
887948
│ └── mcpserver/ # MCP Server integration (new)
888-
├── markdown/ # Markdown documents (prepare before use)
949+
├── source/ # Source documents (markdown and CSV, prepare before use)
889950
├── export/ # Separate export tool for Kibela
890951
├── doc/ # Project documentation
891952
│ ├── mcp-server.md # MCP Server setup guide
@@ -933,12 +994,19 @@ RAGent/
933994
# Edit .env file
934995
```
935996

936-
2. **Prepare Markdown Documents**
997+
2. **Prepare Source Documents**
937998
```bash
938-
# Create markdown directory if not exists
939-
mkdir -p markdown
999+
# Create source directory if not exists
1000+
mkdir -p source
1001+
1002+
# Place your files in the directory (markdown and/or CSV)
1003+
cp /path/to/docs/*.md source/
1004+
cp /path/to/data/*.csv source/
1005+
1006+
# For CSV files, optionally configure column mapping:
1007+
cp csv-config.yaml.example csv-config.yaml
1008+
# Edit csv-config.yaml to specify columns
9401009

941-
# Place your markdown files in the directory
9421010
# Or use the export tool for Kibela notes:
9431011
cd export
9441012
go build -o RAGent-export
@@ -954,6 +1022,9 @@ RAGent/
9541022
# Execute actual vectorization
9551023
RAGent vectorize
9561024

1025+
# Vectorize with CSV configuration
1026+
RAGent vectorize --csv-config csv-config.yaml
1027+
9571028
# Continuously vectorize using follow mode (default 30m interval)
9581029
RAGent vectorize --follow
9591030

0 commit comments

Comments
 (0)