-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
002c3fe
commit f0812f3
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from funcchain.components import ChatRouter | ||
|
||
|
||
def handle_pdf_requests(user_query: str) -> str: | ||
return f"Handling PDF requests with user query: {user_query}" | ||
|
||
|
||
def handle_csv_requests(user_query: str) -> str: | ||
return f"Handling CSV requests with user query: {user_query}" | ||
|
||
|
||
def handle_default_requests(user_query: str) -> str: | ||
return f"Handling DEFAULT requests with user query: {user_query}" | ||
|
||
|
||
router = ChatRouter( | ||
routes={ | ||
"pdf": { | ||
"handler": handle_pdf_requests, | ||
"description": "Call this for requests including PDF Files.", | ||
}, | ||
"csv": { | ||
"handler": handle_csv_requests, | ||
"description": "Call this for requests including CSV Files.", | ||
}, | ||
"default": handle_default_requests, | ||
}, | ||
) | ||
|
||
|
||
def test_router() -> None: | ||
assert "Handling CSV" in router.invoke_route("Can you summarize this csv?") | ||
|
||
assert "Handling PDF" in router.invoke_route("Can you summarize this pdf?") | ||
|
||
assert "Handling DEFAULT" in router.invoke_route("Hey, whatsup?") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_router() |