AOSSIE-Org / AOSSIE-Org/Agora-Blockchain

BUG: FileNotFoundError in chatbot/app.py when launched outside chatbot/ directory

オープン
#258 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
97
フォーク
199
PR マージ指標
30日以内にマージされた PR はありません

説明

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Issue Description ✍️

## 🚀 Describe the Bug
In `chatbot/app.py`, model data and intents are loaded using relative file paths (`open('intents.json')` and `FILE = "data.pth"`). When the Flask app is launched from outside the `chatbot/` directory (e.g. from the project root), Python cannot resolve these paths and throws a `FileNotFoundError`.

## 🎉 Actual Behavior
Running `python chatbot/app.py` from the project root throws:
`FileNotFoundError: [Errno 2] No such file or directory: 'intents.json'`

## 🎯 Expected Behavior
The app should load `intents.json` and `data.pth` correctly regardless of the working directory it is launched from.

## 🖥️ Screenshot
N/A

## 💡 Suggestions
Construct absolute paths using `__file__`:
```python
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
intents_path = os.path.join(BASE_DIR, 'intents.json')
FILE = os.path.join(BASE_DIR, 'data.pth')
```

### Record

- [x] I have synced all my node versions as mentioned in the project
- [x] I am using the same version of npm as is the project
- [x] My current branch is in sync with the development branch
- [x] I want to work on this issue

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。