Skip to content

Commit a479d16

Browse files
authored
Merge pull request #2 from LangbaseInc/ankit/release-python-sdk
📦 NEW: Python Release System
2 parents 58397ed + d16544b commit a479d16

File tree

12 files changed

+424
-24
lines changed

12 files changed

+424
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ pytest -v
8383
pre-commit run --all-files
8484
```
8585
86+
### 6. Release a new version
87+
```bash
88+
python release.py
89+
```
90+
91+
### 3. Optional: Publish to PyPI
92+
```
93+
python -m build
94+
twine upload dist/*
95+
```
96+
8697
## Quick Checklist
8798
8899
Before pushing your changes, ensure:

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ The following examples are for reference only. Prefer docs for the latest inform
2222

2323
## Installation
2424

25+
Install Langbase SDK:
26+
2527
```bash
2628
pip install langbase
2729
```
2830

31+
Install dotenv:
32+
33+
```bash
34+
pip install dotenv
35+
```
36+
2937
## Quick Start
3038

3139
### 1. Set up your API key
@@ -54,6 +62,7 @@ llm_api_key = os.getenv("LLM_API_KEY")
5462

5563
# Initialize the client
5664
langbase = Langbase(api_key=langbase_api_key)
65+
langbase = Langbase(api_key=langbase_api_key)
5766
```
5867

5968
### 3. Generate text
@@ -188,6 +197,7 @@ results = langbase.memories.retrieve(
188197

189198
```python
190199
# Run an agent with tools
200+
response = langbase.agent.run(
191201
response = langbase.agent.run(
192202
model="openai:gpt-4",
193203
messages=[{"role": "user", "content": "Search for AI news"}],
@@ -202,19 +212,22 @@ response = langbase.agent.run(
202212

203213
```python
204214
# Chunk text for processing
215+
chunks = langbase.chunker(
205216
chunks = langbase.chunker(
206217
content="Long text to split...",
207218
chunk_max_length=1024,
208219
chunk_overlap=256,
209220
)
210221

211222
# Generate embeddings
223+
embeddings = langbase.embed(
212224
embeddings = langbase.embed(
213225
chunks=["Text 1", "Text 2"],
214226
embedding_model="openai:text-embedding-3-small",
215227
)
216228

217229
# Parse documents
230+
content = langbase.parser(
218231
content = langbase.parser(
219232
document=open("document.pdf", "rb"),
220233
document_name="document.pdf",
@@ -224,21 +237,22 @@ content = langbase.parser(
224237

225238
## Examples
226239

227-
Explore the [examples](./examples) directory for complete working examples:
240+
Explore the [examples](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples) directory for complete working examples:
228241

229-
- [Agent with tools](./examples/agent/)
230-
- [Work with memory](./examples/memory/)
231-
- [Generate text](./examples/pipes/pipes.run.py)
232-
- [Document processing](./examples/parser/)
233-
- [Workflow automation](./examples/workflow/)
242+
- [Generate text](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/agent/agent.run.py)
243+
- [Stream text](https://github.com/LangbaseInc/langbase-python-sdk/blob/main/examples/agent/agent.run.stream.py)
244+
- [Work with memory](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/memory/)
245+
- [Agent with tools](https://github.com/LangbaseInc/langbase-python-sdk/blob/main/examples/agent/agent.run.tool.py)
246+
- [Document processing](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/parser/)
247+
- [Workflow automation](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/workflow/)
234248

235249
## SDK Reference
236250

237251
For detailed SDK documentation, visit [langbase.com/docs/sdk](https://langbase.com/docs/sdk).
238252

239253
## Contributing
240254

241-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
255+
We welcome contributions! Please see our [Contributing Guide](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/CONTRIBUTING.md) for details.
242256

243257
## Support
244258

@@ -248,4 +262,4 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
248262

249263
## License
250264

251-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
265+
See the [LICENSE](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/LICENSE) file for details.

examples/agent/agent.run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def main():
2020

2121
if not langbase_api_key:
2222
print("❌ Missing LANGBASE_API_KEY in environment variables.")
23-
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
23+
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
2424
exit(1)
2525

2626
if not llm_api_key:
2727
print("❌ Missing LLM_API_KEY in environment variables.")
28-
print("Please set: export LLM_API_KEY='your_llm_api_key'")
28+
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
2929
exit(1)
3030

3131
# Initialize Langbase client

examples/agent/agent.run.stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main():
2020

2121
if not langbase_api_key:
2222
print("❌ Missing LANGBASE_API_KEY in environment variables.")
23-
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
23+
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
2424
exit(1)
2525

2626
# Initialize Langbase client

examples/agent/agent.run.workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def main():
3131

3232
if not llm_api_key:
3333
print("❌ Missing LLM_API_KEY in environment variables.")
34-
print("Please set: export LLM_API_KEY='your_llm_api_key'")
34+
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
3535
exit(1)
3636

3737
# Initialize Langbase client and Workflow

examples/workflow/email_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ async def process_email(email_content: str):
3333

3434
if not langbase_api_key:
3535
print("❌ Missing LANGBASE_API_KEY in environment variables.")
36-
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
36+
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
3737
exit(1)
3838

3939
if not llm_api_key:
4040
print("❌ Missing LLM_API_KEY in environment variables.")
41-
print("Please set: export LLM_API_KEY='your_llm_api_key'")
41+
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
4242
exit(1)
4343

4444
# Initialize Langbase

examples/workflow/summarization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ async def process_text(input_text: str):
3232

3333
if not langbase_api_key:
3434
print("❌ Missing LANGBASE_API_KEY in environment variables.")
35-
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
35+
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
3636
exit(1)
3737

3838
if not llm_api_key:
3939
print("❌ Missing LLM_API_KEY in environment variables.")
40-
print("Please set: export LLM_API_KEY='your_llm_api_key'")
40+
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
4141
exit(1)
4242

4343
# Initialize Langbase

langbase/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
)
6464
from .workflow import TimeoutError, Workflow
6565

66-
__version__ = "0.1.0"
66+
__version__ = "0.0.0"
67+
__author__ = "LangbaseInc"
68+
__description__ = "Python SDK for the Langbase API"
69+
6770
__all__ = [
6871
# Errors
6972
"APIConnectionError",

pyproject.toml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
[project]
22
name = "langbase"
3-
version = "0.1.0"
3+
version = "0.0.0"
44
description = "Python SDK for the Langbase API"
55
readme = "README.md"
6-
license = {text = "MIT"}
6+
license = {text = "Apache-2.0"}
77
authors = [
8-
{ name = "Saqib", email = "[email protected]" },
9-
{ name = "Ankit", email = "[email protected]" },
8+
{ name = "Saqib Ameen", email = "[email protected]" },
9+
{ name = "Ankit Kumar", email = "[email protected]" },
1010
]
1111
requires-python = ">=3.7"
12-
keywords = ["ai", "langbase", "agent", "memory", "rag", "mcp", "pipes", "workflow"]
12+
keywords = ["ai", "langbase", "agent", "memory", "rag", "mcp", "pipes", "workflow", "llms"]
1313
classifiers = [
14-
"Development Status :: 4 - Beta",
1514
"Intended Audience :: Developers",
16-
"License :: OSI Approved :: MIT License",
15+
"License :: OSI Approved :: Apache Software License",
16+
"Operating System :: OS Independent",
17+
"Programming Language :: Python :: 3",
1718
"Programming Language :: Python :: 3.7",
1819
"Programming Language :: Python :: 3.8",
1920
"Programming Language :: Python :: 3.9",
2021
"Programming Language :: Python :: 3.10",
2122
"Programming Language :: Python :: 3.11",
2223
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3 :: Only",
25+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
2326
"Topic :: Software Development :: Libraries :: Python Modules",
2427
]
2528
dependencies = [
2629
"requests>=2.25.0",
2730
"typing-extensions>=4.0.0",
2831
]
2932

33+
[project.optional-dependencies]
34+
release = [
35+
"python-semantic-release>=8.0.0",
36+
]
37+
3038
[project.urls]
3139
Documentation = "https://docs.langbase.com"
3240
Homepage = "https://langbase.com"
@@ -102,3 +110,19 @@ precision = 2
102110

103111
[tool.coverage.html]
104112
directory = "htmlcov"
113+
114+
[tool.semantic_release]
115+
version_toml = ["pyproject.toml:project.version"]
116+
version_variables = [
117+
"langbase/__init__.py:__version__",
118+
]
119+
branch = "main"
120+
upload_to_PyPI = false
121+
upload_to_release = false
122+
build_command = "pip install build && python -m build"
123+
124+
[tool.semantic_release.commit_parser_options]
125+
allowed_tags = ["📦 NEW", "👌 IMPROVE", "🐛 FIX", "🚀 RELEASE", "📖 DOC", "🤖 TEST", "‼️ BREAKING"]
126+
minor_tags = ["📦 NEW"]
127+
patch_tags = ["👌 IMPROVE", "🐛 FIX", "🚀 RELEASE"]
128+
major_tags = ["‼️ BREAKING"]

0 commit comments

Comments
 (0)