mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Fix adding file path instead of stem to markdown entries
This commit is contained in:
parent
720139c3c1
commit
ad4fa4b2f4
2 changed files with 3 additions and 4 deletions
|
@ -142,13 +142,12 @@ class MarkdownToEntries(TextToEntries):
|
|||
entry_filename = urllib3.util.parse_url(raw_filename).url
|
||||
else:
|
||||
entry_filename = str(Path(raw_filename))
|
||||
stem = Path(raw_filename).stem
|
||||
|
||||
heading = parsed_entry.splitlines()[0] if re.search("^#+\s", parsed_entry) else ""
|
||||
# Append base filename to compiled entry for context to model
|
||||
# Increment heading level for heading entries and make filename as its top level heading
|
||||
prefix = f"# {stem}\n#" if heading else f"# {stem}\n"
|
||||
compiled_entry = f"{entry_filename}\n{prefix}{parsed_entry}"
|
||||
prefix = f"# {entry_filename}\n#" if heading else f"# {entry_filename}\n"
|
||||
compiled_entry = f"{prefix}{parsed_entry}"
|
||||
entries.append(
|
||||
Entry(
|
||||
compiled=compiled_entry,
|
||||
|
|
|
@ -16,7 +16,7 @@ def test_extract_markdown_with_no_headings(tmp_path):
|
|||
data = {
|
||||
f"{tmp_path}": entry,
|
||||
}
|
||||
expected_heading = f"# {tmp_path.stem}"
|
||||
expected_heading = f"# {tmp_path}"
|
||||
|
||||
# Act
|
||||
# Extract Entries from specified Markdown files
|
||||
|
|
Loading…
Reference in a new issue