Skip to content

Commit

Permalink
Add Flow Architecture
Browse files Browse the repository at this point in the history
Signed-off-by: Di Wang <[email protected]>
  • Loading branch information
hemslo committed Feb 17, 2024
1 parent fad9672 commit 1a28250
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,28 @@ docker compose up --build
```shell
slack_socket_mode
```

## Flow Architecture

```mermaid
flowchart LR
A((Request)) --> B(Supervisor)
B --> C{Select Agent}
C --> D1[DatetimeProvider]
D1 --> B
C --> D2[GenericSearch]
D2 --> B
C --> D3[RandomNumber]
D3 --> B
C --> D4[RandomSelect]
D4 --> B
C --> D5[SlackSearcher]
D5 --> B
C --> D6[SlackToolkit]
D6 --> B
C --> D7[ThreadSummary]
D7 --> B
C --> D8[WebrcaCreate]
D8 --> B
C --> |FINISH| E((Response))
```
33 changes: 16 additions & 17 deletions app/graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import operator
from collections.abc import Mapping
from typing import Annotated, Sequence, TypedDict

from langchain.agents import create_openai_tools_agent, AgentExecutor
Expand All @@ -15,12 +14,12 @@
from app.chains.supervisor import build_supervisor_chain
from app.dependencies.openai_chat_model import openai_chat_model
from app.tools.datetime_provider import datetime_provider
from app.tools.duckduckgo_search import duckduckgo_search
from app.tools.random_number import random_number
from app.tools.random_select import random_select
from app.tools.slack_searcher import slack_searcher
from app.tools.slack_toolkit import slack_toolkit
from app.tools.webrca_create import webrca_create
from app.tools.duckduckgo_search import duckduckgo_search
from app.tools.slack_searcher import slack_searcher


# https://github.com/langchain-ai/langgraph/blob/main/examples/multi_agent/agent_supervisor.ipynb
Expand Down Expand Up @@ -54,6 +53,14 @@ class AgentState(TypedDict):
SUPERVISOR_NAME = "Supervisor"

GRAPH = {
"DatetimeProvider": {
"tools": [datetime_provider],
"system_prompt": "You are a datetime provider.",
},
"GenericSearch": {
"tools": [duckduckgo_search],
"system_prompt": "You are a search engine for generic questions.",
},
"RandomNumber": {
"tools": [random_number],
"system_prompt": "You are a random number generator.",
Expand All @@ -62,25 +69,17 @@ class AgentState(TypedDict):
"tools": [random_select],
"system_prompt": "You are a random selector.",
},
"WebrcaCreate": {
"tools": [webrca_create],
"system_prompt": "You are a webrca incident creator.",
},
"GenericSearch": {
"tools": [duckduckgo_search],
"system_prompt": "You are a search engine for generic questions.",
"SlackSearcher": {
"tools": [slack_searcher],
"system_prompt": "You are a slack searcher.",
},
"SlackToolkit": {
"tools": slack_toolkit.get_tools(),
"system_prompt": "You are a slack toolkit.",
},
"SlackSearcher": {
"tools": [slack_searcher],
"system_prompt": "You are a slack searcher.",
},
"DatetimeProvider": {
"tools": [datetime_provider],
"system_prompt": "You are a datetime provider.",
"WebrcaCreate": {
"tools": [webrca_create],
"system_prompt": "You are a webrca incident creator.",
},
}

Expand Down

0 comments on commit 1a28250

Please sign in to comment.