Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
whimo committed Oct 14, 2024
1 parent e9596a4 commit e50aadf
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
22 changes: 22 additions & 0 deletions motleycrew/applications/customer_support/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Customer support agent demo

This is a demo of a customer support app built using motleycrew and Ray.

It includes sample data for populating the issue tree.


## Installation and usage
We suggest you set up a virtualenv for managing the environment.

```
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
```

Navigate to http://127.0.0.1:8000/ and have fun!
Also, check out the Ray dashboard for the app logs etc.
14 changes: 11 additions & 3 deletions motleycrew/applications/customer_support/issue_tree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import List, Optional
from dotenv import load_dotenv
import shutil
from pathlib import Path

import pandas
from langchain.prompts import ChatPromptTemplate
Expand Down Expand Up @@ -194,10 +197,14 @@ def categorize_issue(self, issue: Issue, insert_issue: bool = False):


def main():
# Initialize the graph store
graph_store = MotleyKuzuGraphStore.from_persist_dir("./issue_tree_db")
load_dotenv()

issues = pandas.read_csv("example_issues.csv")
# (Re-)initialize the graph store
db_path = Path(__file__).parent / "issue_tree_db"
shutil.rmtree(db_path, ignore_errors=True)
graph_store = MotleyKuzuGraphStore.from_persist_dir(db_path)

issues = pandas.read_csv(Path(__file__).parent / "example_issues.csv")

for _, row in issues.iterrows():
# Create IssueData node
Expand All @@ -220,6 +227,7 @@ def main():
resolution="Guided the customer through the password reset process. The issue was resolved after the customer set a new password.",
)

print(f"Example issue: {issue}")
leaf_node, issue_node = categorizer.categorize_issue(issue)
print(f"Issue categorized as: {leaf_node.name}")

Expand Down
2 changes: 1 addition & 1 deletion motleycrew/applications/customer_support/ray_serve_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def resolve_issue(self, resolution: str) -> str:
@serve.ingress(app)
class SupportAgentDeployment:
def __init__(self):
configure_logging(verbose=True, debug=True)
configure_logging(verbose=True)
load_dotenv()

database = MotleyKuzuGraphStore.from_persist_dir(
Expand Down
3 changes: 3 additions & 0 deletions motleycrew/applications/customer_support/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
motleycrew
ray[serve]
pandas
3 changes: 3 additions & 0 deletions motleycrew/applications/customer_support/support_agent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from dataclasses import dataclass, field
from dotenv import load_dotenv
from pathlib import Path
from typing import List, Optional, Sequence, Tuple

Expand Down Expand Up @@ -305,6 +306,8 @@ def agent_factory(tools: dict[str, MotleyTool]) -> AgentExecutor:


async def main():
load_dotenv()

graph_store = MotleyKuzuGraphStore.from_persist_dir(
str(Path(__file__).parent / "issue_tree_db")
)
Expand Down

0 comments on commit e50aadf

Please sign in to comment.