-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_smart_extraction.py
More file actions
55 lines (43 loc) · 1.95 KB
/
test_smart_extraction.py
File metadata and controls
55 lines (43 loc) · 1.95 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
import os
import sys
# Add project root to path
# Add project root to path
sys.path.append(os.path.join(os.getcwd(), 'form-flow-backend'))
from services.ai.local_llm import get_local_llm_service
from utils.logging import setup_logging
def test_smart_extraction():
# Setup logging to see GPU status
setup_logging(level="INFO")
print("🚀 Initializing Local LLM Service...")
# Mock settings if needed, or rely on env
service = get_local_llm_service()
if not service:
print("❌ Failed to initialize service (check logs)")
return
# User's example schema
fields = [
{"name": "full_name", "label": "Full Name", "type": "text"},
{"name": "email", "label": "Email Address", "type": "email"},
{"name": "phone", "label": "Phone", "type": "tel"},
{"name": "country", "label": "Country", "type": "text"},
{"name": "contact_reason", "label": "Contact Reason", "type": "select", "options": [
{"label": "Project Enquiry", "value": "project_enquiry"},
{"label": "Job Application", "value": "job_application"},
{"label": "Other", "value": "other"}
]},
{"name": "message", "label": "Message", "type": "textarea"}
]
# User's example speech
user_input = "Patil my email id has email id as [email protected] country India the reason for contact is a project enquiry the message saying I want to get more information about the"
print(f"\n🗣️ User Input: \"{user_input}\"")
print(f"📋 Fields: {[f['label'] for f in fields]}")
print("\n🔮 Running extraction...")
try:
result = service.extract_all_fields(user_input, fields)
print("\n✅ Extraction Result:")
for key, value in result['extracted'].items():
print(f" - {key}: {value}")
except Exception as e:
print(f"❌ Error during extraction: {e}")
if __name__ == "__main__":
test_smart_extraction()