-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_knowledge_extraction.py
More file actions
79 lines (63 loc) · 2.55 KB
/
debug_knowledge_extraction.py
File metadata and controls
79 lines (63 loc) · 2.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
#!/usr/bin/env python3
"""
Debug script for knowledge extraction
"""
import os
import sys
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
sys.path.append('/Users/zoecapital/ai-sdr')
from agents.knowledge_extraction_agent import KnowledgeExtractionAgent
def test_knowledge_extraction():
print("🧪 Testing Knowledge Extraction Agent")
print("=" * 50)
# Test with the uploaded file
file_path = "/Users/zoecapital/ai-sdr/uploads/training/demo_user_sample_company_doc.txt"
if not os.path.exists(file_path):
print(f"❌ File not found: {file_path}")
return
print(f"📁 Testing with file: {file_path}")
# Initialize the agent
try:
agent = KnowledgeExtractionAgent()
print("✅ Agent initialized successfully")
except Exception as e:
print(f"❌ Failed to initialize agent: {e}")
return
# Test file reading
try:
content = agent._read_document(file_path)
if content:
print(f"✅ File read successfully ({len(content)} characters)")
print(f"📄 First 200 characters: {content[:200]}...")
else:
print("❌ Failed to read file content")
return
except Exception as e:
print(f"❌ Error reading file: {e}")
return
# Test knowledge extraction
try:
print("\n🧠 Testing knowledge extraction...")
result = agent.extract_knowledge_from_files([file_path])
if result["success"]:
print("✅ Knowledge extraction successful!")
knowledge = result["knowledge"]
print("\n📊 Extracted Knowledge:")
print(f"🏢 Company: {knowledge.get('company_info', {}).get('company_name', 'N/A')}")
print(f"🏭 Industry: {knowledge.get('company_info', {}).get('industry', 'N/A')}")
print(f"📦 Products: {len(knowledge.get('products', []))}")
print(f"💬 Key Messages: {len(knowledge.get('key_messages', []))}")
if knowledge.get('key_messages'):
print("Sample key messages:")
for i, msg in enumerate(knowledge['key_messages'][:3], 1):
print(f" {i}. {msg}")
else:
print(f"❌ Knowledge extraction failed: {result.get('error', 'Unknown error')}")
except Exception as e:
print(f"❌ Error during knowledge extraction: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_knowledge_extraction()