-
Notifications
You must be signed in to change notification settings - Fork 183
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
Showing
10 changed files
with
92 additions
and
49 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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Optional | ||
|
||
from attrs import define, field | ||
|
||
from griptape.events.base_chunk_event import BaseChunkEvent | ||
|
||
if TYPE_CHECKING: | ||
from griptape.common import BaseDeltaMessageContent | ||
|
||
|
||
@define | ||
class ActionChunkEvent(BaseChunkEvent): | ||
tag: Optional[str] = field(default=None, kw_only=True, metadata={"serializable": True}) | ||
name: Optional[str] = field(default=None, kw_only=True, metadata={"serializable": True}) | ||
path: Optional[str] = field(default=None, kw_only=True, metadata={"serializable": True}) | ||
|
||
@classmethod | ||
def from_delta_message_content(cls, content: BaseDeltaMessageContent) -> ActionChunkEvent: | ||
from griptape.common import ActionCallDeltaMessageContent | ||
|
||
if isinstance(content, ActionCallDeltaMessageContent): | ||
return cls( | ||
token=content.partial_input if content.partial_input is not None else "", | ||
index=content.index, | ||
tag=content.tag, | ||
name=content.name, | ||
path=content.path, | ||
) | ||
|
||
raise ValueError(f"Content is not an instance of ActionCallDeltaMessageContent: {content.__class__.__name__}") |
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,19 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from attrs import define, field | ||
|
||
from griptape.events.base_event import BaseEvent | ||
|
||
if TYPE_CHECKING: | ||
from griptape.common import BaseDeltaMessageContent | ||
|
||
|
||
@define | ||
class BaseChunkEvent(BaseEvent): | ||
token: str = field(metadata={"serializable": True}) | ||
index: int = field(default=0, metadata={"serializable": True}) | ||
|
||
@classmethod | ||
def from_delta_message_content(cls, content: BaseDeltaMessageContent) -> BaseChunkEvent: ... |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from attrs import define, field | ||
|
||
from griptape.events.base_chunk_event import BaseChunkEvent | ||
|
||
if TYPE_CHECKING: | ||
from griptape.common import BaseDeltaMessageContent | ||
|
||
|
||
@define | ||
class TextChunkEvent(BaseChunkEvent): | ||
token: str = field(metadata={"serializable": True}) | ||
|
||
@classmethod | ||
def from_delta_message_content(cls, content: BaseDeltaMessageContent) -> TextChunkEvent: | ||
from griptape.common import TextDeltaMessageContent | ||
|
||
if isinstance(content, TextDeltaMessageContent): | ||
return cls(token=content.text, index=content.index) | ||
|
||
raise ValueError(f"Content is not an instance of TextDeltaMessageContent: {content.__class__.__name__}") |
This file was deleted.
Oops, something went wrong.
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