mirror of
https://github.com/getzep/graphiti.git
synced 2026-01-31 04:21:33 +00:00
* chore: Add romeo runner * fix: Linter * dedupe fixes * wip * wip dump * allbirds * chore: Update romeo parser * chore: Anthropic model fix * allbirds runner * format * wip * mypy updates * update * remove r * update tests * format * wip * wip * wip * chore: Strategically update the message * chore: Add romeo runner * fix: Linter * wip * wip dump * chore: Update romeo parser * chore: Anthropic model fix * wip * allbirds * allbirds runner * format * wip * wip * mypy updates * update * remove r * update tests * format * wip * chore: Strategically update the message * rebase and fix import issues * Update package imports for graphiti_core in examples and utils * nits * chore: Update OpenAI GPT-4o model to gpt-4o-2024-08-06 * implement groq * improvments & linting * cleanup and nits * Refactor package imports for graphiti_core in examples and utils * Refactor package imports for graphiti_core in examples and utils * chore: Nuke unused examples * chore: Nuke unused examples * chore: Only run type check on graphiti_core * fix unit tests * reformat * unit test * fix: Unit tests * test: Add coverage for extract_date_strings_from_edge * lint * remove commented code --------- Co-authored-by: prestonrasmussen <prasmuss15@gmail.com> Co-authored-by: Daniel Chalef <131175+danielchalef@users.noreply.github.com>
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import os
|
|
import re
|
|
|
|
|
|
def parse_wizard_of_oz(file_path):
|
|
with open(file_path, encoding='utf-8') as file:
|
|
content = file.read()
|
|
|
|
# Split the content into chapters
|
|
chapters = re.split(r'\n\n+Chapter [IVX]+\n', content)[
|
|
1:
|
|
] # Skip the first split which is before Chapter I
|
|
|
|
episodes = []
|
|
for i, chapter in enumerate(chapters, start=1):
|
|
# Extract chapter title
|
|
title_match = re.match(r'(.*?)\n\n', chapter)
|
|
title = title_match.group(1) if title_match else f'Chapter {i}'
|
|
|
|
# Remove the title from the chapter content
|
|
chapter_content = chapter[len(title) :].strip() if title_match else chapter.strip()
|
|
|
|
# Create episode dictionary
|
|
episode = {'episode_number': i, 'title': title, 'content': chapter_content}
|
|
episodes.append(episode)
|
|
|
|
return episodes
|
|
|
|
|
|
def get_wizard_of_oz_messages():
|
|
file_path = 'woo.txt'
|
|
script_dir = os.path.dirname(__file__)
|
|
relative_path = os.path.join(script_dir, file_path)
|
|
# Use the function
|
|
parsed_episodes = parse_wizard_of_oz(relative_path)
|
|
return parsed_episodes
|