Skip to content

Commit

Permalink
implement workspaces with scoped settings
Browse files Browse the repository at this point in the history
  • Loading branch information
martypdx committed Oct 29, 2023
1 parent 6a5da58 commit 201ad8f
Show file tree
Hide file tree
Showing 48 changed files with 110 additions and 4,084 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUPABASE_ACCESS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inpla3hocWlxbG56eWRmbHBtZGRpIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTY4NTkxODc5MywiZXhwIjoyMDAxNDk0NzkzfQ.9LUZNSKeT7a0SOZgBj_sJE37l2SR2VltlOsLEmeknSA
SUPABASE_DB_PASSWORD=V9iOsc2bQzfCviFC
PROJECT_ID=zekxhqiqlnzydflpmddi
3 changes: 0 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:

- run: npm ci
- run: npm run lint
# - run: npm test
# env:
# CI: true

- name: Setup Supabase
if: github.base_ref == 'main'
Expand Down
3 changes: 3 additions & 0 deletions .netlify/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"siteId": "f6641e60-4fba-4a72-943d-76c96edada04"
}
27 changes: 0 additions & 27 deletions .vscode/settings.json

This file was deleted.

Binary file added assets/.DS_Store
Binary file not shown.
File renamed without changes.
3 changes: 3 additions & 0 deletions backend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions backend/functions/greeting/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { streamCompletion } from "../_lib/openai.ts";
import { handleCors } from "../_lib/cors.ts";
import { CENTER, MISSION, SYNTAX, TRAINING } from "../_prompts/instructions.ts";

async function handler(req: Request): Promise<Response> {
const messages = [
MISSION,
SYNTAX,
TRAINING,
CENTER,
];

const cors = handleCors(req.method);
if (cors) return cors;

return await streamCompletion(messages);
}

Deno.serve(handler);
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"lint": {
"include": [
"supabase/"
"backend/"
]
},
"fmt": {
"lineWidth": 80,
"indentWidth": 4,
"singleQuote": true,
"include": [
"supabase/"
"backend/"
]
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"qunit"
]
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions frontend/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

22 changes: 22 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "spiritwave.ai",
"version": "1.0.0",
"description": "",
"main": "app.js",
"type": "module",
"directories": {
"test": "test"
},
"scripts": {
"lint": "eslint ./src",
"test": "qunit test/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^8.47.0",
"jsdom": "^22.1.0",
"qunit": "^2.19.4"
}
}
1 change: 0 additions & 1 deletion src/app.js → frontend/src/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import './session.js';

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ const getStream = (url) => async () => {
error = await res.text();
if (error.startsWith('<!DOCTYPE html>')) {
const matches = error.matchAll(ExtractPreContentRegex);
let message = '';
let message = `${res.status}: ${res.statusText}`;
for (const [, group] of matches) {
if (message) message += '\n';
message += group ?? '';
message += '\n' + (group ?? '');
}

throw message;
Expand Down Expand Up @@ -43,8 +42,12 @@ const getStream = (url) => async () => {
};

class FetchError extends Error {
constructor(err) {
super(`Unable to retrieve AI response: \n${err}`);
constructor(statusCode, statusText, err) {
let message = err?.message ?? err ?? '';
if (typeof message === 'object') {
message = JSON.stringify(message, true, 2);
}
super(`Unable to retrieve AI response: \n${message}`);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/session.js → frontend/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ async function tryStream(getStream) {
}
catch (err) {
// TODO: better handling of failures. maybe a service at some point
// eslint-disable-next-line no-console
alert(err?.constructor?.name + ' - ' + err.message);
let message = err?.message;
if (typeof message === 'object') {
message = JSON.stringify(message, true, 2);
}
alert(err?.constructor?.name + ' - ' + message);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion styles/global.css → frontend/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ section, header, footer {
}

section:not(:last-child) {
margin-bottom: 8em;
margin-bottom: 2em;
}

section > *, header, footer {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions netlify.toml

This file was deleted.

Loading

0 comments on commit 201ad8f

Please sign in to comment.