Skip to content

Commit 05be989

Browse files
committed
📦 NEW: Example
1 parent 19a7ae0 commit 05be989

File tree

8 files changed

+164
-28
lines changed

8 files changed

+164
-28
lines changed

examples/everything/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Pipes.
2+
PIPE_LESS_WORDY=""
3+
PIPE_LESS_WORDY_STREAM=""

examples/everything/.gitignore

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# NPM #
2+
##########
3+
# Ignore all directories called node_modules in current folder and any subfolders.
4+
node_modules/
5+
/node_modules/
6+
7+
# Packages #
8+
############
9+
*.7z
10+
*.dmg
11+
*.gz
12+
*.bz2
13+
*.iso
14+
*.jar
15+
*.rar
16+
*.tar
17+
*.zip
18+
*.tgz
19+
*.map
20+
21+
# Logs and databases #
22+
######################
23+
*.log
24+
*.sql
25+
*.env
26+
27+
# OS generated files #
28+
######################
29+
**.DS_Store*
30+
ehthumbs.db
31+
Icon?
32+
Thumbs.db
33+
._*
34+
**settings.dat*
35+
36+
# Vim generated files #
37+
######################
38+
*.un~
39+
40+
# SASS #
41+
##########
42+
**/.sass-cache
43+
**/.sass-cache/*
44+
**/.map
45+
46+
# Composer #
47+
##########
48+
!assets/js/vendor/
49+
wpcs/
50+
/vendor/
51+
52+
# Bower #
53+
##########
54+
assets/bower_components/*
55+
56+
# Codekit #
57+
##########
58+
/codekit-config.json
59+
*.codekit
60+
**.codekit-cache/*
61+
62+
# Compiled Files and Build Dirs #
63+
##########
64+
/README.html
65+
66+
# PhpStrom Project Files #
67+
.idea/
68+
library/vendors/composer
69+
assets/img/.DS_Store
70+
71+
# VSCode related files #
72+
# .vscode
73+
74+
# Next.js
75+
.next

examples/everything/.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"bracketSpacing": false,
3+
"trailingComma": "all",
4+
"arrowParens": "avoid",
5+
"singleQuote": true,
6+
"printWidth": 80,
7+
"useTabs": true,
8+
"tabWidth": 4,
9+
"semi": true
10+
}

examples/everything/index.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'dotenv/config';
2+
import {Pipe} from 'langbase';
3+
4+
// STREAM: OFF
5+
const pipeStreamOff = new Pipe({
6+
apiKey: process.env.PIPE_LESS_WORDY!,
7+
});
8+
9+
const result = await pipeStreamOff.generateText({
10+
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
11+
});
12+
13+
console.log('STEAM-OFF');
14+
console.log(result.completion);
15+
16+
// STREAM: ON
17+
const pipeStreaming = new Pipe({
18+
apiKey: process.env.PIPE_LESS_WORDY_STREAM!,
19+
});
20+
21+
const stream = await pipeStreaming.streamText({
22+
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
23+
});
24+
25+
console.log('\n');
26+
console.log('STEAM-ON');
27+
for await (const chunk of stream) {
28+
process.stdout.write(chunk.choices[0]?.delta?.content || '');
29+
}

examples/everything/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "everything",
3+
"version": "0.0.1",
4+
"description": "Everything example",
5+
"type": "module",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "npx tsx index.ts"
9+
},
10+
"keywords": [],
11+
"author": "Ahmad Awais <[email protected]> (https://twitter.com/MrAhmadAwais)",
12+
"license": "UNLICENSED",
13+
"dependencies": {
14+
"dotenv": "^16.4.5",
15+
"langbase": "^0.0.0"
16+
}
17+
}

examples/everything/readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Everything Example
2+
3+
Here's a kitchen sink example that does everything.
4+
5+
```sh
6+
# Make sure to copy .env.example file and create .env file with all the keys in it
7+
cp .env.example .env
8+
9+
# Then test.
10+
npm test
11+
```

packages/langbase/src/pipes/prod.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)