Skip to main content

CLI tool to recognize receipt images using Gemini API and output in XML format

Project description

Harina v3 CLI

Harina v3 CLI

PyPI version Python 3.8+ AI Models MIT License CLI Tool

レシート画像を認識してXML形式で出力するCLIツールです。LiteLLM経由で複数のAIプロバイダー(Google Gemini、OpenAI、Anthropic Claude等)を使用してレシートの内容を解析します。

✨ 機能

  • レシート画像からテキスト情報を抽出
  • 店舗情報、商品情報、金額情報を構造化されたXML形式で出力
  • 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

# ファイルに出力
harina path/to/receipt_image.jpg -o output.xml

# 異なる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 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>

🖼️ 対応画像形式

  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harina_v3_cli-3.0.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harina_v3_cli-3.0.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file harina_v3_cli-3.0.1.tar.gz.

File metadata

  • Download URL: harina_v3_cli-3.0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for harina_v3_cli-3.0.1.tar.gz
Algorithm Hash digest
SHA256 0aa40085cce7fbd38b02dcf3f8ccbdcf338e34991158666b4658fc0dac33cc54
MD5 0d9683dab2b9e6f580767f1b44d54af3
BLAKE2b-256 46112a37aae292bb8372dd4c8d9752cd077bf2c29dd70933963c3ee51b17782c

See more details on using hashes here.

Provenance

The following attestation bundles were made for harina_v3_cli-3.0.1.tar.gz:

Publisher: deploy.yml on Sunwood-ai-labs/harina-v3-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harina_v3_cli-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: harina_v3_cli-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for harina_v3_cli-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 182ab6668547ff5c180a968e728ed23cbd20f9e59454b183ed1797a80acd17c8
MD5 2a9b495d9a9077fda9779d15c8be07e3
BLAKE2b-256 cc81ce5ce9940911bc90b32705670bab8df7b6df05149470141ceedc2bd302f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for harina_v3_cli-3.0.1-py3-none-any.whl:

Publisher: deploy.yml on Sunwood-ai-labs/harina-v3-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page