|
|
|
|
|
""" |
|
|
Test Document Generation System |
|
|
|
|
|
Simple test to verify the document generation and inter-system communication works. |
|
|
""" |
|
|
|
|
|
import asyncio |
|
|
import sys |
|
|
import os |
|
|
from datetime import datetime |
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
|
|
|
|
|
from atles.document_generation_system import create_document_generation_system, DocumentType, Priority |
|
|
|
|
|
|
|
|
async def test_document_generation(): |
|
|
"""Test document generation system""" |
|
|
|
|
|
print("π§ͺ Testing ATLES Document Generation System") |
|
|
print("=" * 50) |
|
|
|
|
|
|
|
|
doc_system = create_document_generation_system("test_system") |
|
|
|
|
|
|
|
|
await doc_system.start() |
|
|
print("β
Document system started") |
|
|
|
|
|
|
|
|
request_id = await doc_system.create_document_request( |
|
|
requester_system="test_client", |
|
|
document_type=DocumentType.KNOWLEDGE_BASE_ENTRY, |
|
|
title="ATLES System Overview", |
|
|
description="A comprehensive overview of the ATLES autonomous AI system, including its capabilities, architecture, and key features.", |
|
|
requirements={ |
|
|
"style": "educational", |
|
|
"length": "medium", |
|
|
"include_examples": True |
|
|
}, |
|
|
priority=Priority.HIGH |
|
|
) |
|
|
|
|
|
print(f"π Created document request: {request_id}") |
|
|
|
|
|
|
|
|
print("β³ Waiting for document generation...") |
|
|
|
|
|
|
|
|
for i in range(10): |
|
|
await asyncio.sleep(1) |
|
|
|
|
|
status = await doc_system.get_request_status(request_id) |
|
|
if status: |
|
|
print(f" Status: {status['status']} - Progress: {status['progress']:.1f}%") |
|
|
|
|
|
if status['status'] == 'completed': |
|
|
print("β
Document generation completed!") |
|
|
break |
|
|
elif status['status'] == 'failed': |
|
|
print("β Document generation failed!") |
|
|
break |
|
|
|
|
|
|
|
|
documents = await doc_system.list_documents() |
|
|
print(f"\nπ Generated {len(documents)} documents:") |
|
|
|
|
|
for doc in documents: |
|
|
print(f" β’ {doc['title']}") |
|
|
print(f" Type: {doc['document_type']}") |
|
|
print(f" Words: {doc['word_count']}") |
|
|
print(f" Quality: {doc['quality_score']:.2f}") |
|
|
print(f" File: {doc['file_path']}") |
|
|
|
|
|
|
|
|
try: |
|
|
with open(doc['file_path'], 'r', encoding='utf-8') as f: |
|
|
content = f.read() |
|
|
|
|
|
print(f"\nπ DOCUMENT CONTENT PREVIEW:") |
|
|
print("-" * 40) |
|
|
print(content[:300] + "..." if len(content) > 300 else content) |
|
|
print("-" * 40) |
|
|
|
|
|
except Exception as e: |
|
|
print(f" β Could not read document: {e}") |
|
|
|
|
|
|
|
|
status = doc_system.get_system_status() |
|
|
print(f"\nπ§ System Status:") |
|
|
print(f" Running: {status['is_running']}") |
|
|
print(f" Active Requests: {status['active_requests']}") |
|
|
print(f" Completed Documents: {status['completed_documents']}") |
|
|
print(f" Total Generated: {status['total_generated']}") |
|
|
|
|
|
|
|
|
await doc_system.stop() |
|
|
print("\nβ
Document system stopped") |
|
|
|
|
|
print("\nπ Document generation test completed!") |
|
|
|
|
|
|
|
|
def main(): |
|
|
"""Main entry point""" |
|
|
|
|
|
print("Testing ATLES Document Generation System...") |
|
|
|
|
|
try: |
|
|
asyncio.run(test_document_generation()) |
|
|
except Exception as e: |
|
|
print(f"β Test failed: {e}") |
|
|
return 1 |
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
sys.exit(main()) |
|
|
|