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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ yarn add langbase

### Usage

You can [`langbase.pipe.run()`](https://langbase.com/docs/sdk/pipe/run) to generate or stream from a Pipe.
You can [`langbase.pipes.run()`](https://langbase.com/docs/sdk/pipe/run) to generate or stream from a Pipe.

Check our [SDK documentation](https://langbase.com/docs/sdk) for more details.

Expand Down Expand Up @@ -60,9 +60,9 @@ LANGBASE_API_KEY="your-api-key"

---

### Generate text [`langbase.pipe.run()`](https://langbase.com/docs/sdk/pipe/run)
### Generate text [`langbase.pipes.run()`](https://langbase.com/docs/sdk/pipe/run)

Set the `stream` to `false`. For more, check the API reference of [`langbase.pipe.run()`](https://langbase.com/docs/langbase-sdk/generate-text)
Set the `stream` to `false`. For more, check the API reference of [`langbase.pipes.run()`](https://langbase.com/docs/langbase-sdk/generate-text)

```ts
import 'dotenv/config';
Expand All @@ -76,7 +76,7 @@ const langbase = new Langbase({

async function main() {
// 2. Run the pipe with a question.
const response = await langbase.pipe.run({
const response = await langbase.pipes.run({
stream: false,
name: 'summary' // pipe name to run
messages: [
Expand All @@ -96,9 +96,9 @@ main();

---

### Stream text [`langbase.pipe.run()`](https://langbase.com/docs/sdk/pipe/run)
### Stream text [`langbase.pipes.run()`](https://langbase.com/docs/sdk/pipe/run)

Set the `stream` to `true`. For more, check the API reference of [`langbase.pipe.run()`](https://langbase.com/docs/langbase-sdk/generate-text)
Set the `stream` to `true`. For more, check the API reference of [`langbase.pipes.run()`](https://langbase.com/docs/langbase-sdk/generate-text)

```ts
import 'dotenv/config';
Expand All @@ -114,7 +114,7 @@ async function main() {
const userMsg = 'Who is an AI Engineer?';

// 2. Run the pipe with a question.
const {****stre**am**} = await langbase.pipe.run({
const {stream} = await langbase.pipes.run({
stream: true,
name: 'summary', // pipe name to run
messages: [{role: 'user', content: userMsg}],
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/app/langbase/pipe/run-stream/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function POST(req: NextRequest) {
});

// 2. Generate a stream by asking a question
const {stream, threadId} = await langbase.pipe.run({
const {stream, threadId} = await langbase.pipes.run({
messages: options.messages,
stream: true,
name: 'summary',
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/app/langbase/pipe/run/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function POST(req: NextRequest) {
});

// 2. Generate a stream by asking a question
const result = await langbase.pipe.run({
const result = await langbase.pipes.run({
messages: [{role: 'user', content: prompt}],
name: 'summary',
stream: false
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/agents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async function Route(request, env) {
apiKey: 'API_KEY',
});

const pipes = await langbase.pipe.list();
const pipes = await langbase.pipes.list();

// User code will be injected here
return new Response(JSON.stringify(pipes), {status: 200});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/agents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async function Route(request, env) {
apiKey: 'API_KEY',
});

const pipes = await langbase.pipe.list();
const pipes = await langbase.pipes.list();

// User code will be injected here
return new Response(JSON.stringify(pipes), {status: 200});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/agents/summarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async function Route(request, env) {
apiKey: 'API_KEY',
});

const pipes = await langbase.pipe.list();
const pipes = await langbase.pipes.list();

// User code will be injected here
return new Response(JSON.stringify(pipes), {status: 200});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.create({
const response = await langbase.memories.create({
name: 'memory-sdk',
embedding_model: 'cohere:embed-multilingual-v3.0'
});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.delete({
const response = await langbase.memories.delete({
name: 'memory-sdk',
});

Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.docs.delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.documents.delete({
const response = await langbase.memories.documents.delete({
memoryName: 'memory-sdk',
documentName: 'readme.md',
});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.docs.list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.documents.list({
const response = await langbase.memories.documents.list({
memoryName: 'memory-sdk',
});

Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.docs.retry-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.documents.embedding.retry({
const response = await langbase.memories.documents.embeddings.retry({
memoryName: 'memory-sdk',
documentName: 'memory.upload.doc.ts',
});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.docs.upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function main() {
'memory.docs.upload.ts',
);

const response = await langbase.memory.documents.upload({
const response = await langbase.memories.documents.upload({
document: fs.readFileSync(src),
memoryName: 'memory-sdk',
documentName: 'memory.docs.upload.ts',
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.list();
const response = await langbase.memories.list();
console.log(response);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/memory/memory.retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.memory.retrieve({
const response = await langbase.memories.retrieve({
memory: [
{
name: 'langbase-docs',
Expand Down
4 changes: 2 additions & 2 deletions examples/nodejs/examples/pipes/multi-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const langbase = new Langbase({
async function main() {
// First agent: Summarize text
const summarizeAgent = async (text: string) => {
const response = await langbase.pipe.run({
const response = await langbase.pipes.run({
stream: false,
name: "summarize",
messages: [
Expand All @@ -31,7 +31,7 @@ async function main() {

// Second agent: Generate questions
const questionsAgent = async (summary: string) => {
const response = await langbase.pipe.run({
const response = await langbase.pipes.run({
stream: false,
name: "generate-questions",
messages: [
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.pipe.create({
const response = await langbase.pipes.create({
name: 'summary-pipe2',
status: 'private',
});
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.pipe.list();
const response = await langbase.pipes.list();
console.log(response);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/nodejs/examples/pipes/pipe.run.chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const langbase = new Langbase({

async function main() {
// Message 1: Tell something to the LLM.
const response1 = await langbase.pipe.run({
const response1 = await langbase.pipes.run({
name: 'summary',
messages: [{role: 'user', content: 'My company is called Langbase'}],
});
Expand All @@ -17,7 +17,7 @@ async function main() {
// Message 2: Ask something about the first message.
// Continue the conversation in the same thread by sending
// `threadId` from the second message onwards.
const response2 = await langbase.pipe.run({
const response2 = await langbase.pipes.run({
name: 'summary',
threadId: response1.threadId!,
messages: [{role: 'user', content: 'Tell me the name of my company?'}],
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.run.pipe.key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function main() {
const userMsg = 'Who is an AI Engineer?';

// Get readable stream
const {stream, threadId, rawResponse} = await langbase.pipe.run({
const {stream, threadId, rawResponse} = await langbase.pipes.run({
messages: [{role: 'user', content: userMsg}],
stream: true,
rawResponse: true,
Expand Down
4 changes: 2 additions & 2 deletions examples/nodejs/examples/pipes/pipe.run.stream.chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

// Message 1: Tell something to the LLM.
const response1 = await langbase.pipe.run({
const response1 = await langbase.pipes.run({
name: 'summary',
stream: true,
messages: [{role: 'user', content: 'My company is called Langbase'}],
Expand All @@ -21,7 +21,7 @@ runner1.on('content', content => {
// Message 2: Ask something about the first message.
// Continue the conversation in the same thread by sending
// `threadId` from the second message onwards.
const response2 = await langbase.pipe.run({
const response2 = await langbase.pipes.run({
name: 'summary',
stream: true,
threadId: response1.threadId!,
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.run.stream.llmkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function main() {
const userMsg = 'Who is an AI Engineer?';

// Get readable stream
const {stream, threadId, rawResponse} = await langbase.pipe.run({
const {stream, threadId, rawResponse} = await langbase.pipes.run({
messages: [{role: 'user', content: userMsg}],
stream: true,
rawResponse: true,
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.run.stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function main() {
const userMsg = 'Who is an AI Engineer?';

// Get readable stream
const {stream, threadId, rawResponse} = await langbase.pipe.run({
const {stream, threadId, rawResponse} = await langbase.pipes.run({
messages: [{role: 'user', content: userMsg}],
stream: true,
rawResponse: true,
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const langbase = new Langbase({
async function main() {
const userMsg = 'Who is an AI Engineer?';

const response = await langbase.pipe.run({
const response = await langbase.pipes.run({
messages: [
{
role: 'user',
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.tool.stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const langbase = new Langbase({
async function main() {
const userMsg = "What's the weather in SF";

const response = await langbase.pipe.run({
const response = await langbase.pipes.run({
messages: [
{
role: 'user',
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const langbase = new Langbase({
async function main() {
const userMsg = "What's the weather in SF";

const response = await langbase.pipe.run({
const response = await langbase.pipes.run({
messages: [
{
role: 'user',
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const langbase = new Langbase({
});

async function main() {
const response = await langbase.pipe.update({
const response = await langbase.pipes.update({
name: 'summary-pipe',
description: 'This is a pipe updated with the SDK',
model: 'google:gemini-1.5-flash-8b-latest',
Expand Down
22 changes: 0 additions & 22 deletions examples/nodejs/examples/threads/thread.delete.ts

This file was deleted.

26 changes: 0 additions & 26 deletions examples/nodejs/examples/threads/thread.messages.add.ts

This file was deleted.

22 changes: 0 additions & 22 deletions examples/nodejs/examples/threads/thread.messages.list.ts

This file was deleted.

6 changes: 3 additions & 3 deletions examples/nodejs/examples/tools/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const langbase = new Langbase({
* @link https://spider.cloud/docs/quickstart
*/
async function main() {
const results = await langbase.tool.crawl({
const results = await langbase.tools.crawl({
url: ['https://langbase.com', 'https://langbase.com/about'],
max_pages: 1,
api_key: process.env.CRAWL_KEY,
maxPages: 1,
apiKey: process.env.CRAWL_KEY,
});

console.log(results);
Expand Down
2 changes: 1 addition & 1 deletion examples/nodejs/examples/tools/web-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const langbase = new Langbase({
});

async function main() {
const results = await langbase.tool.webSearch({
const results = await langbase.tools.webSearch({
service: 'exa',
totalResults: 2,
query: 'What is Langbase?',
Expand Down
Loading
Loading