-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Updates per feedback, adds custom handler
- Loading branch information
1 parent
9bde3d6
commit b221758
Showing
10 changed files
with
88 additions
and
39 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
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
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,33 @@ | ||
import time | ||
from typing import List | ||
from uuid import uuid4 | ||
|
||
from jupyter_ai.models import AgentChatMessage, HumanChatMessage | ||
|
||
from .base import BaseChatHandler | ||
|
||
CUSTOM_MESSAGE = "This handler displays a custom message in response to any prompt." | ||
|
||
def CustomMessage(): | ||
return AgentChatMessage( | ||
id=uuid4().hex, | ||
time=time.time(), | ||
body=CUSTOM_MESSAGE, | ||
reply_to="", | ||
) | ||
|
||
""" | ||
This is a sample custom chat handler class to demonstrate entry points. | ||
""" | ||
class CustomChatHandler(BaseChatHandler): | ||
id = "custom" | ||
name = "Custom" | ||
help = "Displays a custom message in the chat message area" | ||
routing_method = "slash_command" | ||
slash_id = "custom" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
async def _process_message(self, message: HumanChatMessage): | ||
self.reply(CUSTOM_MESSAGE, message) |
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
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
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