Skip to content

Commit 08b3c4e

Browse files
feat: Persistent chat state (#181)
* add memory saver and update api contract * update new api contract in frontend and chat widget * add mongo memory saver * update read me
1 parent aa1746b commit 08b3c4e

File tree

17 files changed

+710
-280
lines changed

17 files changed

+710
-280
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,31 @@
33
[![Join the chat at https://gitter.im/ai-chatbot-framework/Lobby](https://badges.gitter.im/ai-chatbot-framework/Lobby.svg)](https://gitter.im/ai-chatbot-framework/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://github.com/alfredfrancis/ai-chatbot-framework/actions/workflows/evaluate-backend.yml/badge.svg)](https://github.com/alfredfrancis/ai-chatbot-framework/actions/workflows/evaluate-backend.yml) [![Build Status](https://github.com/alfredfrancis/ai-chatbot-framework/actions/workflows/evaluate-frontend.yml/badge.svg)](https://github.com/alfredfrancis/ai-chatbot-framework/actions/workflows/evaluate-frontend.yml)
44

55

6+
AI Chatbot Framework is an open-source, self-hosted, DIY Chatbot building platform built in Python. With this tool, it’s easy to create Natural Language conversational scenarios with no coding efforts whatsoever.
7+
The smooth UI makes it effortless to create and train conversations to the bot. AI Chatbot Framework can live on any channel of your choice (such as Messenger, Slack etc.) by integrating it’s API with that platform.
68

7-
### An AI Chatbot framework built in Python
9+
You don’t need to be an expert at artificial intelligence to create an awesome chatbot that has AI capabilities. With this project you can create an AI powered chatting machine in no time.
810

9-
AI Chatbot Framework is an AI powered conversational dialog interface built in Python. With this tool, it’s easy to create Natural Language conversational scenarios with no coding efforts whatsoever. The smooth UI makes it effortless to create and train conversations to the bot. AI Chatbot Framework can live on any channel of your choice (such as Messenger, Slack etc.) by integrating it’s API with that platform.
10-
11-
You don’t need to be an expert at artificial intelligence to create an awesome chatbot that has AI capabilities. With this boilerplate project you can create an AI powered chatting machine in no time. Since this is a hobby project, there could be numerous bugs, so contributions through pull requests are welcome!
1211

1312
![](docs/screenshots/admin_chat_screenshot.png)
1413

14+
## Features
15+
- Fully Self Hosted
16+
- Multi-turn Conversations
17+
- Advanced Natural Language Understanding (NLU)
18+
- Spacy Word Embeddings
19+
- Intent Recognition (ML)
20+
- Entity Extraction (ML)
21+
- One shot NLU using Large Language Models (Coming Soon)
22+
- Persistent Memory & Context Management
23+
- API request fulfilment
24+
- Channel Integrations
25+
- Web using rest api/chat snippet
26+
- Facebook Messenger (coming soon)
27+
- WhatsApp via Twilio (coming soon)
28+
- Slack (coming soon)
29+
- Low Code Admin Dashboard
30+
1531
## Index
1632

1733
* [Installation](#installation)

app/admin/test/__init__.py

Whitespace-only changes.

app/admin/test/routes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from fastapi import APIRouter, Depends
2+
from app.bot.dialogue_manager.models import UserMessage
3+
from app.dependencies import get_dialogue_manager
4+
from app.bot.dialogue_manager.dialogue_manager import DialogueManager
5+
6+
router = APIRouter(prefix="/test", tags=["test"])
7+
8+
9+
@router.post("/chat")
10+
async def chat(
11+
body: dict, dialogue_manager: DialogueManager = Depends(get_dialogue_manager)
12+
):
13+
"""
14+
Endpoint to converse with the chatbot.
15+
Delegates the request processing to DialogueManager.
16+
17+
:return: JSON response with the chatbot's reply and context.
18+
"""
19+
20+
user_message = UserMessage(
21+
thread_id=body["thread_id"], text=body["text"], context=body["context"]
22+
)
23+
new_state = await dialogue_manager.process(user_message)
24+
return new_state.to_dict()

app/bot/chat/routes.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
from fastapi import APIRouter, Request, Depends
2-
from app.bot.dialogue_manager.models import ChatModel
1+
from fastapi import APIRouter, Depends
2+
from app.bot.dialogue_manager.models import UserMessage
33
from app.dependencies import get_dialogue_manager
4+
from app.bot.dialogue_manager.dialogue_manager import DialogueManager
45

56
router = APIRouter(prefix="/v1", tags=["bots"])
67

78

89
@router.post("/chat")
910
async def chat(
10-
request: Request, body: dict, dialogue_manager=Depends(get_dialogue_manager)
11+
body: dict, dialogue_manager: DialogueManager = Depends(get_dialogue_manager)
1112
):
1213
"""
1314
Endpoint to converse with the chatbot.
@@ -16,7 +17,8 @@ async def chat(
1617
:return: JSON response with the chatbot's reply and context.
1718
"""
1819

19-
# Access the dialogue manager from the fast api application state.
20-
chat_request = ChatModel.from_json(body)
21-
chat_response = await dialogue_manager.process(chat_request)
22-
return chat_response.to_json()
20+
user_message = UserMessage(
21+
thread_id=body["thread_id"], text=body["text"], context=body["context"]
22+
)
23+
new_state = await dialogue_manager.process(user_message)
24+
return new_state.bot_message

0 commit comments

Comments
 (0)