Skip to content

Commit a82e5e6

Browse files
authored
Merge pull request #1 from LangbaseInc/ankit/python-sdk
📦 NEW: Python SDK
2 parents 63707a9 + bfeedbd commit a82e5e6

File tree

92 files changed

+7744
-2910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7744
-2910
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Bug report
2+
description: Report a bug for Langbase.
3+
labels: []
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
This template is to report bugs for the Langbase. If you need help with your own project, feel free to [start a new thread in our discord forum](https://langbase.com/discord).
9+
- type: textarea
10+
attributes:
11+
label: Description
12+
description: A detailed bug description for Langbase and steps to reproduce it. Include the API, framework, and AI provider you're using.
13+
placeholder: |
14+
Steps to reproduce...
15+
validations:
16+
required: true
17+
- type: textarea
18+
attributes:
19+
label: Code example
20+
description: Provide an example code snippet that may have a problem
21+
placeholder: |
22+
...
23+
- type: textarea
24+
attributes:
25+
label: Additional context
26+
description: |
27+
Any additional information that might help us investigate.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Feature Request
2+
description: Propose a new feature for Langbase.
3+
labels: []
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Use this template to propose new features for Langbase. If you need help with your own project, feel free to [start a new thread in our discord forum](https://langbase.com/discord).
9+
- type: textarea
10+
attributes:
11+
label: Feature Description
12+
description: Describe the feature you are proposing. Include the API, framework, and AI provider.
13+
placeholder: Feature description...
14+
validations:
15+
required: true
16+
- type: textarea
17+
attributes:
18+
label: Use Case
19+
description: Explain how this feature would be beneficial.
20+
placeholder: Use case...
21+
- type: textarea
22+
attributes:
23+
label: Additional Context
24+
description: Any additional information that might help us understand your request.
25+
placeholder: Additional context...

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Ask a Question
4+
url: https://langbase.com/discord
5+
about: Please ask your questions in our discord forum.

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## TLDR
2+
3+
<!-- Add a brief description of what this pull request changes and why and any important things for reviewers to look at -->
4+
5+
## Dive Deeper
6+
7+
<!-- more thoughts and in depth discussion here -->

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.x'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -r requirements-dev.txt
24+
25+
- name: Run tests
26+
run: |
27+
pytest

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-json
10+
- id: check-merge-conflict
11+
- id: check-toml
12+
- id: debug-statements
13+
- id: mixed-line-ending
14+
15+
- repo: https://github.com/psf/black
16+
rev: 23.12.1
17+
hooks:
18+
- id: black
19+
language_version: python3
20+
args: [.]
21+
22+
- repo: https://github.com/pycqa/isort
23+
rev: 5.13.2
24+
hooks:
25+
- id: isort
26+
args: [--profile=black, --line-length=88]

CONTRIBUTING.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Contributing to Langbase Python SDK
2+
3+
Thank you for your interest in contributing to the Langbase Python SDK! We welcome contributions from the community.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
- Python 3.7 or higher
10+
- pip package manager
11+
- git
12+
13+
### Development Setup
14+
15+
1. **Fork and clone the repository**
16+
```bash
17+
git clone https://github.com/langbase/langbase-python-sdk
18+
cd langbase-python-sdk
19+
```
20+
21+
2. **Create a virtual environment**
22+
```bash
23+
python3 -m venv .venv
24+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
25+
```
26+
### Note:
27+
Check version of pip
28+
```bash
29+
pip --version
30+
```
31+
**If it's pip 21.3 or lower, you need to upgrade it.**
32+
```bash
33+
pip install --upgrade pip
34+
```
35+
36+
3. **Install the package in development mode**
37+
```bash
38+
pip install -e .
39+
```
40+
41+
4. **Install development dependencies**
42+
```bash
43+
pip install -r requirements-dev.txt
44+
```
45+
46+
5. **Install pre-commit hooks**
47+
```bash
48+
pre-commit install
49+
```
50+
51+
## Before You Commit
52+
53+
**IMPORTANT**: All code must pass quality checks before committing. Run these commands:
54+
55+
### Format Your Code
56+
```bash
57+
# Auto-format with Black (required)
58+
black langbase/ tests/ examples/
59+
60+
# Sort imports with isort (required)
61+
isort langbase/ tests/ examples/
62+
```
63+
64+
65+
### 4. Run Tests
66+
```bash
67+
# Run all tests
68+
pytest
69+
70+
# Run with coverage
71+
pytest --cov=langbase
72+
73+
# Run specific test file
74+
pytest tests/test_pipes.py
75+
76+
# Run in verbose mode
77+
pytest -v
78+
```
79+
80+
### 5. Run All Checks at Once
81+
```bash
82+
# This runs all pre-commit hooks (black, isort)
83+
pre-commit run --all-files
84+
```
85+
86+
## Quick Checklist
87+
88+
Before pushing your changes, ensure:
89+
90+
- [ ] ✅ Code is formatted with `black`
91+
- [ ] ✅ Imports are sorted with `isort`
92+
- [ ] ✅ All tests pass with `pytest`
93+
- [ ] ✅ New features have tests
94+
- [ ] ✅ New features have type hints
95+
- [ ] ✅ Documentation is updated if needed
96+
97+
## Making Changes
98+
99+
### 1. Create a Feature Branch
100+
```bash
101+
git checkout -b feature/your-feature-name
102+
```
103+
104+
### 2. Make Your Changes
105+
- Write clean, readable code
106+
- Add type hints to all functions
107+
- Follow existing code patterns
108+
- Add docstrings to public functions
109+
110+
### 3. Add Tests
111+
- Write tests for new features
112+
- Ensure existing tests still pass
113+
- Aim for good test coverage
114+
115+
### 4. Update Documentation
116+
- Update README.md if adding new features
117+
- Update docstrings
118+
- Add examples if applicable
119+
120+
### 5. Commit Your Changes
121+
```bash
122+
# Stage your changes
123+
git add .
124+
125+
# Commit with a descriptive message
126+
git commit -m "📖 DOC: Improved contribution docs"
127+
```
128+
129+
Follow conventional commit format:
130+
- `📦 NEW:` New feature
131+
- `🐛 BUG:` Bug fix
132+
- `📖 Docs:` Documentation changes
133+
- `👌🏻 IMP:` Improvements
134+
135+
### 6. Push and Create PR
136+
```bash
137+
git push origin feature/your-feature-name
138+
```
139+
140+
Then create a Pull Request on GitHub.
141+
142+
## Code Style Guide
143+
144+
### Type Hints
145+
All functions should have type hints:
146+
```python
147+
def process_data(input_text: str, max_length: int = 100) -> Dict[str, Any]:
148+
"""Process input text and return results."""
149+
...
150+
```
151+
152+
### Docstrings
153+
Use Google-style docstrings:
154+
```python
155+
def my_function(param1: str, param2: int) -> bool:
156+
"""
157+
Brief description of function.
158+
159+
Args:
160+
param1: Description of param1
161+
param2: Description of param2
162+
163+
Returns:
164+
Description of return value
165+
...
166+
```
167+
168+
169+
## Testing Guidelines
170+
171+
### Writing Tests
172+
- Use pytest for all tests
173+
- Use descriptive test names
174+
- Test both success and error cases
175+
- Use fixtures for common setup
176+
177+
Example:
178+
```python
179+
def test_pipe_run_with_invalid_name_raises_error(langbase_client):
180+
"""Test that running a pipe with invalid name raises appropriate error."""
181+
with pytest.raises(NotFoundError) as exc_info:
182+
langbase_client.pipes.run(name="non-existent-pipe")
183+
184+
assert "404" in str(exc_info.value)
185+
```
186+
187+
## Need Help?
188+
189+
- Check existing issues and PRs
190+
- Read the [documentation](https://langbase.com/docs)
191+
- Ask in our [Discord community](https://discord.gg/langbase)
192+
- Open an issue for bugs or feature requests
193+
194+
## License
195+
196+
By contributing, you agree that your contributions will be licensed under the MIT License.

LICENCE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2023 Langbase, Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

0 commit comments

Comments
 (0)