Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ pytest -v
pre-commit run --all-files
```

### 6. Release a new version
```bash
python release.py
```

### 3. Optional: Publish to PyPI
```
python -m build
twine upload dist/*
```

## Quick Checklist

Before pushing your changes, ensure:
Expand Down
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ The following examples are for reference only. Prefer docs for the latest inform

## Installation

Install Langbase SDK:

```bash
pip install langbase
```

Install dotenv:

```bash
pip install dotenv
```

## Quick Start

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

# Initialize the client
langbase = Langbase(api_key=langbase_api_key)
langbase = Langbase(api_key=langbase_api_key)
```

### 3. Generate text
Expand Down Expand Up @@ -188,6 +197,7 @@ results = langbase.memories.retrieve(

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

```python
# Chunk text for processing
chunks = langbase.chunker(
chunks = langbase.chunker(
content="Long text to split...",
chunk_max_length=1024,
chunk_overlap=256,
)

# Generate embeddings
embeddings = langbase.embed(
embeddings = langbase.embed(
chunks=["Text 1", "Text 2"],
embedding_model="openai:text-embedding-3-small",
)

# Parse documents
content = langbase.parser(
content = langbase.parser(
document=open("document.pdf", "rb"),
document_name="document.pdf",
Expand All @@ -224,21 +237,22 @@ content = langbase.parser(

## Examples

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

- [Agent with tools](./examples/agent/)
- [Work with memory](./examples/memory/)
- [Generate text](./examples/pipes/pipes.run.py)
- [Document processing](./examples/parser/)
- [Workflow automation](./examples/workflow/)
- [Generate text](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/agent/agent.run.py)
- [Stream text](https://github.com/LangbaseInc/langbase-python-sdk/blob/main/examples/agent/agent.run.stream.py)
- [Work with memory](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/memory/)
- [Agent with tools](https://github.com/LangbaseInc/langbase-python-sdk/blob/main/examples/agent/agent.run.tool.py)
- [Document processing](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/parser/)
- [Workflow automation](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/examples/workflow/)

## SDK Reference

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

## Contributing

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

## Support

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

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
See the [LICENSE](https://github.com/LangbaseInc/langbase-python-sdk/tree/main/LICENSE) file for details.
4 changes: 2 additions & 2 deletions examples/agent/agent.run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def main():

if not langbase_api_key:
print("❌ Missing LANGBASE_API_KEY in environment variables.")
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
exit(1)

if not llm_api_key:
print("❌ Missing LLM_API_KEY in environment variables.")
print("Please set: export LLM_API_KEY='your_llm_api_key'")
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
exit(1)

# Initialize Langbase client
Expand Down
2 changes: 1 addition & 1 deletion examples/agent/agent.run.stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def main():

if not langbase_api_key:
print("❌ Missing LANGBASE_API_KEY in environment variables.")
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
exit(1)

# Initialize Langbase client
Expand Down
2 changes: 1 addition & 1 deletion examples/agent/agent.run.workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def main():

if not llm_api_key:
print("❌ Missing LLM_API_KEY in environment variables.")
print("Please set: export LLM_API_KEY='your_llm_api_key'")
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
exit(1)

# Initialize Langbase client and Workflow
Expand Down
4 changes: 2 additions & 2 deletions examples/workflow/email_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ async def process_email(email_content: str):

if not langbase_api_key:
print("❌ Missing LANGBASE_API_KEY in environment variables.")
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
exit(1)

if not llm_api_key:
print("❌ Missing LLM_API_KEY in environment variables.")
print("Please set: export LLM_API_KEY='your_llm_api_key'")
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
exit(1)

# Initialize Langbase
Expand Down
4 changes: 2 additions & 2 deletions examples/workflow/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ async def process_text(input_text: str):

if not langbase_api_key:
print("❌ Missing LANGBASE_API_KEY in environment variables.")
print("Please set: export LANGBASE_API_KEY='your_langbase_api_key'")
print("Please set: LANGBASE_API_KEY='your_langbase_api_key' in .env file")
exit(1)

if not llm_api_key:
print("❌ Missing LLM_API_KEY in environment variables.")
print("Please set: export LLM_API_KEY='your_llm_api_key'")
print("Please set: LLM_API_KEY='your_llm_api_key' in .env file")
exit(1)

# Initialize Langbase
Expand Down
5 changes: 4 additions & 1 deletion langbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
)
from .workflow import TimeoutError, Workflow

__version__ = "0.1.0"
__version__ = "0.0.0"
__author__ = "LangbaseInc"
__description__ = "Python SDK for the Langbase API"

__all__ = [
# Errors
"APIConnectionError",
Expand Down
38 changes: 31 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
[project]
name = "langbase"
version = "0.1.0"
version = "0.0.0"
description = "Python SDK for the Langbase API"
readme = "README.md"
license = {text = "MIT"}
license = {text = "Apache-2.0"}
authors = [
{ name = "Saqib", email = "[email protected]" },
{ name = "Ankit", email = "[email protected]" },
{ name = "Saqib Ameen", email = "[email protected]" },
{ name = "Ankit Kumar", email = "[email protected]" },
]
requires-python = ">=3.7"
keywords = ["ai", "langbase", "agent", "memory", "rag", "mcp", "pipes", "workflow"]
keywords = ["ai", "langbase", "agent", "memory", "rag", "mcp", "pipes", "workflow", "llms"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"requests>=2.25.0",
"typing-extensions>=4.0.0",
]

[project.optional-dependencies]
release = [
"python-semantic-release>=8.0.0",
]

[project.urls]
Documentation = "https://docs.langbase.com"
Homepage = "https://langbase.com"
Expand Down Expand Up @@ -102,3 +110,19 @@ precision = 2

[tool.coverage.html]
directory = "htmlcov"

[tool.semantic_release]
version_toml = ["pyproject.toml:project.version"]
version_variables = [
"langbase/__init__.py:__version__",
]
branch = "main"
upload_to_PyPI = false
upload_to_release = false
build_command = "pip install build && python -m build"

[tool.semantic_release.commit_parser_options]
allowed_tags = ["📦 NEW", "👌 IMPROVE", "🐛 FIX", "🚀 RELEASE", "📖 DOC", "🤖 TEST", "‼️ BREAKING"]
minor_tags = ["📦 NEW"]
patch_tags = ["👌 IMPROVE", "🐛 FIX", "🚀 RELEASE"]
major_tags = ["‼️ BREAKING"]
Loading