Harina v3 CLI
レシート画像を認識してXML形式で出力するCLIツールです。LiteLLM経由で複数のAIプロバイダー(Google Gemini、OpenAI、Anthropic Claude等)を使用してレシートの内容を解析します。
✨ 機能
- レシート画像からテキスト情報を抽出
- 店舗情報、商品情報、金額情報を構造化されたXMLまたはCSV形式で出力
- Google Gemini APIを使用した高精度な画像認識
- コマンドライン インターフェース
🚀 クイックスタート
# PyPIからインストール
pip install harina-v3-cli
# 使用方法
harina path/to/receipt.jpg
📦 インストール
PyPIからインストール(推奨)
pip install harina-v3-cli
開発者向けインストール
# リポジトリをクローン
git clone https://github.com/Sunwood-ai-labs/harina-v3-cli.git
cd harina-v3-cli
# 依存関係をインストール
uv sync
# 開発モードでインストール
uv pip install -e .
💡 使用方法
🔑 環境変数の設定
APIキーを設定するには、.envファイルを使用します:
# .envファイルの例をコピー
cp .env.example .env
.envファイルを編集してAPIキーを設定:
# Google Geminiを使用する場合(デフォルト)
GEMINI_API_KEY=your_actual_gemini_api_key_here
# その他のプロバイダーについては.env.exampleを参照
詳細な環境変数設定については、開発者向けガイドをご覧ください。
🛠️ 基本的な使用方法
# 標準出力にXMLを出力(デフォルト: Gemini 1.5 Flash)
harina path/to/receipt_image.jpg
# ファイルに出力(XML形式)
harina path/to/receipt_image.jpg -o output.xml
# CSV形式で出力
harina path/to/receipt_image.jpg --format csv -o output.csv
# 異なるGeminiモデルを使用
harina path/to/receipt_image.jpg --model gemini/gemini-1.5-pro
# OpenAIのGPT-4oを使用する場合(OPENAI_API_KEYが必要)
harina path/to/receipt_image.jpg --model gpt-4o
# Claude 3 Sonnetを使用する場合(ANTHROPIC_API_KEYが必要)
harina path/to/receipt_image.jpg --model claude-3-sonnet-20240229
# 環境変数でデフォルトモデルを設定
export HARINA_MODEL=gpt-4o
harina path/to/receipt_image.jpg
📄 出力形式
XML形式
XMLの出力形式は以下のようになります:
<?xml version="1.0" ?>
<receipt>
<store_info>
<name>店舗名</name>
<address>住所</address>
<phone>電話番号</phone>
</store_info>
<transaction_info>
<date>2024-01-15</date>
<time>14:30</time>
<receipt_number>12345</receipt_number>
</transaction_info>
<items>
<item>
<name>商品名1</name>
<quantity>1</quantity>
<unit_price>100</unit_price>
<total_price>100</total_price>
</item>
<item>
<name>商品名2</name>
<quantity>2</quantity>
<unit_price>200</unit_price>
<total_price>400</total_price>
</item>
</items>
<totals>
<subtotal>500</subtotal>
<tax>50</tax>
<total>550</total>
</totals>
<payment_info>
<method>現金</method>
<amount_paid>1000</amount_paid>
<change>450</change>
</payment_info>
</receipt>
CSV形式
CSVの出力形式は以下のようになります:
store_name,store_address,store_phone,transaction_date,transaction_time,receipt_number,item_name,item_category,item_subcategory,item_quantity,item_unit_price,item_total_price,subtotal,tax,total,payment_method,amount_paid,change
店舗名,住所,電話番号,2024-01-15,14:30,12345,商品名1,カテゴリ1,サブカテゴリ1,1,100,100,500,50,550,現金,1000,450
店舗名,住所,電話番号,2024-01-15,14:30,12345,商品名2,カテゴリ2,サブカテゴリ2,2,200,400,500,50,550,現金,1000,450
各商品は1行として出力され、店舗情報や取引情報は各商品行に繰り返し含まれます。
🖼️ 対応画像形式
- JPEG (.jpg, .jpeg)
- PNG (.png)
- GIF (.gif)
- BMP (.bmp)
- その他PIL(Pillow)でサポートされている形式
📋 必要な依存関係
- Python 3.8以上
- litellm
- click
- pillow
- requests
🔐 API キーの取得
使用するモデルプロバイダーに応じて、以下からAPIキーを取得してください:
| プロバイダー | 取得先 | 環境変数 |
|---|---|---|
| Google Gemini | Google AI Studio | GEMINI_API_KEY |
| OpenAI GPT | OpenAI Platform | OPENAI_API_KEY |
| Anthropic Claude | Anthropic Console | ANTHROPIC_API_KEY |
🔒 セキュリティに関する重要な注意事項
- APIキーを直接コードに書き込まないでください
- APIキーをGitリポジトリにコミットしないでください
.envファイルは.gitignoreに含まれているため、Gitで追跡されません- 本番環境では環境変数を使用してAPIキーを設定してください
- APIキーが漏洩した場合は、すぐにGoogle AI Studioで無効化し、新しいキーを生成してください
📚 詳細ドキュメント
📄 ライセンス
MIT License
Release files for harina-v3-cli 3.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| harina_v3_cli-3.1.0.tar.gz | 14.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harina_v3_cli-3.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.1 kB
Release files / harina_v3_cli-3.1.0.tar.gz
| Download URL | harina_v3_cli-3.1.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d385bcdb4047e95246c1e64e87555dd7719e4a655d92a853976ddf51b577e818
|
|
BLAKE2b-256 checksum How to use checksums |
6c064bfd0e2d83039d6f1948a0ebfdc090aebd8a11ff6c1dfc89aa66ab4f06df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 28, 2025.
Transparency logRelease files / harina_v3_cli-3.1.0-py3-none-any.whl
| Download URL | harina_v3_cli-3.1.0-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed3842dbae7b5957d07befd8e53fcef6e801b976f5e1cf8b8ca9fca29ba39c02
|
|
BLAKE2b-256 checksum How to use checksums |
3045a67e4791e3bb38fdfb6d53ffdb0531049222229e0834ee65b4553576b267
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 28, 2025.
Transparency log