This commit is contained in:
Travis Fischer
2023-11-14 04:45:44 -06:00
parent 441e20c3fb
commit 6fbde75363
5 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
"node": ">=18"
},
"scripts": {
"build": "tsc --project tsconfig.json",
"build": "tsc --project tsconfig.dist.json",
"prebuild": "run-s clean && prisma generate",
"clean": "del dist",
"dev": "tsc --watch",
+2
View File
@@ -18,6 +18,8 @@ export namespace queue {
// 10 minute timeout, including waiting for tool outputs
export const stalledInterval = 10 * 60 * 1000
export const threadRunJobName = 'thread-run'
export const startRunner = !!process.env.START_RUNNER
}
export namespace storage {
+9
View File
@@ -0,0 +1,9 @@
- `server/` - contains the OpenAI-compatible Assistants REST API powered by [Hono](https://hono.dev)
- use `tsx src/server/index.ts` to start a server instance
- or use `node dist/server/index.js` after successfully building the project with `pnpm build`
- `runner/` - contains the [BullMQ async task queue runner](https://docs.bullmq.io/)
- use `tsx src/runner/index.ts` to start a runner instance
- or use `node dist/runner/index.js` after successfully building the project with `pnpm build`
- `generated/` - contains auto-generated [zod schemas](https://zod.dev), types, and [@hono/zod-openapi routes](https://github.com/honojs/middleware/tree/main/packages/zod-openapi)
- all code in this directory is auto-generated by [generate.ts](../bin/generate.ts) using [OpenAI's OpenAPI spec](https://github.com/openai/openai-openapi) as a source of truth
- `lib/` - contains all the server code shared between `server` and the async task queue `runner`
+6
View File
@@ -5,6 +5,7 @@ import { OpenAPIHono } from '@hono/zod-openapi'
import 'dotenv/config'
import { asyncExitHook } from 'exit-hook'
import * as config from '~/lib/config'
import { prisma } from '~/lib/db'
import { queue } from '~/lib/queue'
@@ -52,6 +53,7 @@ app.route('', messageFiles)
app.route('', runs)
app.route('', runSteps)
// TODO: these values should be taken from the source openapi spec
app.doc('/openapi', {
openapi: '3.0.0',
info: {
@@ -64,6 +66,10 @@ app.showRoutes()
const server = serve(app)
if (config.queue.startRunner) {
await import('~/runner/index')
}
asyncExitHook(
async (signal: number) => {
console.log(`Received ${signal}; closing server...`)
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"]
}