Add text episode type (#46)

Add a new `text` episode type and update the `extract_nodes` function to handle it.

* **EpisodeType Enum:**
  - Add `text` to the `EpisodeType` enum in `graphiti_core/nodes.py`.
  - Update the `from_str` method to handle the `text` episode type.

* **extract_nodes Function:**
  - Update the `extract_nodes` function in `graphiti_core/utils/maintenance/node_operations.py` to handle the `text` episode type.
  - Use the `message` type prompt for both `message` and `text` episodes.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/getzep/graphiti?shareId=XXXX-XXXX-XXXX-XXXX).
This commit is contained in:
Daniel Chalef
2024-08-26 15:51:13 -07:00
committed by GitHub
parent 2d01e5d7b7
commit a6d63f0c0d
2 changed files with 6 additions and 1 deletions

View File

@@ -46,10 +46,13 @@ class EpisodeType(Enum):
or "assistant: I'm doing well, thank you for asking."
json : str
Represents an episode containing a JSON string object with structured data.
text : str
Represents a plain text episode.
"""
message = 'message'
json = 'json'
text = 'text'
@staticmethod
def from_str(episode_type: str):
@@ -57,6 +60,8 @@ class EpisodeType(Enum):
return EpisodeType.message
if episode_type == 'json':
return EpisodeType.json
if episode_type == 'text':
return EpisodeType.text
logger.error(f'Episode type: {episode_type} not implemented')
raise NotImplementedError

View File

@@ -72,7 +72,7 @@ async def extract_nodes(
) -> list[EntityNode]:
start = time()
extracted_node_data: list[dict[str, Any]] = []
if episode.source == EpisodeType.message:
if episode.source in [EpisodeType.message, EpisodeType.text]:
extracted_node_data = await extract_message_nodes(llm_client, episode, previous_episodes)
elif episode.source == EpisodeType.json:
extracted_node_data = await extract_json_nodes(llm_client, episode)