@@ -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
2628pip 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
@@ -53,14 +61,14 @@ langbase_api_key = os.getenv("LANGBASE_API_KEY")
5361llm_api_key = os.getenv(" LLM_API_KEY" )
5462
5563# Initialize the client
56- lb = Langbase(api_key = langbase_api_key)
64+ langbase = Langbase(api_key = langbase_api_key)
5765```
5866
5967### 3. Generate text
6068
6169``` python
6270# Simple generation
63- response = lb .agent.run(
71+ response = langbase .agent.run(
6472 input = [{" role" : " user" , " content" : " Tell me about AI" }],
6573 model = " openai:gpt-4.1-mini" ,
6674 api_key = llm_api_key,
@@ -148,10 +156,10 @@ runner.process()
148156
149157``` python
150158# List all pipes
151- pipes = lb .pipes.list()
159+ pipes = langbase .pipes.list()
152160
153161# Run a pipe
154- response = lb .pipes.run(
162+ response = langbase .pipes.run(
155163 name = " ai-agent" ,
156164 messages = [{" role" : " user" , " content" : " Hello!" }],
157165 variables = {" style" : " friendly" }, # Optional variables
@@ -163,21 +171,21 @@ response = lb.pipes.run(
163171
164172``` python
165173# Create a memory
166- memory = lb .memories.create(
174+ memory = langbase .memories.create(
167175 name = " product-docs" ,
168176 description = " Product documentation" ,
169177)
170178
171179# Upload documents
172- lb .memories.documents.upload(
180+ langbase .memories.documents.upload(
173181 memory_name = " product-docs" ,
174182 document_name = " guide.pdf" ,
175183 document = open (" guide.pdf" , " rb" ),
176184 content_type = " application/pdf" ,
177185)
178186
179187# Retrieve relevant context
180- results = lb .memories.retrieve(
188+ results = langbase .memories.retrieve(
181189 query = " How do I get started?" ,
182190 memory = [{" name" : " product-docs" }],
183191 top_k = 3 ,
@@ -188,7 +196,7 @@ results = lb.memories.retrieve(
188196
189197``` python
190198# Run an agent with tools
191- response = lb .agent.run(
199+ response = langbase .agent.run(
192200 model = " openai:gpt-4" ,
193201 messages = [{" role" : " user" , " content" : " Search for AI news" }],
194202 tools = [{" type" : " function" , " function" : {... }}],
@@ -202,20 +210,20 @@ response = lb.agent.run(
202210
203211``` python
204212# Chunk text for processing
205- chunks = lb .chunker(
213+ chunks = langbase .chunker(
206214 content = " Long text to split..." ,
207215 chunk_max_length = 1024 ,
208216 chunk_overlap = 256 ,
209217)
210218
211219# Generate embeddings
212- embeddings = lb .embed(
220+ embeddings = langbase .embed(
213221 chunks = [" Text 1" , " Text 2" ],
214222 embedding_model = " openai:text-embedding-3-small" ,
215223)
216224
217225# Parse documents
218- content = lb .parser(
226+ content = langbase .parser(
219227 document = open (" document.pdf" , " rb" ),
220228 document_name = " document.pdf" ,
221229 content_type = " application/pdf" ,
@@ -224,22 +232,22 @@ content = lb.parser(
224232
225233## Examples
226234
227- Explore the [ examples] ( . /examples) directory for complete working examples:
235+ Explore the [ examples] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main /examples) directory for complete working examples:
228236
229- - [ Generate text] ( ./ examples/pipes/pipes .run.py)
230- - [ Stream text with events ] ( ./ examples/pipes/pipes .run.typed- stream.py)
231- - [ Work with memory] ( . /examples/memory/)
232- - [ Agent with tools] ( ./ examples/agent/)
233- - [ Document processing] ( . /examples/parser/)
234- - [ Workflow automation] ( . /examples/workflow/)
237+ - [ Generate text] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main/ examples/agent/agent .run.py)
238+ - [ Stream text] ( https://github.com/LangbaseInc/langbase-python-sdk/blob/main/ examples/agent/agent .run.stream.py)
239+ - [ Work with memory] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main /examples/memory/)
240+ - [ Agent with tools] ( https://github.com/LangbaseInc/langbase-python-sdk/blob/main/ examples/agent/agent.run.tool.py )
241+ - [ Document processing] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main /examples/parser/)
242+ - [ Workflow automation] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main /examples/workflow/)
235243
236244## SDK Reference
237245
238246For detailed SDK documentation, visit [ langbase.com/docs/sdk] ( https://langbase.com/docs/sdk ) .
239247
240248## Contributing
241249
242- We welcome contributions! Please see our [ Contributing Guide] ( CONTRIBUTING.md ) for details.
250+ We welcome contributions! Please see our [ Contributing Guide] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main/ CONTRIBUTING.md) for details.
243251
244252## Support
245253
@@ -249,4 +257,4 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
249257
250258## License
251259
252- This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
260+ See the [ LICENSE] ( https://github.com/LangbaseInc/langbase-python-sdk/tree/main/ LICENSE) file for details.
0 commit comments