Skip to content

Commit

Permalink
📦 NEW: Example
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Jul 24, 2024
1 parent 19a7ae0 commit 05be989
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 28 deletions.
3 changes: 3 additions & 0 deletions examples/everything/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pipes.
PIPE_LESS_WORDY=""
PIPE_LESS_WORDY_STREAM=""
75 changes: 75 additions & 0 deletions examples/everything/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# NPM #
##########
# Ignore all directories called node_modules in current folder and any subfolders.
node_modules/
/node_modules/

# Packages #
############
*.7z
*.dmg
*.gz
*.bz2
*.iso
*.jar
*.rar
*.tar
*.zip
*.tgz
*.map

# Logs and databases #
######################
*.log
*.sql
*.env

# OS generated files #
######################
**.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
._*
**settings.dat*

# Vim generated files #
######################
*.un~

# SASS #
##########
**/.sass-cache
**/.sass-cache/*
**/.map

# Composer #
##########
!assets/js/vendor/
wpcs/
/vendor/

# Bower #
##########
assets/bower_components/*

# Codekit #
##########
/codekit-config.json
*.codekit
**.codekit-cache/*

# Compiled Files and Build Dirs #
##########
/README.html

# PhpStrom Project Files #
.idea/
library/vendors/composer
assets/img/.DS_Store

# VSCode related files #
# .vscode

# Next.js
.next
10 changes: 10 additions & 0 deletions examples/everything/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": false,
"trailingComma": "all",
"arrowParens": "avoid",
"singleQuote": true,
"printWidth": 80,
"useTabs": true,
"tabWidth": 4,
"semi": true
}
29 changes: 29 additions & 0 deletions examples/everything/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'dotenv/config';
import {Pipe} from 'langbase';

// STREAM: OFF
const pipeStreamOff = new Pipe({
apiKey: process.env.PIPE_LESS_WORDY!,
});

const result = await pipeStreamOff.generateText({
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
});

console.log('STEAM-OFF');
console.log(result.completion);

// STREAM: ON
const pipeStreaming = new Pipe({
apiKey: process.env.PIPE_LESS_WORDY_STREAM!,
});

const stream = await pipeStreaming.streamText({
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
});

console.log('\n');
console.log('STEAM-ON');
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
17 changes: 17 additions & 0 deletions examples/everything/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "everything",
"version": "0.0.1",
"description": "Everything example",
"type": "module",
"main": "index.js",
"scripts": {
"test": "npx tsx index.ts"
},
"keywords": [],
"author": "Ahmad Awais <[email protected]> (https://twitter.com/MrAhmadAwais)",
"license": "UNLICENSED",
"dependencies": {
"dotenv": "^16.4.5",
"langbase": "^0.0.0"
}
}
11 changes: 11 additions & 0 deletions examples/everything/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Everything Example

Here's a kitchen sink example that does everything.

```sh
# Make sure to copy .env.example file and create .env file with all the keys in it
cp .env.example .env

# Then test.
npm test
```
28 changes: 0 additions & 28 deletions packages/langbase/src/pipes/prod.ts

This file was deleted.

19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05be989

Please sign in to comment.