Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Beak.js server #14

Merged
merged 24 commits into from
Nov 22, 2023
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
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,23 @@ jobs:
yarn workspace @beakjs/react publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish (server)
run: |
yarn workspace @beakjs/server publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish (next)
run: |
yarn workspace @beakjs/next publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish (next)
run: |
yarn workspace @beakjs/remix publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish (express)
run: |
yarn workspace @beakjs/express publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 5 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"chatcmpl",
"uuidv4",
"Hola",
"Mundo"
"Mundo",
"OpenAIAPIKey",
"nextjs",
"typecheck",
"isbot"
]
}
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🐦 Beak.js [![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/mme_xyz?style=flat&logo=x)](https://twitter.com/mme_xyz) [![npm (scoped)](https://img.shields.io/npm/v/%40beakjs/react)](https://www.npmjs.com/package/@beakjs/react)

Beak.js lets you integrate custom conversational assistants into your React applications.
Beak.js contains everything you need to create custom AI-powered assistants for your React app.

**Key Features:**

Expand Down Expand Up @@ -32,7 +32,7 @@ import { Beak } from "@beakjs/react";

const App = () => (
<Beak
openAIApiKey="sk-..."
__unsafeOpenAIApiKey__="sk-..."
instructions="Assistant is running in a web app and helps the user with XYZ."
>
<MyApp />
Expand All @@ -43,7 +43,7 @@ const App = () => (

Now, you've got a chat window ready in the bottom right corner of your website. Give it a try!

**Note:** Don't expose your API key in public-facing apps. We will be adding a solution for securely using your API key soon.
**Note:** Don't expose your API key in public-facing apps - this is for development only. See [Deployment](#deployment) for information on how to securely deploy your app without compromising your API key.

### Making Beak.js work with your app

Expand Down Expand Up @@ -94,6 +94,18 @@ const MyApp = () => {

By using `useBeakFunction` together with `useBeakInfo`, your assistant can see what's happening on the screen and take action within your app depending on the current context.

## Deployment

To keep your API keys safe, we set up a server that forwards your assistant's requests to OpenAI.

Currently, we support the following deployment options:

- [Next.js](/docs/deployment/next.md)
- [Remix](/docs/deployment/remix.md)
- [Express](/docs/deployment/express.md)

Read more by clicking the links above.

## Run the Demo

To run the demo, build the project and start the demo app:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.5
0.0.6
3 changes: 3 additions & 0 deletions demo/backend/express/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.env
dist
24 changes: 24 additions & 0 deletions demo/backend/express/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "demo-backend-express",
"version": "0.0.6",
"main": "dist/index.js",
"repository": "https://github.com/mme/beakjs.git",
"type": "module",
"scripts": {
"build": "tsc",
"clean": "rm -rf node_modules && rm -rf .next && rm -rf dist",
"start": "node dist/index.js"
},
"author": "Markus Ecker",
"license": "MIT",
"private": true,
"dependencies": {
"@beakjs/express": "0.0.6",
"dotenv": "^16.3.1",
"express": "^4.18.2"
},
"devDependencies": {
"@types/express": "^4.17.21",
"typescript": "^5.0.4"
}
}
14 changes: 14 additions & 0 deletions demo/backend/express/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import express from "express";
import { beakHandler } from "@beakjs/express";
import dotenv from "dotenv";
dotenv.config();

const app = express();
const port = 3000;

app.use(express.json());
app.use("/beak", beakHandler());

app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
22 changes: 22 additions & 0 deletions demo/backend/express/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es2019",
"module": "ESNext",
"declaration": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"lib": ["es2019"],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"types": ["node"]
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
Loading