Skip to content

Commit

Permalink
docs: setup environment
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinHsu1019 committed Nov 13, 2024
1 parent 079aa25 commit 2d282b5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Preprocess/insert_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def split_and_insert(self, pid, content, category):
elif not result: # 如果失敗且非長度問題
failed_records.append({'pid': pid, 'category': category})

# 將失敗的資料寫入 JSON 檔案
# 將失敗的資料寫入 JSON 檔案,之後有需要可以利用此 JSON 檔案重新匯入
if failed_records:
with open('failed_imports.json', 'w', encoding='utf-8') as f:
json.dump(failed_records, f, ensure_ascii=False, indent=4)
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ To set up the development environment, follow these steps:
```

4. Manually add your `secret key` to the `config.ini`.
(需展開解釋 config.ini 內的每一項 key)
```
[OpenAI] 的 api_key 可以在 openai 官網註冊取得
[VoyageAI] 的 api_key 可以在 voyageai 官網註冊取得
[Api_docs] 的 password 可以自己隨意輸入 (flask_app.py 啟動後,直接訪問 http://127.0.0.1:5000/ 即可看到 swagger api_docs 頁面)
```

5. Create a `logs` directory:
```
Expand All @@ -82,18 +86,26 @@ To set up the development environment, follow these steps:
```

8. Data preprocessing:
```
(TODO: 等 data 那邊處理好)
```

9. Data insert to weaviate:
```
python3 Preprocess/insert_data.py
```

10. Run the Flask app:
10. Run the Flask app (/ 是 API Docs, /api/chat/ 是我們的 Retrieval API):
```
python3 src/flask_app.py
python3 Model/flask_app.py
```

11. 將主辦方提供的 questions.json 測試資料塞入 data/:
11. 將主辦方提供的題目 json 檔案改名為 questions.json 並塞入 data/

12. 運行 main.py 進行測試得出 data/pred_retrieve.json 提交最終結果給主辦方:

```
python3 main.py
```

## Folder-specific Details
For more detailed information about each folder and its purpose, refer to the individual `README.md` files located in their respective directories.
8 changes: 4 additions & 4 deletions config_example.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[Weaviate]
weaviate_url =
weaviate_url = http://127.0.0.1:8882

[OpenAI]
api_key =
api_key =

[Api_docs]
password =
password =

[VoyageAI]
api_key =
api_key =
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import requests

# 讀取主辦提供的 Question JSON 檔案
with open('data/questions_example.json', encoding='utf-8') as file:
with open('data/questions.json', encoding='utf-8') as file:
questions = json.load(file)['questions']

# 初始化輸出資料格式
Expand Down
2 changes: 1 addition & 1 deletion testing/get_best_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import requests

# Load questions from the JSON file
with open('data/questions_example.json', encoding='utf-8') as file:
with open('data/questions.json', encoding='utf-8') as file:
questions = json.load(file)['questions']

# Load ground truth data
Expand Down

0 comments on commit 2d282b5

Please sign in to comment.