Mostly working
This commit is contained in:
@@ -10,15 +10,37 @@ def main():
|
|||||||
type=str,
|
type=str,
|
||||||
help="Path to a PDF file to ingest into the RAG system",
|
help="Path to a PDF file to ingest into the RAG system",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--ingest-file",
|
||||||
|
type=str,
|
||||||
|
help="Path to a markdown file to ingest into the RAG system",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--ingest-dir",
|
||||||
|
type=str,
|
||||||
|
help="Path to a directory of markdown files to ingest into the RAG system",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
rag_manager = RAGManager()
|
||||||
|
|
||||||
if args.ingest_pdf:
|
if args.ingest_pdf:
|
||||||
print(f"Ingesting PDF: {args.ingest_pdf}...")
|
print(f"Ingesting PDF: {args.ingest_pdf}...")
|
||||||
rag_manager = RAGManager()
|
|
||||||
rag_manager.ingest_pdf(args.ingest_pdf)
|
rag_manager.ingest_pdf(args.ingest_pdf)
|
||||||
print("PDF ingestion complete.")
|
print("PDF ingestion complete.")
|
||||||
|
|
||||||
|
if args.ingest_file:
|
||||||
|
print(f"Ingesting File: {args.ingest_file}...")
|
||||||
|
rag_manager.ingest_file(args.ingest_file)
|
||||||
|
print("File ingestion complete.")
|
||||||
|
|
||||||
|
if args.ingest_dir:
|
||||||
|
print(f"Ingesting Directory: {args.ingest_dir}...")
|
||||||
|
rag_manager.ingest_directory(args.ingest_dir)
|
||||||
|
print("Directory ingestion complete.")
|
||||||
|
|
||||||
|
if not any([args.ingest_pdf, args.ingest_file, args.ingest_dir]):
|
||||||
print("Hello from dnd-helpers!")
|
print("Hello from dnd-helpers!")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -215,8 +215,11 @@ class PipelineOrchestrator:
|
|||||||
|
|
||||||
# Persistence: Lore Updates
|
# Persistence: Lore Updates
|
||||||
for lore_update in extraction_result.lore_updates:
|
for lore_update in extraction_result.lore_updates:
|
||||||
await asyncio.to_thread(update_lore, lore_update)
|
file_path = await asyncio.to_thread(update_lore, lore_update)
|
||||||
logger.info(f"LLM Worker: Lore updated: {lore_update.entity_name}")
|
await asyncio.to_thread(self.rag_manager.ingest_file, file_path)
|
||||||
|
logger.info(
|
||||||
|
f"LLM Worker: Lore updated and ingested into RAG: {lore_update.entity_name}"
|
||||||
|
)
|
||||||
|
|
||||||
# Persistence: Character State Updates
|
# Persistence: Character State Updates
|
||||||
for char_update in extraction_result.character_updates:
|
for char_update in extraction_result.character_updates:
|
||||||
|
|||||||
@@ -87,6 +87,22 @@ class RAGManager:
|
|||||||
|
|
||||||
print(f"Successfully ingested {file_path} into the vector store.")
|
print(f"Successfully ingested {file_path} into the vector store.")
|
||||||
|
|
||||||
|
def ingest_directory(self, dir_path: str):
|
||||||
|
"""
|
||||||
|
Recursively loads all markdown files in a directory into the index.
|
||||||
|
"""
|
||||||
|
files_processed = 0
|
||||||
|
for root, _, files in os.walk(dir_path):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith(".md"):
|
||||||
|
file_path = os.path.join(root, file)
|
||||||
|
self.ingest_file(file_path)
|
||||||
|
files_processed += 1
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"Successfully ingested {files_processed} files from {dir_path} into the vector store."
|
||||||
|
)
|
||||||
|
|
||||||
def summarize_results(self, query: str, nodes: List[Any]) -> List[ContextUpdate]:
|
def summarize_results(self, query: str, nodes: List[Any]) -> List[ContextUpdate]:
|
||||||
"""
|
"""
|
||||||
Uses an LLM to transform raw snippets into concise "insights", filtering out irrelevant content.
|
Uses an LLM to transform raw snippets into concise "insights", filtering out irrelevant content.
|
||||||
|
|||||||
Reference in New Issue
Block a user