💩
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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`
|
||||
@@ -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...`)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user