-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_project_hints.py
More file actions
124 lines (98 loc) · 4.55 KB
/
test_project_hints.py
File metadata and controls
124 lines (98 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3
"""Test script for the project management hints endpoint."""
import requests
import json
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
def test_project_hints():
"""Test the project management hints endpoint."""
# Configuration
base_url = "http://localhost:8000"
# Example request payload
request_data = {
"project": {
"id": 1, # Replace with actual project ID
"type": "project" # or "portfolio", "program"
},
"openproject": {
"base_url": "https://your-openproject-instance.com", # Replace with actual URL
"user_token": "your-api-token-here" # Replace with actual token
}
}
print("Testing Project Management Hints Endpoint")
print("=" * 50)
try:
# Make request to the hints endpoint
response = requests.post(
f"{base_url}/project-management-hints",
json=request_data,
headers={"Content-Type": "application/json"},
timeout=300 # 5 minutes timeout for comprehensive analysis
)
if response.status_code == 200:
hints_data = response.json()
print(f"✅ Successfully generated {len(hints_data['hints'])} hints")
print(f"📊 Performed {hints_data['checks_performed']} automated checks")
print(f"🏗️ Project ID: {hints_data['project_id']}")
print(f"🌐 OpenProject URL: {hints_data['openproject_base_url']}")
print(f"📅 Generated at: {hints_data['generated_at']}")
print("\n📋 HINTS:")
print("-" * 30)
for i, hint in enumerate(hints_data['hints'], 1):
print(f"{i}. {hint['title']}")
print(f" {hint['description']}")
print(f" ☐ Checked: {hint['checked']}")
print()
if hints_data.get('summary'):
print("📝 SUMMARY:")
print("-" * 30)
print(hints_data['summary'])
# Save response to file for inspection
with open('project_hints_response.json', 'w', encoding='utf-8') as f:
json.dump(hints_data, f, indent=2, ensure_ascii=False)
print(f"\n💾 Full response saved to: project_hints_response.json")
else:
print(f"❌ Error {response.status_code}: {response.text}")
except requests.exceptions.ConnectionError:
print("❌ Connection error: Make sure the server is running on http://localhost:8000")
except requests.exceptions.Timeout:
print("❌ Request timeout: The analysis took too long")
except Exception as e:
print(f"❌ Unexpected error: {e}")
def test_rag_status():
"""Test the RAG system status."""
base_url = "http://localhost:8000"
print("\nTesting RAG System Status")
print("=" * 30)
try:
response = requests.get(f"{base_url}/rag/status")
if response.status_code == 200:
status_data = response.json()
print("✅ RAG system status retrieved")
print(f"📊 Pipeline ready: {status_data.get('validation', {}).get('pipeline_ready', False)}")
pipeline_stats = status_data.get('pipeline_stats', {})
if 'document_stats' in pipeline_stats:
doc_stats = pipeline_stats['document_stats']
print(f"📚 Documents loaded: {doc_stats.get('total_documents', 0)}")
print(f"🔍 Vector chunks: {doc_stats.get('vector_store_stats', {}).get('total_chunks', 0)}")
else:
print(f"❌ Error {response.status_code}: {response.text}")
except Exception as e:
print(f"❌ Error checking RAG status: {e}")
if __name__ == "__main__":
print("🚀 Project Management Hints API Test")
print("=" * 50)
# First check RAG system status
test_rag_status()
# Then test the hints endpoint
print("\n" + "=" * 50)
test_project_hints()
print("\n" + "=" * 50)
print("📖 Usage Instructions:")
print("1. Update the request_data with your actual OpenProject details")
print("2. Make sure the RAG system is initialized: POST /rag/initialize")
print("3. Ensure your OpenProject instance is accessible")
print("4. Run this script to test the endpoint")
print("\n💡 The endpoint performs 10 automated checks and generates German hints based on PMFlex methodology!")