Skip to content

Commit ab23911

Browse files
committed
🐛 FIX: Formatting
1 parent 0527ad2 commit ab23911

13 files changed

+30
-52
lines changed

examples/agent/agent.run.stream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,26 @@ def main():
3333
model="openai:gpt-4.1-mini",
3434
instructions="You are a helpful assistant that help users summarize text.",
3535
input=[{"role": "user", "content": "Who is an AI Engineer?"}],
36-
api_key=api_key
36+
api_key=api_key,
3737
)
3838

3939
# Convert the stream to a stream runner - equivalent to getRunner(stream)
4040
runner = get_runner(response)
4141

4242
# Event-like handling in Python
4343
# Method 1: Using iterator pattern (Python equivalent of event listeners)
44-
44+
4545
# Equivalent to runner.on('connect', ...)
4646
print("Stream started.\n")
4747

4848
try:
4949
# Equivalent to runner.on('content', content => {...})
5050
for content in runner.text_generator():
5151
print(content, end="", flush=True)
52-
52+
5353
# Equivalent to runner.on('end', ...)
5454
print("\nStream ended.")
55-
55+
5656
except Exception as error:
5757
# Equivalent to runner.on('error', error => {...})
5858
print(f"Error: {error}")

examples/chunker/chunker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Example demonstrating how to chunk text content using Langbase.
33
"""
44

5+
import json
56
import os
67
import pathlib
7-
import json
88

99
from dotenv import load_dotenv
1010

examples/embed/embed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Experimental upcoming beta AI primitve.
22
# Please refer to the documentation for more information: https://langbase.com/docs for more information.
3-
import os
43
import json
4+
import os
5+
56
from dotenv import load_dotenv
67

78
from langbase import Langbase

examples/memory/memory.docs.delete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def main():
2525

2626
# Delete the document
2727
try:
28-
response = lb.memories.documents.delete(memory_name=memory_name, document_name=document_id)
28+
response = lb.memories.documents.delete(
29+
memory_name=memory_name, document_name=document_id
30+
)
2931

3032
print(
3133
f"Document '{document_id}' deleted successfully from memory '{memory_name}'"

examples/memory/memory.docs.list.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def main():
2424

2525
# List documents in the memory
2626
try:
27-
response = lb.memories.documents.list(
28-
memory_name=memory_name
29-
)
27+
response = lb.memories.documents.list(memory_name=memory_name)
3028

3129
print(f"Documents in memory '{memory_name}':")
3230
print(json.dumps(response, indent=2))

examples/memory/memory.docs.retry-embed.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ def main():
2121

2222
# Memory name to retry embedding for
2323
memory_name = "product-knowledge" # Replace with your memory name
24-
document_name="name.txt" # Replace with document name
24+
document_name = "name.txt" # Replace with document name
2525

2626
# Retry embedding for failed documents
2727
try:
28-
response = lb.memories.documents.embeddings.retry(memory_name=memory_name,document_name=document_name)
28+
response = lb.memories.documents.embeddings.retry(
29+
memory_name=memory_name, document_name=document_name
30+
)
2931

3032
print(f"Retry embedding initiated for memory '{memory_name}'")
3133
print(json.dumps(response, indent=2))

examples/memory/memory.docs.upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def main():
2929
response1 = lb.memories.documents.upload(
3030
memory_name=memory_name,
3131
document_name="intro.txt",
32-
document=content1.encode('utf-8'), # Convert string to bytes
32+
document=content1.encode("utf-8"), # Convert string to bytes
3333
content_type="text/plain",
34-
meta={"source": "documentation", "section": "introduction"}
34+
meta={"source": "documentation", "section": "introduction"},
3535
)
3636
print("Document 1 uploaded successfully!")
3737
print(f"Status: {response1.status_code}")

examples/memory/memory.retrieve.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ def main():
2929
try:
3030
response = lb.memories.retrieve(
3131
query=query,
32-
memory=[
33-
{
34-
"name": memory_name
35-
}
36-
],
32+
memory=[{"name": memory_name}],
3733
top_k=5, # Number of relevant memories to retrieve
3834
)
3935

examples/pipes/pipes.create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
"content": "You are a helpful assistant that summarizes text clearly and concisely.",
3131
}
3232
],
33-
upsert=True
33+
upsert=True,
3434
)
3535

3636
print("Pipe created successfully!")

examples/pipes/pipes.run.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@ def main():
2020
# Initialize the client
2121
lb = Langbase(api_key=langbase_api_key)
2222

23-
2423
# Run the pipe with explicit stream=False
2524
try:
2625
response = lb.pipes.run(
27-
name="summary-agent",
28-
messages=[
29-
{
30-
"role": "user",
31-
"content": "Who is an AI Engineer?"
32-
}
33-
],
34-
stream=False
26+
name="summary-agent",
27+
messages=[{"role": "user", "content": "Who is an AI Engineer?"}],
28+
stream=False,
3529
)
3630

3731
# Print the entire response as is

0 commit comments

Comments
 (0)