Comparing version 0.2.3 to 0.2.4
{ | ||
"name": "langbase", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -29,5 +29,5 @@ # Langbase SDK | ||
You can `generateText` or `streamText` based on the type of a pipe. | ||
You can [`generateText`](https://langbase.com/docs/langbase-sdk/generate-text) or [`streamText`](https://langbase.com/docs/langbase-sdk/stream-text) based on the type of a pipe. | ||
Check our [SDK documentation](https://langbase.com/docs) for more details. | ||
Check our [SDK documentation](https://langbase.com/docs/langbase-sdk/overview) for more details. | ||
@@ -37,2 +37,3 @@ ### Example projects | ||
Check the following examples: | ||
- [Node: Generate Text](https://github.com/LangbaseInc/langbase-sdk/blob/main/examples/everything/generate-text.ts) | ||
@@ -45,11 +46,24 @@ - [Node: Stream Text](https://github.com/LangbaseInc/langbase-sdk/blob/main/examples/everything/stream-text.ts) | ||
### Demo code: | ||
### Node.js Example Code | ||
```TypeScript | ||
## Node.js Examples | ||
### Add a `.env` file with your Pipe API key | ||
```bash | ||
# Add your Pipe API key here. | ||
LANGBASE_PIPE_API_KEY="pipe_12345`" | ||
``` | ||
--- | ||
### Generate text [`generateText()`](https://langbase.com/docs/langbase-sdk/generate-text) | ||
For more check the API reference of [`generateText()`](https://langbase.com/docs/langbase-sdk/generate-text) | ||
```ts | ||
import 'dotenv/config'; | ||
import {Pipe} from 'langbase'; | ||
// STREAM: OFF | ||
console.log('STREAM-OFF: generateText()'); | ||
// 1. Initiate the Pipe. | ||
@@ -59,3 +73,3 @@ const pipe = new Pipe({ | ||
// As a demo we're using a pipe that has less wordy responses. | ||
apiKey: process.env.PIPE_LESS_WORDY!, | ||
apiKey: process.env.LANGBASE_PIPE_API_KEY!, | ||
}); | ||
@@ -70,9 +84,21 @@ | ||
console.log(result.completion); | ||
``` | ||
// ======= OR ======== // | ||
--- | ||
// STREAM: ON | ||
console.log(''); | ||
console.log('STREAM-ON: streamText()'); | ||
### Stream text [`streamText()`](https://langbase.com/docs/langbase-sdk/stream-text) | ||
For more check the API reference of [`streamText()`](https://langbase.com/docs/langbase-sdk/stream-text) | ||
```ts | ||
import 'dotenv/config'; | ||
import {Pipe} from 'langbase'; | ||
// 1. Initiate the Pipe. | ||
const pipe = new Pipe({ | ||
// Make sure you have a .env file with any pipe you wanna use. | ||
// As a demo we're using a pipe that has less wordy responses. | ||
apiKey: process.env.LANGBASE_PIPE_API_KEY!, | ||
}); | ||
// 2. Generate a stream by asking a question | ||
@@ -92,1 +118,3 @@ const stream = await pipe.streamText({ | ||
``` | ||
Check out [more examples in the docs](https://langbase.com/docs/langbase-sdk/examples) → |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122569
115