struai 0.0.1__tar.gz → 0.2.0__tar.gz

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.
@@ -0,0 +1,58 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test-python:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.9', '3.10', '3.11', '3.12']
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Python ${{ matrix.python-version }}
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ pip install -e ".[dev]"
26
+
27
+ - name: Lint
28
+ run: ruff check src/
29
+
30
+ - name: Type check
31
+ run: mypy src/struai/ --ignore-missing-imports
32
+ continue-on-error: true
33
+
34
+ test-node:
35
+ runs-on: ubuntu-latest
36
+ defaults:
37
+ run:
38
+ working-directory: js
39
+ strategy:
40
+ matrix:
41
+ node-version: ['18', '20', '22']
42
+ steps:
43
+ - uses: actions/checkout@v4
44
+
45
+ - name: Set up Node.js ${{ matrix.node-version }}
46
+ uses: actions/setup-node@v4
47
+ with:
48
+ node-version: ${{ matrix.node-version }}
49
+
50
+ - name: Install dependencies
51
+ run: npm install
52
+
53
+ - name: Build
54
+ run: npm run build
55
+
56
+ - name: Test
57
+ run: npm test
58
+ continue-on-error: true # Tests not implemented yet
@@ -0,0 +1,68 @@
1
+ name: Publish npm Package
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches: [main]
7
+ paths:
8
+ - 'js/**'
9
+ - '.github/workflows/publish-npm.yml'
10
+ release:
11
+ types: [published]
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ defaults:
17
+ run:
18
+ working-directory: js
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ - name: Set up Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: '20'
26
+ registry-url: 'https://registry.npmjs.org'
27
+
28
+ - name: Install dependencies
29
+ run: npm install
30
+
31
+ - name: Build
32
+ run: npm run build
33
+
34
+ - name: Upload artifacts
35
+ uses: actions/upload-artifact@v4
36
+ with:
37
+ name: npm-dist
38
+ path: js/dist/
39
+
40
+ publish:
41
+ needs: build
42
+ runs-on: ubuntu-latest
43
+ if: github.event_name == 'release' || github.ref == 'refs/heads/main'
44
+ defaults:
45
+ run:
46
+ working-directory: js
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+
50
+ - name: Set up Node.js
51
+ uses: actions/setup-node@v4
52
+ with:
53
+ node-version: '20'
54
+ registry-url: 'https://registry.npmjs.org'
55
+
56
+ - name: Install dependencies
57
+ run: npm install
58
+
59
+ - name: Download artifacts
60
+ uses: actions/download-artifact@v4
61
+ with:
62
+ name: npm-dist
63
+ path: js/dist/
64
+
65
+ - name: Publish to npm
66
+ run: npm publish --access public
67
+ env:
68
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,54 @@
1
+ name: Publish Python Package
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches: [main]
7
+ paths:
8
+ - 'src/**'
9
+ - 'pyproject.toml'
10
+ - '.github/workflows/publish-python.yml'
11
+ release:
12
+ types: [published]
13
+
14
+ jobs:
15
+ build:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: '3.11'
24
+
25
+ - name: Install build tools
26
+ run: pip install build twine
27
+
28
+ - name: Build package
29
+ run: python -m build
30
+
31
+ - name: Upload artifacts
32
+ uses: actions/upload-artifact@v4
33
+ with:
34
+ name: python-dist
35
+ path: dist/
36
+
37
+ publish:
38
+ needs: build
39
+ runs-on: ubuntu-latest
40
+ if: github.event_name == 'release' || github.ref == 'refs/heads/main'
41
+ environment: pypi
42
+ permissions:
43
+ id-token: write
44
+ steps:
45
+ - name: Download artifacts
46
+ uses: actions/download-artifact@v4
47
+ with:
48
+ name: python-dist
49
+ path: dist/
50
+
51
+ - name: Publish to PyPI
52
+ uses: pypa/gh-action-pypi-publish@release/v1
53
+ with:
54
+ skip-existing: true
@@ -0,0 +1,43 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ .pytest_cache/
23
+ .ruff_cache/
24
+ .mypy_cache/
25
+ .venv/
26
+ venv/
27
+
28
+ # JavaScript
29
+ js/node_modules/
30
+ js/dist/
31
+ js/*.tsbuildinfo
32
+
33
+ # IDE
34
+ .idea/
35
+ .vscode/
36
+ *.swp
37
+ *.swo
38
+ .DS_Store
39
+
40
+ # Environment
41
+ .env
42
+ .env.local
43
+ *.pem
struai-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: struai
3
+ Version: 0.2.0
4
+ Summary: StruAI Drawing Analysis SDK - AI-powered construction drawing analysis
5
+ Project-URL: Homepage, https://struai.com
6
+ Project-URL: Documentation, https://docs.struai.com/python
7
+ Project-URL: Repository, https://github.com/struai/struai-python
8
+ Project-URL: Issues, https://github.com/struai/struai-python/issues
9
+ Author-email: StruAI <support@struai.com>
10
+ License-Expression: MIT
11
+ Keywords: ai,cad,construction drawings,drawing analysis,knowledge graph,pdf,struai,structural engineering
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: httpx>=0.25.0
25
+ Requires-Dist: pydantic>=2.0.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.0; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
29
+ Requires-Dist: pytest>=7.0; extra == 'dev'
30
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # StruAI Python SDK
34
+
35
+ Official Python SDK for the StruAI Drawing Analysis API.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install struai
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```python
46
+ from struai import StruAI
47
+
48
+ client = StruAI(api_key="sk-xxx") # or set STRUAI_API_KEY env var
49
+
50
+ # Optional: override base URL (http://localhost:8000 or http://localhost:8000/v1)
51
+ client = StruAI(api_key="sk-xxx", base_url="http://localhost:8000")
52
+ ```
53
+
54
+ ## Tier 1: Raw Detection ($0.02/page)
55
+
56
+ Fast geometric detection. Returns annotations in ~1-2 seconds.
57
+
58
+ ```python
59
+ # Analyze a PDF page
60
+ result = client.drawings.analyze("structural.pdf", page=4)
61
+
62
+ print(f"Processed in {result.processing_ms}ms")
63
+ print(f"Page size: {result.dimensions.width}x{result.dimensions.height}")
64
+
65
+ # Access detected annotations
66
+ for leader in result.annotations.leaders:
67
+ texts = [t.text for t in leader.texts_inside]
68
+ print(f"Leader at {leader.arrow_tip}: {', '.join(texts)}")
69
+
70
+ for tag in result.annotations.section_tags:
71
+ label = tag.texts_inside[0].text
72
+ print(f"Section {label}, direction: {tag.direction}")
73
+
74
+ # Retrieve/delete previous results
75
+ drawing = client.drawings.get("drw_7f8a9b2c")
76
+ client.drawings.delete("drw_7f8a9b2c")
77
+ ```
78
+
79
+ ## Tier 2: Graph + Search ($0.15/page)
80
+
81
+ Full pipeline: detection → LLM enrichment → knowledge graph → semantic search.
82
+
83
+ ```python
84
+ # Create a project
85
+ project = client.projects.create(
86
+ name="Building A Structural",
87
+ description="96-page structural drawing set"
88
+ )
89
+
90
+ # Add sheets (async processing)
91
+ job = project.sheets.add("structural.pdf", page=4)
92
+ result = job.wait(timeout=120) # Blocks until complete
93
+ print(f"Created {result.entities_created} entities")
94
+
95
+ # Semantic search
96
+ results = project.search(
97
+ query="W12x26 beam connections at grid A",
98
+ limit=10,
99
+ include_graph_context=True
100
+ )
101
+
102
+ for hit in results.results:
103
+ print(f"{hit.entity.label}: {hit.score:.2f}")
104
+ if hit.graph_context:
105
+ for rel in hit.graph_context.relationships:
106
+ print(f" - {rel.type}: {rel.fact}")
107
+
108
+ # Natural language query
109
+ answer = project.query("What beams connect to column C3?")
110
+ print(answer.answer)
111
+ print(f"Confidence: {answer.confidence:.0%}")
112
+
113
+ # Browse entities
114
+ entities = project.entities.list(type="Component", limit=50)
115
+ entity = project.entities.get("ent_abc123")
116
+ ```
117
+
118
+ ## Async Support
119
+
120
+ ```python
121
+ from struai import AsyncStruAI
122
+
123
+ async with AsyncStruAI(api_key="sk-xxx") as client:
124
+ # Tier 1
125
+ result = await client.drawings.analyze("structural.pdf", page=4)
126
+
127
+ # Tier 2
128
+ project = await client.projects.create(name="Building A")
129
+ job = await project.sheets.add("structural.pdf", page=4)
130
+ result = await job.wait(timeout=120)
131
+ results = await project.search("W12x26 beam connections")
132
+ ```
133
+
134
+ ## Error Handling
135
+
136
+ ```python
137
+ from struai import StruAI, AuthenticationError, RateLimitError, NotFoundError
138
+
139
+ try:
140
+ result = client.drawings.analyze("plans.pdf", page=99)
141
+ except AuthenticationError:
142
+ print("Invalid API key")
143
+ except RateLimitError as e:
144
+ print(f"Rate limited. Retry after {e.retry_after}s")
145
+ except NotFoundError:
146
+ print("Resource not found")
147
+ ```
148
+
149
+ ## License
150
+
151
+ MIT
struai-0.2.0/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # StruAI Python SDK
2
+
3
+ Official Python SDK for the StruAI Drawing Analysis API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install struai
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from struai import StruAI
15
+
16
+ client = StruAI(api_key="sk-xxx") # or set STRUAI_API_KEY env var
17
+
18
+ # Optional: override base URL (http://localhost:8000 or http://localhost:8000/v1)
19
+ client = StruAI(api_key="sk-xxx", base_url="http://localhost:8000")
20
+ ```
21
+
22
+ ## Tier 1: Raw Detection ($0.02/page)
23
+
24
+ Fast geometric detection. Returns annotations in ~1-2 seconds.
25
+
26
+ ```python
27
+ # Analyze a PDF page
28
+ result = client.drawings.analyze("structural.pdf", page=4)
29
+
30
+ print(f"Processed in {result.processing_ms}ms")
31
+ print(f"Page size: {result.dimensions.width}x{result.dimensions.height}")
32
+
33
+ # Access detected annotations
34
+ for leader in result.annotations.leaders:
35
+ texts = [t.text for t in leader.texts_inside]
36
+ print(f"Leader at {leader.arrow_tip}: {', '.join(texts)}")
37
+
38
+ for tag in result.annotations.section_tags:
39
+ label = tag.texts_inside[0].text
40
+ print(f"Section {label}, direction: {tag.direction}")
41
+
42
+ # Retrieve/delete previous results
43
+ drawing = client.drawings.get("drw_7f8a9b2c")
44
+ client.drawings.delete("drw_7f8a9b2c")
45
+ ```
46
+
47
+ ## Tier 2: Graph + Search ($0.15/page)
48
+
49
+ Full pipeline: detection → LLM enrichment → knowledge graph → semantic search.
50
+
51
+ ```python
52
+ # Create a project
53
+ project = client.projects.create(
54
+ name="Building A Structural",
55
+ description="96-page structural drawing set"
56
+ )
57
+
58
+ # Add sheets (async processing)
59
+ job = project.sheets.add("structural.pdf", page=4)
60
+ result = job.wait(timeout=120) # Blocks until complete
61
+ print(f"Created {result.entities_created} entities")
62
+
63
+ # Semantic search
64
+ results = project.search(
65
+ query="W12x26 beam connections at grid A",
66
+ limit=10,
67
+ include_graph_context=True
68
+ )
69
+
70
+ for hit in results.results:
71
+ print(f"{hit.entity.label}: {hit.score:.2f}")
72
+ if hit.graph_context:
73
+ for rel in hit.graph_context.relationships:
74
+ print(f" - {rel.type}: {rel.fact}")
75
+
76
+ # Natural language query
77
+ answer = project.query("What beams connect to column C3?")
78
+ print(answer.answer)
79
+ print(f"Confidence: {answer.confidence:.0%}")
80
+
81
+ # Browse entities
82
+ entities = project.entities.list(type="Component", limit=50)
83
+ entity = project.entities.get("ent_abc123")
84
+ ```
85
+
86
+ ## Async Support
87
+
88
+ ```python
89
+ from struai import AsyncStruAI
90
+
91
+ async with AsyncStruAI(api_key="sk-xxx") as client:
92
+ # Tier 1
93
+ result = await client.drawings.analyze("structural.pdf", page=4)
94
+
95
+ # Tier 2
96
+ project = await client.projects.create(name="Building A")
97
+ job = await project.sheets.add("structural.pdf", page=4)
98
+ result = await job.wait(timeout=120)
99
+ results = await project.search("W12x26 beam connections")
100
+ ```
101
+
102
+ ## Error Handling
103
+
104
+ ```python
105
+ from struai import StruAI, AuthenticationError, RateLimitError, NotFoundError
106
+
107
+ try:
108
+ result = client.drawings.analyze("plans.pdf", page=99)
109
+ except AuthenticationError:
110
+ print("Invalid API key")
111
+ except RateLimitError as e:
112
+ print(f"Rate limited. Retry after {e.retry_after}s")
113
+ except NotFoundError:
114
+ print("Resource not found")
115
+ ```
116
+
117
+ ## License
118
+
119
+ MIT
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ *.tsbuildinfo
@@ -0,0 +1,73 @@
1
+ # StruAI JavaScript SDK
2
+
3
+ Official JavaScript/TypeScript SDK for the StruAI Drawing Analysis API.
4
+
5
+ See the [main README](../README.md) for Python examples.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install struai
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { StruAI } from 'struai';
17
+
18
+ const client = new StruAI({ apiKey: 'sk-xxx' });
19
+
20
+ // Optional: override base URL (http://localhost:8000 or http://localhost:8000/v1)
21
+ const local = new StruAI({ apiKey: 'sk-xxx', baseUrl: 'http://localhost:8000' });
22
+ ```
23
+
24
+ ## Tier 1: Raw Detection ($0.02/page)
25
+
26
+ ```typescript
27
+ // Analyze a PDF page
28
+ const result = await client.drawings.analyze(file, { page: 4 });
29
+
30
+ console.log(`Processed in ${result.processing_ms}ms`);
31
+
32
+ for (const leader of result.annotations.leaders) {
33
+ const texts = leader.texts_inside.map(t => t.text).join(', ');
34
+ console.log(`Leader: ${texts}`);
35
+ }
36
+ ```
37
+
38
+ ## Tier 2: Graph + Search ($0.15/page)
39
+
40
+ ```typescript
41
+ // Create project
42
+ const project = await client.projects.create({
43
+ name: 'Building A Structural',
44
+ description: '96-page structural drawing set'
45
+ });
46
+
47
+ // Add sheet (async processing)
48
+ const job = await project.sheets.add(file, { page: 4 });
49
+ const result = await job.wait({ timeout: 120000 });
50
+ console.log(`Created ${result.entities_created} entities`);
51
+
52
+ // Semantic search
53
+ const results = await project.search('W12x26 beam connections', {
54
+ limit: 10,
55
+ includeGraphContext: true
56
+ });
57
+
58
+ for (const hit of results.results) {
59
+ console.log(`${hit.entity.label}: ${hit.score}`);
60
+ }
61
+
62
+ // Natural language query
63
+ const answer = await project.query('What beams connect to column C3?');
64
+ console.log(answer.answer);
65
+
66
+ // Browse entities
67
+ const entities = await project.entities.list({ type: 'Component', limit: 50 });
68
+ const entity = await project.entities.get('ent_abc123');
69
+ ```
70
+
71
+ ## License
72
+
73
+ MIT
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "struai",
3
+ "version": "0.2.0",
4
+ "description": "StruAI Drawing Analysis SDK - AI-powered construction drawing analysis",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format cjs,esm --dts",
20
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
21
+ "test": "vitest",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "struai",
26
+ "structural-engineering",
27
+ "construction-drawings",
28
+ "drawing-analysis",
29
+ "cad",
30
+ "pdf",
31
+ "ai",
32
+ "knowledge-graph"
33
+ ],
34
+ "author": "StruAI <support@struai.com>",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/bhoshaga/struai.git",
39
+ "directory": "js"
40
+ },
41
+ "homepage": "https://struai.com",
42
+ "bugs": {
43
+ "url": "https://github.com/bhoshaga/struai/issues"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.0.0",
47
+ "tsup": "^8.0.0",
48
+ "typescript": "^5.0.0",
49
+ "vitest": "^1.0.0"
50
+ },
51
+ "engines": {
52
+ "node": ">=18.0.0"
53
+ }
54
+ }