Skip to content

Commit

Permalink
Refactor main.py to optimize card existence check and improve error h…
Browse files Browse the repository at this point in the history
…andling
  • Loading branch information
kkdai committed Jul 12, 2024
1 parent 81fcca4 commit b22a5d0
Showing 1 changed file with 60 additions and 25 deletions.
85 changes: 60 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,74 @@
# NameCard Helper
# LineBot Smart Namecard

## Project Background
這是一個使用 FastAPI 和 LINE Messaging API 的智能名片管理機器人。該機器人可以處理文本和圖像消息,並將名片數據存儲在 Firebase Firestore 中。

## Screenshot
## 功能

## Features
- 接收並處理文本消息
- 接收並處理圖像消息,從圖像中提取名片數據
- 將名片數據存儲在 Firebase Firestore 中
- 查詢和刪除冗餘的名片數據

## Technologies Used
## 環境變數

- Python 3
- FastAPI
- LINE Messaging API
- Google Generative AI
- Aiohttp
- PIL (Python Imaging Library)
- Firebase
在運行此應用程序之前,請確保設置以下環境變數:

## Setup
- `ChannelSecret`: LINE Messaging API 的 Channel Secret
- `ChannelAccessToken`: LINE Messaging API 的 Channel Access Token
- `GEMINI_API_KEY`: Gemini API 的 API Key

1. Clone the repository to your local machine.
2. Set the following environment variables:
- `ChannelSecret`: Your LINE channel secret.
- `ChannelAccessToken`: Your LINE channel access token.
- `GEMINI_API_KEY`: Your Gemini API key for AI processing.
- `FIREBASE_URL`: Your Firebase database URL.
3. Install the required dependencies by running `pip install -r requirements.txt`.
4. Start the FastAPI server with `uvicorn main:app --reload`.
## 安裝

## Usage
1. 克隆此存儲庫:

This repository provides a FastAPI application that integrates with LINE Messaging API, Firebase, and Gemini Pro API to manage and process name cards. Below are the steps to set up and run the application.
```bash
git clone https://github.com/yourusername/linebot-smart-namecard.git
cd linebot-smart-namecard
```

## Commands
2. 創建並激活虛擬環境:

- `!清空`: Clears all the scanned receipt history for the user.
```bash
python3 -m venv venv
source venv/bin/activate
```

3. 安裝依賴項:

```bash
pip install -r requirements.txt
```

4. 設置環境變數:

```bash
export ChannelSecret=your_channel_secret
export ChannelAccessToken=your_channel_access_token
export GEMINI_API_KEY=your_gemini_api_key
```

5. 運行應用程序:

```bash
uvicorn main:app --reload
```

## 使用

### 接收文本消息

- 發送 "test" 消息以生成並返回示例名片數據。
- 發送 "list" 消息以列出所有名片數據。
- 發送 "remove" 消息以刪除冗餘的名片數據。

### 接收圖像消息

- 發送包含名片圖像的消息,機器人將提取名片數據並將其存儲在 Firebase Firestore 中。

## 代碼結構

- `main.py`: 主應用程序文件,包含所有的路由和處理邏輯。
- `requirements.txt`: 依賴項文件。

## Contributing

Expand Down

0 comments on commit b22a5d0

Please sign in to comment.