Skip to content

Commit bcaed45

Browse files
committed
Initial commit
0 parents  commit bcaed45

106 files changed

Lines changed: 33426 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve LangStruct
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Bug Description
10+
A clear and concise description of what the bug is.
11+
12+
## Reproduction Steps
13+
Steps to reproduce the behavior:
14+
1. Go to '...'
15+
2. Run '...'
16+
3. See error
17+
18+
## Expected Behavior
19+
A clear and concise description of what you expected to happen.
20+
21+
## Actual Behavior
22+
A clear and concise description of what actually happened.
23+
24+
## Error Message
25+
```
26+
Paste any error messages or stack traces here
27+
```
28+
29+
## Environment
30+
- **LangStruct version**: [e.g., 0.1.0]
31+
- **Python version**: [e.g., 3.12.0]
32+
- **Operating System**: [e.g., macOS 14.0, Ubuntu 22.04, Windows 11]
33+
- **LLM Provider**: [e.g., OpenAI GPT-4, Google Gemini]
34+
35+
## Minimal Code Example
36+
```python
37+
from langstruct import LangStruct
38+
39+
# Minimal code that reproduces the issue
40+
extractor = LangStruct(example={"name": "John"})
41+
result = extractor.extract("Some text") # This fails
42+
```
43+
44+
## Additional Context
45+
Add any other context about the problem here, such as:
46+
- Does this happen with all models or just specific ones?
47+
- Is this related to a specific type of text/document?
48+
- Any workarounds you've found?
49+
50+
## Checklist
51+
- [ ] I have searched existing issues to make sure this isn't a duplicate
52+
- [ ] I have provided a minimal code example that reproduces the issue
53+
- [ ] I have included the complete error message/stack trace
54+
- [ ] I have specified my environment details
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for LangStruct
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Feature Description
10+
A clear and concise description of what you want to happen.
11+
12+
## Problem/Use Case
13+
What problem does this solve? What use case does this enable?
14+
Example: "I'm trying to extract data from medical records, but I need..."
15+
16+
## Proposed Solution
17+
Describe the solution you'd like to see.
18+
19+
## Example Usage
20+
Show how you would like to use this feature:
21+
22+
```python
23+
from langstruct import LangStruct
24+
25+
# Example of how the new feature would work
26+
extractor = LangStruct(...)
27+
result = extractor.new_method(...)
28+
```
29+
30+
## Alternatives Considered
31+
Describe any alternative solutions or features you've considered.
32+
33+
## Additional Context
34+
Add any other context, mockups, or examples about the feature request here.
35+
36+
## Implementation Ideas
37+
If you have ideas about how this could be implemented, share them here.
38+
39+
## Checklist
40+
- [ ] I have searched existing issues to make sure this isn't a duplicate
41+
- [ ] I have provided a clear use case for this feature
42+
- [ ] I have included example usage code
43+
- [ ] This feature aligns with LangStruct's goals of structured text extraction

.github/pull_request_template.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Description
2+
Brief description of what this PR does and why.
3+
4+
## Changes Made
5+
- [ ] Added feature X
6+
- [ ] Fixed bug Y
7+
- [ ] Updated documentation Z
8+
- [ ] Other: ...
9+
10+
## Type of Change
11+
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
12+
- [ ] ✨ New feature (non-breaking change which adds functionality)
13+
- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] 📝 Documentation update
15+
- [ ] 🎨 Code style/formatting
16+
- [ ] ♻️ Refactoring
17+
- [ ] ⚡ Performance improvement
18+
- [ ] 🧪 Test improvement
19+
20+
## Testing
21+
- [ ] Tests pass locally (`uv run pytest`)
22+
- [ ] Added tests for new functionality
23+
- [ ] Tested on multiple Python versions (if applicable)
24+
- [ ] Tested with different LLM providers (if applicable)
25+
26+
## Code Quality
27+
- [ ] Code follows project style guidelines (`uv run black . && uv run isort .`)
28+
- [ ] Type checking passes (`uv run mypy langstruct/`)
29+
- [ ] Added appropriate docstrings
30+
- [ ] Updated examples if needed
31+
32+
## Documentation
33+
- [ ] Updated README if needed
34+
- [ ] Updated API documentation
35+
- [ ] Added/updated examples
36+
- [ ] Updated CHANGELOG.md
37+
38+
## Checklist
39+
- [ ] My code follows the style guidelines of this project
40+
- [ ] I have performed a self-review of my own code
41+
- [ ] I have commented my code, particularly in hard-to-understand areas
42+
- [ ] I have made corresponding changes to the documentation
43+
- [ ] My changes generate no new warnings
44+
- [ ] I have added tests that prove my fix is effective or that my feature works
45+
- [ ] New and existing unit tests pass locally with my changes
46+
47+
## Related Issues
48+
Closes #(issue number)
49+
50+
## Screenshots (if applicable)
51+
Add screenshots to help explain your changes.
52+
53+
## Additional Notes
54+
Any additional information, concerns, or questions for reviewers.

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Deploy Docs
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
paths: ['docs/**']
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '18'
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v3
23+
with:
24+
version: 9
25+
run_install: false
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
31+
32+
- name: Setup pnpm cache
33+
uses: actions/cache@v4
34+
with:
35+
path: ${{ env.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
39+
40+
- name: Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
working-directory: ./docs
43+
44+
- name: Build docs
45+
run: pnpm run build
46+
working-directory: ./docs
47+
48+
- name: Deploy to Cloudflare Pages
49+
uses: cloudflare/wrangler-action@v3
50+
with:
51+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
52+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
53+
command: pages deploy dist --project-name=langstruct-docs
54+
workingDirectory: ./docs

.github/workflows/lint.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v3
18+
with:
19+
version: "latest"
20+
21+
- name: Set up Python
22+
run: uv python install 3.12
23+
24+
- name: Install dependencies
25+
run: |
26+
uv sync --extra dev
27+
28+
- name: Run black (format check)
29+
run: |
30+
uv run black --check --diff .
31+
32+
- name: Run isort (import sorting check)
33+
run: |
34+
uv run isort --check-only --diff .
35+
36+
- name: Run mypy (type checking)
37+
run: |
38+
uv run mypy langstruct/ || echo "Type checking completed with warnings"
39+
40+
- name: Check for common issues
41+
run: |
42+
# Check for print statements in production code
43+
echo "Checking for print statements in source code..."
44+
if grep -r "print(" langstruct/ --exclude-dir=__pycache__ | grep -v "# debug" | grep -v "# testing"; then
45+
echo "Found print statements in source code. Please use logging instead."
46+
exit 1
47+
fi
48+
49+
# Check for TODO/FIXME that should be issues
50+
echo "Checking for TODO/FIXME comments..."
51+
if grep -r "TODO\|FIXME\|XXX\|HACK" langstruct/ --exclude-dir=__pycache__ | wc -l | grep -v "^0$"; then
52+
echo "Found TODO/FIXME comments. Consider creating GitHub issues for these."
53+
grep -r "TODO\|FIXME\|XXX\|HACK" langstruct/ --exclude-dir=__pycache__ || true
54+
fi

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v3
17+
with:
18+
version: "latest"
19+
20+
- name: Set up Python
21+
run: uv python install 3.12
22+
23+
- name: Install dependencies
24+
run: |
25+
uv sync --extra dev
26+
27+
- name: Run tests
28+
run: |
29+
uv run pytest
30+
31+
- name: Build package
32+
run: |
33+
uv build
34+
35+
- name: Publish to PyPI
36+
env:
37+
TWINE_USERNAME: __token__
38+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
39+
run: |
40+
uv run python -m pip install twine
41+
uv run twine upload dist/*
42+
43+
- name: Create GitHub Release
44+
uses: softprops/action-gh-release@v2
45+
with:
46+
files: dist/*
47+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
python-version: ['3.12']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v3
22+
with:
23+
version: "latest"
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
run: uv python install ${{ matrix.python-version }}
27+
28+
- name: Install dependencies
29+
run: |
30+
uv sync --extra dev
31+
32+
- name: Run tests
33+
run: |
34+
uv run pytest -v --tb=short -k "not integration"
35+
36+
- name: Test examples (Ubuntu only)
37+
if: matrix.os == 'ubuntu-latest'
38+
env:
39+
# Use mock API key for testing examples
40+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY || 'mock-key-for-testing' }}
41+
run: |
42+
# Test that examples can be imported without API calls
43+
uv run python -c "import sys; sys.path.append('examples'); import importlib.util"

0 commit comments

Comments
 (0)