paddleocr-skills 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -220
- package/bin/paddleocr-skills.js +33 -20
- package/lib/copy.js +39 -39
- package/lib/installer.js +76 -70
- package/lib/prompts.js +67 -67
- package/lib/python.js +75 -75
- package/lib/verify.js +121 -121
- package/package.json +42 -42
- package/templates/.env.example +12 -12
- package/templates/{paddleocr-vl/references/paddleocr-vl → paddleocr-vl-1.5/references/paddleocr-vl-1.5}/layout_schema.md +64 -64
- package/templates/{paddleocr-vl/references/paddleocr-vl → paddleocr-vl-1.5/references/paddleocr-vl-1.5}/output_format.md +154 -154
- package/templates/{paddleocr-vl/references/paddleocr-vl → paddleocr-vl-1.5/references/paddleocr-vl-1.5}/vl_model_spec.md +157 -157
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/_lib.py +780 -780
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/configure.py +270 -270
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/optimize_file.py +226 -226
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/requirements-optimize.txt +8 -8
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/requirements.txt +7 -7
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/smoke_test.py +199 -199
- package/templates/{paddleocr-vl/scripts/paddleocr-vl → paddleocr-vl-1.5/scripts/paddleocr-vl-1.5}/vl_caller.py +232 -232
- package/templates/{paddleocr-vl/skills/paddleocr-vl → paddleocr-vl-1.5/skills/paddleocr-vl-1.5}/SKILL.md +481 -481
- package/templates/ppocrv5/references/ppocrv5/agent_policy.md +258 -258
- package/templates/ppocrv5/references/ppocrv5/normalized_schema.md +257 -257
- package/templates/ppocrv5/references/ppocrv5/provider_api.md +140 -140
- package/templates/ppocrv5/scripts/ppocrv5/_lib.py +635 -635
- package/templates/ppocrv5/scripts/ppocrv5/configure.py +346 -346
- package/templates/ppocrv5/scripts/ppocrv5/ocr_caller.py +684 -684
- package/templates/ppocrv5/scripts/ppocrv5/requirements.txt +4 -4
- package/templates/ppocrv5/scripts/ppocrv5/smoke_test.py +139 -139
- package/templates/ppocrv5/skills/ppocrv5/SKILL.md +272 -272
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
Smoke Test for PaddleOCR-VL
|
|
5
|
-
|
|
6
|
-
Verifies that VL_API_URL and VL_TOKEN are correctly configured
|
|
7
|
-
and that the API is accessible.
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
python scripts/paddleocr-vl/smoke_test.py
|
|
11
|
-
python scripts/paddleocr-vl/smoke_test.py --test-url "URL" # Optional custom test
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
import argparse
|
|
15
|
-
import json
|
|
16
|
-
import sys
|
|
17
|
-
from pathlib import Path
|
|
18
|
-
|
|
19
|
-
# Add current directory to Python path
|
|
20
|
-
script_dir = Path(__file__).parent
|
|
21
|
-
sys.path.insert(0, str(script_dir))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def main():
|
|
25
|
-
parser = argparse.ArgumentParser(description='PaddleOCR-VL smoke test')
|
|
26
|
-
parser.add_argument(
|
|
27
|
-
'--test-url',
|
|
28
|
-
help='Optional: Custom document URL for testing'
|
|
29
|
-
)
|
|
30
|
-
parser.add_argument(
|
|
31
|
-
'--skip-api-test',
|
|
32
|
-
action='store_true',
|
|
33
|
-
help='Skip API connectivity test, only check configuration'
|
|
34
|
-
)
|
|
35
|
-
args = parser.parse_args()
|
|
36
|
-
|
|
37
|
-
print("=" * 60)
|
|
38
|
-
print("PaddleOCR-VL - Smoke Test")
|
|
39
|
-
print("=" * 60)
|
|
40
|
-
print()
|
|
41
|
-
|
|
42
|
-
# Check configuration
|
|
43
|
-
print("\n[1/3] Checking configuration...")
|
|
44
|
-
|
|
45
|
-
from _lib import Config
|
|
46
|
-
|
|
47
|
-
try:
|
|
48
|
-
Config.load_env()
|
|
49
|
-
|
|
50
|
-
# Get config values
|
|
51
|
-
api_url = Config.get_vl_api_url()
|
|
52
|
-
token = Config.get_vl_token()
|
|
53
|
-
timeout_ms = Config.get_timeout_ms()
|
|
54
|
-
max_retry = Config.get_max_retry()
|
|
55
|
-
cache_ttl = Config.get_cache_ttl_sec()
|
|
56
|
-
|
|
57
|
-
print(f"+ VL_API_URL: {api_url}")
|
|
58
|
-
|
|
59
|
-
# Mask token for display
|
|
60
|
-
if len(token) > 12:
|
|
61
|
-
masked_token = token[:8] + "..." + token[-4:]
|
|
62
|
-
else:
|
|
63
|
-
masked_token = "***"
|
|
64
|
-
print(f"+ VL_TOKEN: {masked_token}")
|
|
65
|
-
print(f"+ Timeout: {timeout_ms}ms")
|
|
66
|
-
print(f"+ Max Retry: {max_retry}")
|
|
67
|
-
print(f"+ Cache TTL: {cache_ttl}s")
|
|
68
|
-
print()
|
|
69
|
-
|
|
70
|
-
except Exception as e:
|
|
71
|
-
print(f"\nConfiguration error: {e}")
|
|
72
|
-
return 1
|
|
73
|
-
|
|
74
|
-
# Check imports and dependencies
|
|
75
|
-
print("[2/3] Checking dependencies...")
|
|
76
|
-
print()
|
|
77
|
-
|
|
78
|
-
try:
|
|
79
|
-
import httpx
|
|
80
|
-
print(f"+ httpx: {httpx.__version__}")
|
|
81
|
-
|
|
82
|
-
from dotenv import load_dotenv
|
|
83
|
-
print("+ python-dotenv: installed")
|
|
84
|
-
|
|
85
|
-
from _lib import VLClient, QualityEvaluator, SimpleCache
|
|
86
|
-
print("+ VLClient: OK")
|
|
87
|
-
print("+ QualityEvaluator: OK")
|
|
88
|
-
print("+ SimpleCache: OK")
|
|
89
|
-
print()
|
|
90
|
-
|
|
91
|
-
except ImportError as e:
|
|
92
|
-
print(f"X Dependency error: {e}")
|
|
93
|
-
print()
|
|
94
|
-
print("Please install dependencies:")
|
|
95
|
-
print(" pip install -r scripts/paddleocr-vl/requirements.txt")
|
|
96
|
-
print()
|
|
97
|
-
return 1
|
|
98
|
-
|
|
99
|
-
# Test API connectivity
|
|
100
|
-
if args.skip_api_test:
|
|
101
|
-
print("[3/3] Skipping API connectivity test (--skip-api-test)")
|
|
102
|
-
print()
|
|
103
|
-
print("=" * 60)
|
|
104
|
-
print("Configuration Check Complete!")
|
|
105
|
-
print("=" * 60)
|
|
106
|
-
print()
|
|
107
|
-
print("Your PaddleOCR-VL is configured correctly.")
|
|
108
|
-
print()
|
|
109
|
-
print("To test with a real document, run:")
|
|
110
|
-
print(' python scripts/paddleocr-vl/vl_caller.py --file-url "URL"')
|
|
111
|
-
print()
|
|
112
|
-
return 0
|
|
113
|
-
|
|
114
|
-
print("[3/3] Testing API connectivity...")
|
|
115
|
-
print()
|
|
116
|
-
|
|
117
|
-
# Use provided test URL or default
|
|
118
|
-
test_url = args.test_url or "https://paddleocr.bj.bcebos.com/dataset/document_layout_sample.png"
|
|
119
|
-
|
|
120
|
-
print(f"Test document: {test_url}")
|
|
121
|
-
print("Calling PaddleOCR-VL API...")
|
|
122
|
-
print()
|
|
123
|
-
|
|
124
|
-
from _lib import make_api_request, QualityEvaluator
|
|
125
|
-
|
|
126
|
-
try:
|
|
127
|
-
result = make_api_request(
|
|
128
|
-
file_url=test_url,
|
|
129
|
-
timeout_ms=timeout_ms,
|
|
130
|
-
use_cache=False # Force fresh request for testing
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
if not result.get("ok", False):
|
|
134
|
-
error = result.get("error", {})
|
|
135
|
-
print(f"X API call failed: {error.get('message', 'Unknown error')}")
|
|
136
|
-
print(f" Error code: {error.get('code', 'UNKNOWN')}")
|
|
137
|
-
print()
|
|
138
|
-
return 1
|
|
139
|
-
|
|
140
|
-
print("+ API call successful!")
|
|
141
|
-
print()
|
|
142
|
-
|
|
143
|
-
# Evaluate quality
|
|
144
|
-
quality = QualityEvaluator.evaluate(result)
|
|
145
|
-
|
|
146
|
-
print("Response Quality:")
|
|
147
|
-
print(f" - Overall Confidence: {quality['overall_confidence']:.2f} / 1.00")
|
|
148
|
-
print(f" - Quality Level: {quality['quality_level']}")
|
|
149
|
-
|
|
150
|
-
if quality.get('region_stats'):
|
|
151
|
-
stats = quality['region_stats']
|
|
152
|
-
print(f" - Regions Detected: {stats.get('total_regions', 0)}")
|
|
153
|
-
|
|
154
|
-
if stats.get('by_type'):
|
|
155
|
-
print(" - Region Types:")
|
|
156
|
-
for region_type, count in sorted(stats['by_type'].items()):
|
|
157
|
-
print(f" {region_type}: {count}")
|
|
158
|
-
|
|
159
|
-
if quality.get('warnings'):
|
|
160
|
-
print("\n Warnings:")
|
|
161
|
-
for warning in quality['warnings']:
|
|
162
|
-
print(f" ! {warning}")
|
|
163
|
-
|
|
164
|
-
print()
|
|
165
|
-
|
|
166
|
-
# Show sample content
|
|
167
|
-
result_data = result.get("result", {})
|
|
168
|
-
full_text = result_data.get("full_text", "")
|
|
169
|
-
|
|
170
|
-
if full_text:
|
|
171
|
-
preview_length = min(200, len(full_text))
|
|
172
|
-
print(f"Content Preview ({preview_length} chars):")
|
|
173
|
-
print(f" {full_text[:preview_length]}...")
|
|
174
|
-
print()
|
|
175
|
-
|
|
176
|
-
except Exception as e:
|
|
177
|
-
print(f"X API call failed: {e}")
|
|
178
|
-
print()
|
|
179
|
-
return 1
|
|
180
|
-
|
|
181
|
-
# Success
|
|
182
|
-
print("=" * 60)
|
|
183
|
-
print("All Tests Passed!")
|
|
184
|
-
print("=" * 60)
|
|
185
|
-
print()
|
|
186
|
-
print("Your PaddleOCR-VL setup is working correctly.")
|
|
187
|
-
print()
|
|
188
|
-
print("Next steps:")
|
|
189
|
-
print(' - Parse documents: python scripts/paddleocr-vl/vl_caller.py --file-url "URL"')
|
|
190
|
-
print(' - Show quality info: Add --show-quality flag')
|
|
191
|
-
print(' - Pretty JSON: Add --pretty flag')
|
|
192
|
-
print()
|
|
193
|
-
|
|
194
|
-
return 0
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if __name__ == '__main__':
|
|
198
|
-
exit_code = main()
|
|
199
|
-
sys.exit(exit_code)
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Smoke Test for PaddleOCR-VL 1.5
|
|
5
|
+
|
|
6
|
+
Verifies that VL_API_URL and VL_TOKEN are correctly configured
|
|
7
|
+
and that the API is accessible.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python scripts/paddleocr-vl-1.5/smoke_test.py
|
|
11
|
+
python scripts/paddleocr-vl-1.5/smoke_test.py --test-url "URL" # Optional custom test
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
# Add current directory to Python path
|
|
20
|
+
script_dir = Path(__file__).parent
|
|
21
|
+
sys.path.insert(0, str(script_dir))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main():
|
|
25
|
+
parser = argparse.ArgumentParser(description='PaddleOCR-VL 1.5 smoke test')
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
'--test-url',
|
|
28
|
+
help='Optional: Custom document URL for testing'
|
|
29
|
+
)
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
'--skip-api-test',
|
|
32
|
+
action='store_true',
|
|
33
|
+
help='Skip API connectivity test, only check configuration'
|
|
34
|
+
)
|
|
35
|
+
args = parser.parse_args()
|
|
36
|
+
|
|
37
|
+
print("=" * 60)
|
|
38
|
+
print("PaddleOCR-VL 1.5 - Smoke Test")
|
|
39
|
+
print("=" * 60)
|
|
40
|
+
print()
|
|
41
|
+
|
|
42
|
+
# Check configuration
|
|
43
|
+
print("\n[1/3] Checking configuration...")
|
|
44
|
+
|
|
45
|
+
from _lib import Config
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
Config.load_env()
|
|
49
|
+
|
|
50
|
+
# Get config values
|
|
51
|
+
api_url = Config.get_vl_api_url()
|
|
52
|
+
token = Config.get_vl_token()
|
|
53
|
+
timeout_ms = Config.get_timeout_ms()
|
|
54
|
+
max_retry = Config.get_max_retry()
|
|
55
|
+
cache_ttl = Config.get_cache_ttl_sec()
|
|
56
|
+
|
|
57
|
+
print(f"+ VL_API_URL: {api_url}")
|
|
58
|
+
|
|
59
|
+
# Mask token for display
|
|
60
|
+
if len(token) > 12:
|
|
61
|
+
masked_token = token[:8] + "..." + token[-4:]
|
|
62
|
+
else:
|
|
63
|
+
masked_token = "***"
|
|
64
|
+
print(f"+ VL_TOKEN: {masked_token}")
|
|
65
|
+
print(f"+ Timeout: {timeout_ms}ms")
|
|
66
|
+
print(f"+ Max Retry: {max_retry}")
|
|
67
|
+
print(f"+ Cache TTL: {cache_ttl}s")
|
|
68
|
+
print()
|
|
69
|
+
|
|
70
|
+
except Exception as e:
|
|
71
|
+
print(f"\nConfiguration error: {e}")
|
|
72
|
+
return 1
|
|
73
|
+
|
|
74
|
+
# Check imports and dependencies
|
|
75
|
+
print("[2/3] Checking dependencies...")
|
|
76
|
+
print()
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
import httpx
|
|
80
|
+
print(f"+ httpx: {httpx.__version__}")
|
|
81
|
+
|
|
82
|
+
from dotenv import load_dotenv
|
|
83
|
+
print("+ python-dotenv: installed")
|
|
84
|
+
|
|
85
|
+
from _lib import VLClient, QualityEvaluator, SimpleCache
|
|
86
|
+
print("+ VLClient: OK")
|
|
87
|
+
print("+ QualityEvaluator: OK")
|
|
88
|
+
print("+ SimpleCache: OK")
|
|
89
|
+
print()
|
|
90
|
+
|
|
91
|
+
except ImportError as e:
|
|
92
|
+
print(f"X Dependency error: {e}")
|
|
93
|
+
print()
|
|
94
|
+
print("Please install dependencies:")
|
|
95
|
+
print(" pip install -r scripts/paddleocr-vl-1.5/requirements.txt")
|
|
96
|
+
print()
|
|
97
|
+
return 1
|
|
98
|
+
|
|
99
|
+
# Test API connectivity
|
|
100
|
+
if args.skip_api_test:
|
|
101
|
+
print("[3/3] Skipping API connectivity test (--skip-api-test)")
|
|
102
|
+
print()
|
|
103
|
+
print("=" * 60)
|
|
104
|
+
print("Configuration Check Complete!")
|
|
105
|
+
print("=" * 60)
|
|
106
|
+
print()
|
|
107
|
+
print("Your PaddleOCR-VL 1.5 is configured correctly.")
|
|
108
|
+
print()
|
|
109
|
+
print("To test with a real document, run:")
|
|
110
|
+
print(' python scripts/paddleocr-vl-1.5/vl_caller.py --file-url "URL"')
|
|
111
|
+
print()
|
|
112
|
+
return 0
|
|
113
|
+
|
|
114
|
+
print("[3/3] Testing API connectivity...")
|
|
115
|
+
print()
|
|
116
|
+
|
|
117
|
+
# Use provided test URL or default
|
|
118
|
+
test_url = args.test_url or "https://paddleocr.bj.bcebos.com/dataset/document_layout_sample.png"
|
|
119
|
+
|
|
120
|
+
print(f"Test document: {test_url}")
|
|
121
|
+
print("Calling PaddleOCR-VL 1.5 API...")
|
|
122
|
+
print()
|
|
123
|
+
|
|
124
|
+
from _lib import make_api_request, QualityEvaluator
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
result = make_api_request(
|
|
128
|
+
file_url=test_url,
|
|
129
|
+
timeout_ms=timeout_ms,
|
|
130
|
+
use_cache=False # Force fresh request for testing
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
if not result.get("ok", False):
|
|
134
|
+
error = result.get("error", {})
|
|
135
|
+
print(f"X API call failed: {error.get('message', 'Unknown error')}")
|
|
136
|
+
print(f" Error code: {error.get('code', 'UNKNOWN')}")
|
|
137
|
+
print()
|
|
138
|
+
return 1
|
|
139
|
+
|
|
140
|
+
print("+ API call successful!")
|
|
141
|
+
print()
|
|
142
|
+
|
|
143
|
+
# Evaluate quality
|
|
144
|
+
quality = QualityEvaluator.evaluate(result)
|
|
145
|
+
|
|
146
|
+
print("Response Quality:")
|
|
147
|
+
print(f" - Overall Confidence: {quality['overall_confidence']:.2f} / 1.00")
|
|
148
|
+
print(f" - Quality Level: {quality['quality_level']}")
|
|
149
|
+
|
|
150
|
+
if quality.get('region_stats'):
|
|
151
|
+
stats = quality['region_stats']
|
|
152
|
+
print(f" - Regions Detected: {stats.get('total_regions', 0)}")
|
|
153
|
+
|
|
154
|
+
if stats.get('by_type'):
|
|
155
|
+
print(" - Region Types:")
|
|
156
|
+
for region_type, count in sorted(stats['by_type'].items()):
|
|
157
|
+
print(f" {region_type}: {count}")
|
|
158
|
+
|
|
159
|
+
if quality.get('warnings'):
|
|
160
|
+
print("\n Warnings:")
|
|
161
|
+
for warning in quality['warnings']:
|
|
162
|
+
print(f" ! {warning}")
|
|
163
|
+
|
|
164
|
+
print()
|
|
165
|
+
|
|
166
|
+
# Show sample content
|
|
167
|
+
result_data = result.get("result", {})
|
|
168
|
+
full_text = result_data.get("full_text", "")
|
|
169
|
+
|
|
170
|
+
if full_text:
|
|
171
|
+
preview_length = min(200, len(full_text))
|
|
172
|
+
print(f"Content Preview ({preview_length} chars):")
|
|
173
|
+
print(f" {full_text[:preview_length]}...")
|
|
174
|
+
print()
|
|
175
|
+
|
|
176
|
+
except Exception as e:
|
|
177
|
+
print(f"X API call failed: {e}")
|
|
178
|
+
print()
|
|
179
|
+
return 1
|
|
180
|
+
|
|
181
|
+
# Success
|
|
182
|
+
print("=" * 60)
|
|
183
|
+
print("All Tests Passed!")
|
|
184
|
+
print("=" * 60)
|
|
185
|
+
print()
|
|
186
|
+
print("Your PaddleOCR-VL 1.5 setup is working correctly.")
|
|
187
|
+
print()
|
|
188
|
+
print("Next steps:")
|
|
189
|
+
print(' - Parse documents: python scripts/paddleocr-vl-1.5/vl_caller.py --file-url "URL"')
|
|
190
|
+
print(' - Show quality info: Add --show-quality flag')
|
|
191
|
+
print(' - Pretty JSON: Add --pretty flag')
|
|
192
|
+
print()
|
|
193
|
+
|
|
194
|
+
return 0
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
if __name__ == '__main__':
|
|
198
|
+
exit_code = main()
|
|
199
|
+
sys.exit(exit_code)
|