Commit ·
9d540bc
1
Parent(s): 1d5f96c
Update chatbot
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .dockerignore +1 -1
- .gitignore +1 -1
- ARCHITECTURE_GUIDE.md +1 -1
- CHATBOT_20_ALGORITHM_VALIDATION.md +1 -1
- CHATBOT_MICROSERVICE_REFACTOR_AUDIT.md +1 -1
- CODE_EVALUATION_72_100.md +1 -1
- DELIVERABLES_CHECKLIST.md +1 -1
- DOCUMENTATION_INDEX.md +1 -1
- Dockerfile +1 -1
- EXECUTIVE_SUMMARY.md +1 -1
- EXTRACTION_PIPELINE_UPDATE.md +21 -0
- HUGGING_FACE_SPACE_TRAINING.md +1 -1
- MODEL_OPS_AND_APP_SPLIT.md +1 -1
- PRODUCTION_SETUP_GUIDE.md +1 -1
- README.md +1 -1
- README_v2.md +1 -1
- REBUILD_SUMMARY.md +1 -1
- REGENERATION_NOTES.md +1 -1
- START_HERE.md +1 -1
- VALIDATION_REPORT_100_100.md +1 -1
- __init__.py +0 -0
- admin_articles.html +17 -0
- apps/__init__.py +0 -1
- apps/chat/__init__.py +0 -1
- apps/chat/admin.py +1 -1
- apps/chat/apps.py +1 -1
- apps/chat/migrations/0001_initial.py +1 -1
- apps/chat/migrations/0002_predefinedresponse_runtime_fields.py +1 -1
- apps/chat/migrations/__init__.py +0 -1
- apps/chat/models.py +1 -1
- apps/chat/services/INTERNAL_ORCHESTRATION_README.md +1 -1
- apps/chat/services/RunData.py +1 -1
- apps/chat/services/RunMarkdowns.py +1 -1
- apps/chat/services/RunModel.py +1 -1
- apps/chat/services/__init__.py +0 -1
- apps/chat/services/ai_model.py +1 -1
- apps/chat/services/api_auth.py +1 -1
- apps/chat/services/backend_orchestration.py +1 -1
- apps/chat/services/bot.py +3 -3
- apps/chat/services/data_registry.py +1 -1
- apps/chat/services/helpers/ClassifierHelper.py +1 -1
- apps/chat/services/helpers/GetBestAnser.py +1 -1
- apps/chat/services/helpers/GetDataFromGoogle.py +1 -1
- apps/chat/services/helpers/GetPredefinedResponse.py +1 -1
- apps/chat/services/helpers/MarkdownDecisionEngine.py +1 -1
- apps/chat/services/helpers/TranslationHelper.py +1 -1
- apps/chat/services/helpers/__init__.py +0 -1
- apps/chat/services/helpers/intent_rules.py +1 -1
- apps/chat/services/helpers/predefined.py +1 -1
- apps/chat/services/helpers/qa_loader.py +1 -1
.dockerignore
CHANGED
|
@@ -13,4 +13,4 @@ logs/
|
|
| 13 |
db.sqlite3
|
| 14 |
artifacts/service_intent_model/checkpoint-*/
|
| 15 |
artifacts/service_intent_model_remote_cpu*/
|
| 16 |
-
artifacts/hf_base_models/
|
|
|
|
| 13 |
db.sqlite3
|
| 14 |
artifacts/service_intent_model/checkpoint-*/
|
| 15 |
artifacts/service_intent_model_remote_cpu*/
|
| 16 |
+
artifacts/hf_base_models/
|
.gitignore
CHANGED
|
@@ -14,4 +14,4 @@ all_chatbot_codes.txt
|
|
| 14 |
all_backend_codes.txt
|
| 15 |
chatbot.zip
|
| 16 |
src.zip
|
| 17 |
-
.pytest_cache/
|
|
|
|
| 14 |
all_backend_codes.txt
|
| 15 |
chatbot.zip
|
| 16 |
src.zip
|
| 17 |
+
.pytest_cache/
|
ARCHITECTURE_GUIDE.md
CHANGED
|
@@ -659,4 +659,4 @@ Required in production:
|
|
| 659 |
|
| 660 |
---
|
| 661 |
|
| 662 |
-
**Questions?** Check the logs! 🔍
|
|
|
|
| 659 |
|
| 660 |
---
|
| 661 |
|
| 662 |
+
**Questions?** Check the logs! 🔍
|
CHATBOT_20_ALGORITHM_VALIDATION.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
# Chatbot Microservice 20-Algorithm Validation
|
| 2 |
|
| 3 |
-
The microservice now performs decision routing, service detection/extraction, knowledge QA routing, and service-result finalization. n8n execution remains backend-only.
|
|
|
|
| 1 |
# Chatbot Microservice 20-Algorithm Validation
|
| 2 |
|
| 3 |
+
The microservice now performs decision routing, service detection/extraction, knowledge QA routing, and service-result finalization. n8n execution remains backend-only.
|
CHATBOT_MICROSERVICE_REFACTOR_AUDIT.md
CHANGED
|
@@ -3,4 +3,4 @@
|
|
| 3 |
- `/api/chat` returns `KNOWLEDGE_QA`, `SERVICE_REQUEST`, or `CLARIFICATION_REQUIRED`.
|
| 4 |
- n8n is no longer executed by the chatbot microservice.
|
| 5 |
- `/api/chat/finalize-service-response` formats backend execution results.
|
| 6 |
-
- `/api/knowledge` endpoints manage chatbot-owned `data.csv`.
|
|
|
|
| 3 |
- `/api/chat` returns `KNOWLEDGE_QA`, `SERVICE_REQUEST`, or `CLARIFICATION_REQUIRED`.
|
| 4 |
- n8n is no longer executed by the chatbot microservice.
|
| 5 |
- `/api/chat/finalize-service-response` formats backend execution results.
|
| 6 |
+
- `/api/knowledge` endpoints manage chatbot-owned `data.csv`.
|
CODE_EVALUATION_72_100.md
CHANGED
|
@@ -650,4 +650,4 @@ This document includes:
|
|
| 650 |
|
| 651 |
**Evaluation Completed:** May 8, 2026
|
| 652 |
**Evaluator:** Code Quality Analysis System
|
| 653 |
-
**Project:** Django ML Chatbot
|
|
|
|
| 650 |
|
| 651 |
**Evaluation Completed:** May 8, 2026
|
| 652 |
**Evaluator:** Code Quality Analysis System
|
| 653 |
+
**Project:** Django ML Chatbot
|
DELIVERABLES_CHECKLIST.md
CHANGED
|
@@ -394,4 +394,4 @@ gunicorn chatbot.wsgi --workers=4
|
|
| 394 |
**Tests:** Comprehensive
|
| 395 |
|
| 396 |
**Date:** May 8, 2026
|
| 397 |
-
**🚀 READY TO DEPLOY!**
|
|
|
|
| 394 |
**Tests:** Comprehensive
|
| 395 |
|
| 396 |
**Date:** May 8, 2026
|
| 397 |
+
**🚀 READY TO DEPLOY!**
|
DOCUMENTATION_INDEX.md
CHANGED
|
@@ -357,4 +357,4 @@ All documented in [ARCHITECTURE_GUIDE.md](./ARCHITECTURE_GUIDE.md)
|
|
| 357 |
|
| 358 |
**Start with [README_v2.md](./README_v2.md) 👉**
|
| 359 |
|
| 360 |
-
🚀 **Ready to deploy!**
|
|
|
|
| 357 |
|
| 358 |
**Start with [README_v2.md](./README_v2.md) 👉**
|
| 359 |
|
| 360 |
+
🚀 **Ready to deploy!**
|
Dockerfile
CHANGED
|
@@ -28,4 +28,4 @@ RUN chmod +x /app/docker-entrypoint.sh
|
|
| 28 |
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
-
CMD ["/app/docker-entrypoint.sh"]
|
|
|
|
| 28 |
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
+
CMD ["/app/docker-entrypoint.sh"]
|
EXECUTIVE_SUMMARY.md
CHANGED
|
@@ -373,4 +373,4 @@ The chatbot is **fully rebuilt, thoroughly tested, extensively documented, and p
|
|
| 373 |
**Quality:** Production-Grade
|
| 374 |
**Date:** May 8, 2026
|
| 375 |
|
| 376 |
-
🚀 **Ready to deploy!**
|
|
|
|
| 373 |
**Quality:** Production-Grade
|
| 374 |
**Date:** May 8, 2026
|
| 375 |
|
| 376 |
+
🚀 **Ready to deploy!**
|
EXTRACTION_PIPELINE_UPDATE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Extraction-only service orchestration update
|
| 2 |
+
|
| 3 |
+
Applied logic:
|
| 4 |
+
|
| 5 |
+
1. `service_intents.csv` is the service router dataset. It decides the requested `service_id`/`intent`.
|
| 6 |
+
2. `service_intents_model_training.csv` is now **slot-extraction only**.
|
| 7 |
+
- removed all `no_service` / generated-negative rows
|
| 8 |
+
- removed rows that do not teach additional data extraction
|
| 9 |
+
- ignored context-only default `subject_scope=self`
|
| 10 |
+
- cleaned duplicated fields inside `missing_fields_json`
|
| 11 |
+
3. `service_extraction_manifest.json` is the runtime allow-list for the extractor.
|
| 12 |
+
4. If no service is detected, the chatbot falls back to the QA index through `QA_CSV`, defaulting to `apps/chat/training_models/data/chatbot.csv`.
|
| 13 |
+
5. If a service is detected but it is not in the manifest, the system skips the ML extractor and continues with context/rule parameters.
|
| 14 |
+
|
| 15 |
+
Summary:
|
| 16 |
+
|
| 17 |
+
- Router rows: 17459
|
| 18 |
+
- Original mixed training rows: 19259
|
| 19 |
+
- Clean extractor rows: 4924
|
| 20 |
+
- Services allowed to use extractor: 132
|
| 21 |
+
- Services that skip extractor: 2
|
HUGGING_FACE_SPACE_TRAINING.md
CHANGED
|
@@ -81,4 +81,4 @@ For free CPU Spaces, start with a smaller model:
|
|
| 81 |
python manage.py submit_remote_service_intent_training --model-id google/flan-t5-small --rebuild-datasets --wait
|
| 82 |
```
|
| 83 |
|
| 84 |
-
Use `google/flan-t5-base` when the Space has enough CPU/GPU memory and time.
|
|
|
|
| 81 |
python manage.py submit_remote_service_intent_training --model-id google/flan-t5-small --rebuild-datasets --wait
|
| 82 |
```
|
| 83 |
|
| 84 |
+
Use `google/flan-t5-base` when the Space has enough CPU/GPU memory and time.
|
MODEL_OPS_AND_APP_SPLIT.md
CHANGED
|
@@ -57,4 +57,4 @@ python manage.py prepare_service_intent_model --dry-run --skip-install
|
|
| 57 |
|
| 58 |
## internal orchestration
|
| 59 |
|
| 60 |
-
internal orchestration remains an external microservice. Django still talks to it through the existing service executor.
|
|
|
|
| 57 |
|
| 58 |
## internal orchestration
|
| 59 |
|
| 60 |
+
internal orchestration remains an external microservice. Django still talks to it through the existing service executor.
|
PRODUCTION_SETUP_GUIDE.md
CHANGED
|
@@ -549,4 +549,4 @@ For issues:
|
|
| 549 |
4. Run tests: `pytest -v`
|
| 550 |
5. Enable debug: `DJANGO_DEBUG=1`
|
| 551 |
|
| 552 |
-
**Happy deploying!** 🚀
|
|
|
|
| 549 |
4. Run tests: `pytest -v`
|
| 550 |
5. Enable debug: `DJANGO_DEBUG=1`
|
| 551 |
|
| 552 |
+
**Happy deploying!** 🚀
|
README.md
CHANGED
|
@@ -101,4 +101,4 @@ If replacing the whole Space repository:
|
|
| 101 |
|
| 102 |
```bash
|
| 103 |
git push --force space main
|
| 104 |
-
```
|
|
|
|
| 101 |
|
| 102 |
```bash
|
| 103 |
git push --force space main
|
| 104 |
+
```
|
README_v2.md
CHANGED
|
@@ -454,4 +454,4 @@ Start with:
|
|
| 454 |
|
| 455 |
---
|
| 456 |
|
| 457 |
-
**Score: 100/100 ✅ | Production Ready 🚀 | Well Tested ✓ | Fully Documented 📚**
|
|
|
|
| 454 |
|
| 455 |
---
|
| 456 |
|
| 457 |
+
**Score: 100/100 ✅ | Production Ready 🚀 | Well Tested ✓ | Fully Documented 📚**
|
REBUILD_SUMMARY.md
CHANGED
|
@@ -439,4 +439,4 @@ The chatbot has been completely rebuilt from a v1.0 codebase (72/100) to a produ
|
|
| 439 |
|
| 440 |
---
|
| 441 |
|
| 442 |
-
**Ready to deploy?** Start with `PRODUCTION_SETUP_GUIDE.md` ✨
|
|
|
|
| 439 |
|
| 440 |
---
|
| 441 |
|
| 442 |
+
**Ready to deploy?** Start with `PRODUCTION_SETUP_GUIDE.md` ✨
|
REGENERATION_NOTES.md
CHANGED
|
@@ -11,4 +11,4 @@ Fixes applied:
|
|
| 11 |
- Added dataset placeholder instructions because CSV files were not present in the uploaded combined file.
|
| 12 |
- Excluded runtime/generated files: caches, logs, SQLite DB, virtual environments, artifacts, binary model files.
|
| 13 |
|
| 14 |
-
Before deployment, restore the required CSV files under `apps/chat/training_models/data/`.
|
|
|
|
| 11 |
- Added dataset placeholder instructions because CSV files were not present in the uploaded combined file.
|
| 12 |
- Excluded runtime/generated files: caches, logs, SQLite DB, virtual environments, artifacts, binary model files.
|
| 13 |
|
| 14 |
+
Before deployment, restore the required CSV files under `apps/chat/training_models/data/`.
|
START_HERE.md
CHANGED
|
@@ -467,4 +467,4 @@ QUALITY ASSURANCE
|
|
| 467 |
**Total Effort:** Complete rewrite from v1.0 to v2.0
|
| 468 |
**Result:** Enterprise-grade production-ready chatbot
|
| 469 |
|
| 470 |
-
👉 **[START WITH DOCUMENTATION_INDEX.md](./DOCUMENTATION_INDEX.md)** 👈
|
|
|
|
| 467 |
**Total Effort:** Complete rewrite from v1.0 to v2.0
|
| 468 |
**Result:** Enterprise-grade production-ready chatbot
|
| 469 |
|
| 470 |
+
👉 **[START WITH DOCUMENTATION_INDEX.md](./DOCUMENTATION_INDEX.md)** 👈
|
VALIDATION_REPORT_100_100.md
CHANGED
|
@@ -528,4 +528,4 @@ The chatbot has been successfully rebuilt from v1.0 (72/100) to v2.0 (100/100) w
|
|
| 528 |
**Tests:** Passing
|
| 529 |
**Documentation:** Complete
|
| 530 |
|
| 531 |
-
**Date Completed:** May 8, 2026
|
|
|
|
| 528 |
**Tests:** Passing
|
| 529 |
**Documentation:** Complete
|
| 530 |
|
| 531 |
+
**Date Completed:** May 8, 2026
|
__init__.py
ADDED
|
File without changes
|
admin_articles.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html><body>
|
| 3 |
+
<h1>Admin Articles</h1>
|
| 4 |
+
<form method="POST">{% csrf_token %}
|
| 5 |
+
<input name="title" placeholder="Title"><br><br>
|
| 6 |
+
<textarea name="content" style="width:100%;height:160px" placeholder="Content"></textarea><br><br>
|
| 7 |
+
<button type="submit">Save</button>
|
| 8 |
+
</form>
|
| 9 |
+
<hr>
|
| 10 |
+
<ul>
|
| 11 |
+
{% for article in articles %}
|
| 12 |
+
<li><b>{{ article.title }}</b> - {{ article.content|slice:':100' }}...</li>
|
| 13 |
+
{% empty %}
|
| 14 |
+
<li>No articles yet.</li>
|
| 15 |
+
{% endfor %}
|
| 16 |
+
</ul>
|
| 17 |
+
</body></html>
|
apps/__init__.py
CHANGED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
apps/chat/__init__.py
CHANGED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
apps/chat/admin.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
from django.contrib import admin
|
| 2 |
from .models import PredefinedResponse
|
| 3 |
|
| 4 |
-
admin.site.register(PredefinedResponse)
|
|
|
|
| 1 |
from django.contrib import admin
|
| 2 |
from .models import PredefinedResponse
|
| 3 |
|
| 4 |
+
admin.site.register(PredefinedResponse)
|
apps/chat/apps.py
CHANGED
|
@@ -4,4 +4,4 @@ from django.apps import AppConfig
|
|
| 4 |
class ChatConfig(AppConfig):
|
| 5 |
default_auto_field = 'django.db.models.BigAutoField'
|
| 6 |
name = 'apps.chat'
|
| 7 |
-
label = 'chat'
|
|
|
|
| 4 |
class ChatConfig(AppConfig):
|
| 5 |
default_auto_field = 'django.db.models.BigAutoField'
|
| 6 |
name = 'apps.chat'
|
| 7 |
+
label = 'chat'
|
apps/chat/migrations/0001_initial.py
CHANGED
|
@@ -13,4 +13,4 @@ class Migration(migrations.Migration):
|
|
| 13 |
('response_text', models.TextField()),
|
| 14 |
],
|
| 15 |
),
|
| 16 |
-
]
|
|
|
|
| 13 |
('response_text', models.TextField()),
|
| 14 |
],
|
| 15 |
),
|
| 16 |
+
]
|
apps/chat/migrations/0002_predefinedresponse_runtime_fields.py
CHANGED
|
@@ -120,4 +120,4 @@ class Migration(migrations.Migration):
|
|
| 120 |
],
|
| 121 |
},
|
| 122 |
),
|
| 123 |
-
]
|
|
|
|
| 120 |
],
|
| 121 |
},
|
| 122 |
),
|
| 123 |
+
]
|
apps/chat/migrations/__init__.py
CHANGED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
apps/chat/models.py
CHANGED
|
@@ -153,4 +153,4 @@ class ApiKey(models.Model):
|
|
| 153 |
def update_last_used(self):
|
| 154 |
"""Update last_used_at timestamp."""
|
| 155 |
self.last_used_at = timezone.now()
|
| 156 |
-
self.save(update_fields=['last_used_at'])
|
|
|
|
| 153 |
def update_last_used(self):
|
| 154 |
"""Update last_used_at timestamp."""
|
| 155 |
self.last_used_at = timezone.now()
|
| 156 |
+
self.save(update_fields=['last_used_at'])
|
apps/chat/services/INTERNAL_ORCHESTRATION_README.md
CHANGED
|
@@ -345,4 +345,4 @@ grep "Service.*executed" logs/chatbot.log
|
|
| 345 |
- **Chatbot Core**: `apps/chat/services/bot.py`
|
| 346 |
- **internal orchestration Executor**: `apps/chat/services/internal orchestration_service_executor.py`
|
| 347 |
- **Service Registry**: `../../internal-service-orchestration/service-registry/services.json`
|
| 348 |
-
- **Test Suite**: `apps/chat/tests/test_service_detection.py`
|
|
|
|
| 345 |
- **Chatbot Core**: `apps/chat/services/bot.py`
|
| 346 |
- **internal orchestration Executor**: `apps/chat/services/internal orchestration_service_executor.py`
|
| 347 |
- **Service Registry**: `../../internal-service-orchestration/service-registry/services.json`
|
| 348 |
+
- **Test Suite**: `apps/chat/tests/test_service_detection.py`
|
apps/chat/services/RunData.py
CHANGED
|
@@ -30,4 +30,4 @@ class RunData:
|
|
| 30 |
|
| 31 |
exact = {q.lower().strip().rstrip('?!'): a for q, a in zip(qa_q, qa_a)}
|
| 32 |
|
| 33 |
-
DataRegistry.register_components(qa_q=qa_q, qa_a=qa_a, exact=exact)
|
|
|
|
| 30 |
|
| 31 |
exact = {q.lower().strip().rstrip('?!'): a for q, a in zip(qa_q, qa_a)}
|
| 32 |
|
| 33 |
+
DataRegistry.register_components(qa_q=qa_q, qa_a=qa_a, exact=exact)
|
apps/chat/services/RunMarkdowns.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
class RunMarkdowns:
|
| 2 |
def __init__(self):
|
| 3 |
# Placeholder (your previous markdown registry was heavy).
|
| 4 |
-
pass
|
|
|
|
| 1 |
class RunMarkdowns:
|
| 2 |
def __init__(self):
|
| 3 |
# Placeholder (your previous markdown registry was heavy).
|
| 4 |
+
pass
|
apps/chat/services/RunModel.py
CHANGED
|
@@ -35,4 +35,4 @@ class RunModel:
|
|
| 35 |
except Exception as exc:
|
| 36 |
logger.warning("Unable to load language identification model: %s", exc)
|
| 37 |
lid=None
|
| 38 |
-
ModelRegistry.register_components(lid_176_ftz=lid, tokenizer=None, falcon_model=None)
|
|
|
|
| 35 |
except Exception as exc:
|
| 36 |
logger.warning("Unable to load language identification model: %s", exc)
|
| 37 |
lid=None
|
| 38 |
+
ModelRegistry.register_components(lid_176_ftz=lid, tokenizer=None, falcon_model=None)
|
apps/chat/services/__init__.py
CHANGED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
apps/chat/services/ai_model.py
CHANGED
|
@@ -42,4 +42,4 @@ class Chatbot:
|
|
| 42 |
if score >= SIMILARITY_THRESHOLD:
|
| 43 |
return self.trans_helper.translate(self.markdown.format_text(ans), target_lang=user_lang, source_lang='en')
|
| 44 |
|
| 45 |
-
return self.trans_helper.translate('No confident answer found.', target_lang=user_lang, source_lang='en')
|
|
|
|
| 42 |
if score >= SIMILARITY_THRESHOLD:
|
| 43 |
return self.trans_helper.translate(self.markdown.format_text(ans), target_lang=user_lang, source_lang='en')
|
| 44 |
|
| 45 |
+
return self.trans_helper.translate('No confident answer found.', target_lang=user_lang, source_lang='en')
|
apps/chat/services/api_auth.py
CHANGED
|
@@ -41,4 +41,4 @@ def require_api_key(request) -> None:
|
|
| 41 |
logger.warning(f"API request with invalid key from {request.META.get('REMOTE_ADDR')}")
|
| 42 |
raise ApiAuthError('Invalid API key')
|
| 43 |
|
| 44 |
-
logger.debug("API authentication successful")
|
|
|
|
| 41 |
logger.warning(f"API request with invalid key from {request.META.get('REMOTE_ADDR')}")
|
| 42 |
raise ApiAuthError('Invalid API key')
|
| 43 |
|
| 44 |
+
logger.debug("API authentication successful")
|
apps/chat/services/backend_orchestration.py
CHANGED
|
@@ -139,4 +139,4 @@ def finalize_service_response(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
| 139 |
message = result.get("safe_summary") or "I need your confirmation before completing this action."
|
| 140 |
else:
|
| 141 |
message = result.get("safe_summary") or result.get("error") or f"I could not complete the {service_id.replace('_', ' ')} service."
|
| 142 |
-
return {"type": "SERVICE_FINAL_RESPONSE", "message": str(message), "response": str(message), "service_id": service_id, "status": status}
|
|
|
|
| 139 |
message = result.get("safe_summary") or "I need your confirmation before completing this action."
|
| 140 |
else:
|
| 141 |
message = result.get("safe_summary") or result.get("error") or f"I could not complete the {service_id.replace('_', ' ')} service."
|
| 142 |
+
return {"type": "SERVICE_FINAL_RESPONSE", "message": str(message), "response": str(message), "service_id": service_id, "status": status}
|
apps/chat/services/bot.py
CHANGED
|
@@ -47,8 +47,8 @@ class Chatbot:
|
|
| 47 |
Uses multi-tier strategy:
|
| 48 |
1. Detect intent (greeting, goodbye, etc.)
|
| 49 |
2. Check predefined responses
|
| 50 |
-
3. Detect service requests
|
| 51 |
-
4.
|
| 52 |
5. Return fallback message
|
| 53 |
|
| 54 |
Args:
|
|
@@ -270,4 +270,4 @@ class Chatbot:
|
|
| 270 |
connectors = (' and ', ' also ', ' plus ', ' then ', ';')
|
| 271 |
if any(connector in text for connector in connectors):
|
| 272 |
return True
|
| 273 |
-
return text.count('?') > 1
|
|
|
|
| 47 |
Uses multi-tier strategy:
|
| 48 |
1. Detect intent (greeting, goodbye, etc.)
|
| 49 |
2. Check predefined responses
|
| 50 |
+
3. Detect service requests with the router. If found, orchestrate/execute service.
|
| 51 |
+
4. If no service is detected, pass the message to chatbot.csv/data QA index
|
| 52 |
5. Return fallback message
|
| 53 |
|
| 54 |
Args:
|
|
|
|
| 270 |
connectors = (' and ', ' also ', ' plus ', ' then ', ';')
|
| 271 |
if any(connector in text for connector in connectors):
|
| 272 |
return True
|
| 273 |
+
return text.count('?') > 1
|
apps/chat/services/data_registry.py
CHANGED
|
@@ -7,4 +7,4 @@ class DataRegistry:
|
|
| 7 |
|
| 8 |
@classmethod
|
| 9 |
def get(cls, key, default=None):
|
| 10 |
-
return cls._registry.get(key, default)
|
|
|
|
| 7 |
|
| 8 |
@classmethod
|
| 9 |
def get(cls, key, default=None):
|
| 10 |
+
return cls._registry.get(key, default)
|
apps/chat/services/helpers/ClassifierHelper.py
CHANGED
|
@@ -7,4 +7,4 @@ class ClassifierHelper:
|
|
| 7 |
for intent, pat in RULES:
|
| 8 |
if pat.search(txt):
|
| 9 |
return intent, []
|
| 10 |
-
return 'unknown', []
|
|
|
|
| 7 |
for intent, pat in RULES:
|
| 8 |
if pat.search(txt):
|
| 9 |
return intent, []
|
| 10 |
+
return 'unknown', []
|
apps/chat/services/helpers/GetBestAnser.py
CHANGED
|
@@ -19,4 +19,4 @@ class QARetriever:
|
|
| 19 |
if m:
|
| 20 |
best_key, score, _ = m
|
| 21 |
return [(self.exact[best_key], float(score)/100.0)]
|
| 22 |
-
return []
|
|
|
|
| 19 |
if m:
|
| 20 |
best_key, score, _ = m
|
| 21 |
return [(self.exact[best_key], float(score)/100.0)]
|
| 22 |
+
return []
|
apps/chat/services/helpers/GetDataFromGoogle.py
CHANGED
|
@@ -3,4 +3,4 @@ class SiteIndexer:
|
|
| 3 |
self.query_text=query_text
|
| 4 |
def index_with_progress(self):
|
| 5 |
yield "FOUND:0"
|
| 6 |
-
yield "RESULT:NO_RESULT"
|
|
|
|
| 3 |
self.query_text=query_text
|
| 4 |
def index_with_progress(self):
|
| 5 |
yield "FOUND:0"
|
| 6 |
+
yield "RESULT:NO_RESULT"
|
apps/chat/services/helpers/GetPredefinedResponse.py
CHANGED
|
@@ -7,4 +7,4 @@ class ResponseHelper:
|
|
| 7 |
try:
|
| 8 |
return PredefinedResponse.objects.get(intent=intent).response_text
|
| 9 |
except PredefinedResponse.DoesNotExist:
|
| 10 |
-
return None
|
|
|
|
| 7 |
try:
|
| 8 |
return PredefinedResponse.objects.get(intent=intent).response_text
|
| 9 |
except PredefinedResponse.DoesNotExist:
|
| 10 |
+
return None
|
apps/chat/services/helpers/MarkdownDecisionEngine.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
class MarkdownDecisionEngine:
|
| 2 |
def format_text(self, text: str) -> str:
|
| 3 |
-
return text
|
|
|
|
| 1 |
class MarkdownDecisionEngine:
|
| 2 |
def format_text(self, text: str) -> str:
|
| 3 |
+
return text
|
apps/chat/services/helpers/TranslationHelper.py
CHANGED
|
@@ -5,4 +5,4 @@ class TranslationHelper:
|
|
| 5 |
return get_language_processor().detect_language(text)
|
| 6 |
|
| 7 |
def translate(self, text: str, target_lang: str, source_lang: str='auto') -> str:
|
| 8 |
-
return get_language_processor().translate(text, target_lang=target_lang, source_lang=source_lang)
|
|
|
|
| 5 |
return get_language_processor().detect_language(text)
|
| 6 |
|
| 7 |
def translate(self, text: str, target_lang: str, source_lang: str='auto') -> str:
|
| 8 |
+
return get_language_processor().translate(text, target_lang=target_lang, source_lang=source_lang)
|
apps/chat/services/helpers/__init__.py
CHANGED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
apps/chat/services/helpers/intent_rules.py
CHANGED
|
@@ -6,4 +6,4 @@ RULES = [
|
|
| 6 |
('ask_hours', re.compile(r"\b(hours|opening|open|close|time|schedule)\b", re.I)),
|
| 7 |
('ask_contact', re.compile(r"\b(contact|email|phone|tel|number)\b", re.I)),
|
| 8 |
('ask_location', re.compile(r"\b(where|location|address|map)\b", re.I)),
|
| 9 |
-
]
|
|
|
|
| 6 |
('ask_hours', re.compile(r"\b(hours|opening|open|close|time|schedule)\b", re.I)),
|
| 7 |
('ask_contact', re.compile(r"\b(contact|email|phone|tel|number)\b", re.I)),
|
| 8 |
('ask_location', re.compile(r"\b(where|location|address|map)\b", re.I)),
|
| 9 |
+
]
|
apps/chat/services/helpers/predefined.py
CHANGED
|
@@ -6,4 +6,4 @@ def get_predefined(intent: str):
|
|
| 6 |
try:
|
| 7 |
return PredefinedResponse.objects.get(intent=intent).response_text
|
| 8 |
except PredefinedResponse.DoesNotExist:
|
| 9 |
-
return None
|
|
|
|
| 6 |
try:
|
| 7 |
return PredefinedResponse.objects.get(intent=intent).response_text
|
| 8 |
except PredefinedResponse.DoesNotExist:
|
| 9 |
+
return None
|
apps/chat/services/helpers/qa_loader.py
CHANGED
|
@@ -18,4 +18,4 @@ class QALoader:
|
|
| 18 |
questions = df['Question'].tolist()
|
| 19 |
answers = df['Answer'].tolist()
|
| 20 |
exact = {q.lower().strip().rstrip('?!'): a for q, a in zip(questions, answers)}
|
| 21 |
-
return questions, answers, exact
|
|
|
|
| 18 |
questions = df['Question'].tolist()
|
| 19 |
answers = df['Answer'].tolist()
|
| 20 |
exact = {q.lower().strip().rstrip('?!'): a for q, a in zip(questions, answers)}
|
| 21 |
+
return questions, answers, exact
|