Skip to content

Commit c0d697d

Browse files
committed
👌 IMPROVE: Primitives
1 parent 54c9f7d commit c0d697d

Some content is hidden

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

47 files changed

+1456
-1121
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,3 @@ repos:
2424
hooks:
2525
- id: isort
2626
args: [--profile=black, --line-length=88]
27-
28-
- repo: https://github.com/astral-sh/ruff-pre-commit
29-
rev: v0.1.9
30-
hooks:
31-
- id: ruff
32-
args: [--fix]
33-
34-
- repo: https://github.com/pre-commit/mirrors-mypy
35-
rev: v1.8.0
36-
hooks:
37-
- id: mypy
38-
args: [--strict, --ignore-missing-imports]
39-
additional_dependencies: [types-requests>=2.28.0]
40-
exclude: ^(tests/|examples/)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,16 @@ response = lb.pipes.run(
9898
runner = get_typed_runner(response)
9999

100100
# Register event handlers
101-
runner.on(StreamEventType.CONNECT, lambda e:
101+
runner.on(StreamEventType.CONNECT, lambda e:
102102
print(f"✓ Connected to thread: {e['threadId']}"))
103103

104-
runner.on(StreamEventType.CONTENT, lambda e:
104+
runner.on(StreamEventType.CONTENT, lambda e:
105105
print(e["content"], end="", flush=True))
106106

107-
runner.on(StreamEventType.TOOL_CALL, lambda e:
107+
runner.on(StreamEventType.TOOL_CALL, lambda e:
108108
print(f"\n🔧 Tool: {e['toolCall']['function']['name']}"))
109109

110-
runner.on(StreamEventType.END, lambda e:
110+
runner.on(StreamEventType.END, lambda e:
111111
print(f"\n⏱️ Duration: {e['duration']:.2f}s"))
112112

113113
# Process the stream
@@ -160,7 +160,7 @@ results = lb.memories.retrieve(
160160

161161
```python
162162
# Run an agent with tools
163-
response = lb.agent_run(
163+
response = lb.agent.run(
164164
model="openai:gpt-4",
165165
messages=[{"role": "user", "content": "Search for AI news"}],
166166
tools=[{"type": "function", "function": {...}}],

examples/agent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ langbase = Langbase(api_key=os.environ.get("LANGBASE_API_KEY"))
140140
Basic agent run pattern:
141141

142142
```python
143-
response = langbase.agent_run(
143+
response = langbase.agent.run(
144144
model="openai:gpt-4.1-mini",
145145
api_key=os.environ.get("LLM_API_KEY"),
146146
instructions="Your instructions here",
@@ -184,4 +184,4 @@ logging.basicConfig(level=logging.DEBUG)
184184
- Explore the [Langbase Documentation](https://docs.langbase.com)
185185
- Try creating your own custom tools
186186
- Experiment with different models and parameters
187-
- Build multi-agent workflows
187+
- Build multi-agent workflows

examples/agent/agent.run.mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
langbase = Langbase(api_key=langbase_api_key)
3131

3232
# Run the agent with MCP server
33-
response = langbase.agent_run(
33+
response = langbase.agent.run(
3434
stream=False,
3535
model="openai:gpt-4.1-mini",
3636
api_key=llm_api_key,

examples/agent/agent.run.memory.py

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

4141
# Step 2: Run the agent with the retrieved memory
42-
response = langbase.agent_run(
42+
response = langbase.agent.run(
4343
model="openai:gpt-4.1",
4444
api_key=llm_api_key,
4545
instructions="You are a career advisor who helps users understand AI job roles.",

examples/agent/agent.run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main():
3232
langbase = Langbase(api_key=langbase_api_key)
3333

3434
# Run the agent
35-
response = langbase.agent_run(
35+
response = langbase.agent.run(
3636
stream=False,
3737
model="openai:gpt-4.1-mini",
3838
api_key=llm_api_key,

examples/agent/agent.run.stream.py

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

2929
try:
3030
# Get readable stream - equivalent to const {stream} = await langbase.agent.run(...)
31-
response = langbase.agent_run(
31+
response = langbase.agent.run(
3232
stream=True,
3333
model="openai:gpt-4.1-mini",
3434
instructions="You are a helpful assistant that help users summarize text.",

examples/agent/agent.run.structured.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main():
5151
}
5252

5353
# Run the agent with structured output
54-
response = langbase.agent_run(
54+
response = langbase.agent.run(
5555
model="openai:gpt-4.1",
5656
api_key=llm_api_key,
5757
instructions="You are a helpful math tutor. Guide the user through the solution step by step.",

examples/agent/agent.run.tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def send_email(args):
4949
response = requests.post(
5050
"https://api.resend.com/emails",
5151
headers={
52-
"Authorization": f'Bearer {os.environ.get("RESEND_API_KEY")}',
52+
"Authorization": f"Bearer {os.environ.get('RESEND_API_KEY')}",
5353
"Content-Type": "application/json",
5454
},
5555
json={
@@ -99,7 +99,7 @@ def main():
9999
input_messages = [{"role": "user", "content": "Send a welcome email to Sam."}]
100100

101101
# Initial run with tool
102-
response = langbase.agent_run(
102+
response = langbase.agent.run(
103103
model="openai:gpt-4.1-mini",
104104
api_key=llm_api_key,
105105
instructions="You are an email sending assistant.",
@@ -159,7 +159,7 @@ def main():
159159
continue
160160

161161
# Final agent response with tool result
162-
final_response = langbase.agent_run(
162+
final_response = langbase.agent.run(
163163
model="openai:gpt-4.1-mini",
164164
api_key=os.environ.get("OPENAI_API_KEY"),
165165
instructions="You are an email sending assistant. Confirm the email has been sent successfully.",

examples/agent/agent.run.workflow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ async def flaky_operation():
9696
],
9797
)
9898
return response["completion"]
99-
else:
100-
raise Exception("Temporary service unavailable")
99+
raise Exception("Temporary service unavailable")
101100

102101
try:
103102
analysis = await workflow.step(

0 commit comments

Comments
 (0)