Skip to content

Commit

Permalink
Customer support app & event driven workflows docs (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
whimo authored Oct 16, 2024
1 parent 2efb773 commit 0514679
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 556 deletions.
1 change: 1 addition & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Examples
examples/research_agent
examples/validating_agent_output
examples/advanced_output_handling
examples/customer_support
examples/streaming_agent_output
examples/event_driven
autogen
73 changes: 73 additions & 0 deletions docs/source/examples/customer_support.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Customer support chatbot with Ray Serve
=======================================

This example demonstrates how to build a customer support chatbot using MotleyCrew and Ray Serve.
The chatbot is designed to answer customer queries based on a database of past issues and their resolutions.

The code for this example can be found `here <https://github.com/ShoggothAI/motleycrew/tree/main/motleycrew/applications/customer_support>`_.
Also, see the `blog post <https://blog.motleycrew.ai/blog/building-a-customer-support-chatbot-using-motleycrew-and-ray>`_ about this app.

Key Components
--------------

1. Issue Database

- Stores information about past issues and their solutions in a tree structure
- Intermediate nodes represent issue categories
- Leaf nodes represent individual issues
- Uses Kuzu to store and query the issue tree through our OGM (see :doc:`../knowledge_graph` for more details)

2. AI Support Agent

- Attempts to resolve customer issues based on past solutions
- Navigates the issue tree to find relevant information
- Can ask clarifying questions to the customer
- Proposes solutions or escalates to a human agent if necessary

3. Agent Tools

- IssueTreeViewTool: Allows the agent to navigate the issue tree
- CustomerChatTool: Enables the agent to ask additional questions to the customer
- ResolveIssueTool: Used to submit a solution or escalate to a human agent

4. Ray Serve Deployment

- Exposes the chatbot as an API
- Allows multiple customers to connect simultaneously
- Uses WebSockets over FastAPI for communication

Implementation Details
----------------------

The support agent is implemented using the "every response is a tool call" design.
The agent loop can only end with a ResolveIssueTool call or when a constraint (e.g., number of iterations) is reached.
This is achieved by making the ResolveIssueTool an output handler.

The Ray Serve deployment is configured using a simple decorator:

.. code-block:: python
@serve.deployment(num_replicas=3, ray_actor_options={"num_cpus": 1, "num_gpus": 0})
class SupportAgentDeployment:
...
This setup allows for easy scaling and supports multiple simultaneous sessions balanced between replicas.

Running the Example
-------------------

The project includes sample issue data that can be used to populate the issue tree.

To run this example:

.. code-block:: bash
git clone https://github.com/ShoggothAI/motleycrew.git
cd motleycrew
pip install -r requirements.txt
python -m motleycrew.applications.customer_support.issue_tree # populate the issue tree
ray start --head
python -m motleycrew.applications.customer_support.ray_serve_app
This example showcases the flexibility of MotleyCrew for building agent-based applications, allowing you to choose your preferred agent framework, orchestration model, and deployment solution.
3 changes: 3 additions & 0 deletions docs/source/examples/event_driven.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../examples/Event-driven orchestration for AI systems.ipynb"
}
94 changes: 0 additions & 94 deletions examples/old/delegation_crewai.py

This file was deleted.

62 changes: 0 additions & 62 deletions examples/old/image_generation_crewai.py

This file was deleted.

60 changes: 0 additions & 60 deletions examples/old/math_crewai.py

This file was deleted.

65 changes: 0 additions & 65 deletions examples/old/research_agent.py

This file was deleted.

Loading

0 comments on commit 0514679

Please sign in to comment.