Skip to content

Feature/elysia+swagger+openapi-2 #236

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

Open
wants to merge 35 commits into
base: feature/brj-app
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
267812e
Use Elisia.js - GRM
hejny Apr 2, 2025
ea46fc6
Merge branch 'update/typescript-5.8.2' into feature/elysia+swagger+op…
hejny Apr 2, 2025
ba4fab6
Add Elysia.js and Swagger dependencies to package.json and package-lo…
hejny Apr 2, 2025
57e1264
Migrating to Elisia.js
hejny Apr 2, 2025
033a999
Migrating to Elisia.js
hejny Apr 2, 2025
d1b23ca
Fix types and imports
hejny Apr 2, 2025
2a38a46
Merge branch 'update/typescript-5.2.2' into feature/elysia+swagger+op…
hejny Apr 2, 2025
5935375
Try to fix compatibility problems
hejny Apr 2, 2025
06f941f
Merge branch 'feature/brj-app' into feature/elysia+swagger+openapi-2
hejny Apr 8, 2025
957b1e4
Changelog
hejny Apr 8, 2025
9266f9b
Fix code typo
hejny Apr 8, 2025
29179e8
Fix imports
hejny Apr 8, 2025
b5bde41
Fix types
hejny Apr 8, 2025
24a41ce
Import `@elysiajs/swagger` via `require`
hejny Apr 8, 2025
89ef66d
📖 Make Promptbook templates library
hejny Apr 8, 2025
a4b0ffc
🧹 Repair imports
hejny Apr 8, 2025
a5b2d87
0.89.0-22
hejny Apr 8, 2025
5c91d8e
🆚 Update `0.89.0-22` -> `version.ts`
hejny Apr 8, 2025
257c14e
🆚 Add `0.89.0-22` -> `versions.txt`
hejny Apr 8, 2025
ffcd657
🆚🐋 Update `0.89.0-22` -> `Dockerfile`
hejny Apr 8, 2025
5cd884a
📖 Convert examples `.book.md` -> `.bookc`
hejny Apr 8, 2025
58d09e8
Publishing
hejny Apr 8, 2025
da962fe
📖 Make Promptbook templates library
hejny Apr 8, 2025
3524f49
📦 Generating packages `0.89.0-22`
hejny Apr 8, 2025
eda1e66
0.89.0-23
hejny Apr 8, 2025
1417f61
🆚 Update `0.89.0-23` -> `version.ts`
hejny Apr 8, 2025
004ac59
🆚 Add `0.89.0-23` -> `versions.txt`
hejny Apr 8, 2025
30bac22
🆚🐋 Update `0.89.0-23` -> `Dockerfile`
hejny Apr 8, 2025
61374ed
📖 Convert examples `.book.md` -> `.bookc`
hejny Apr 8, 2025
ae8d721
📦 Generating packages `0.89.0-23`
hejny Apr 8, 2025
6858e06
🆚 Update terminal commands to use `npx ts-node` for execution
hejny Apr 8, 2025
d3fdde5
Try to import `@elysiajs/swagger`
hejny Apr 8, 2025
74d3a96
`@elysiajs/swagger` cannot be imported
hejny Apr 8, 2025
428e3f5
`@elysiajs/swagger` cannot be imported, comment it out
hejny Apr 8, 2025
03f84e0
TODOs
hejny Apr 8, 2025
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
Prev Previous commit
Next Next commit
Try to fix compatibility problems
  • Loading branch information
hejny committed Apr 2, 2025
commit 5935375ea04ae270922a072b5584af604d28c619
2 changes: 1 addition & 1 deletion examples/usage/remote/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function main() {
const collection = await createCollectionFromDirectory('./examples/pipelines/', tools);

// [⚖]
startRemoteServer({
await startRemoteServer({
port: 4460,
rootPath: '/',
collection,
Expand Down
60 changes: 30 additions & 30 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@ai-sdk/openai": "1.0.7",
"@anthropic-ai/sdk": "0.26.1",
"@azure/openai": "1.0.0-beta.12",
"@elysiajs/swagger": "^1.2.2",
"@elysiajs/swagger": "1.2.2",
"@mozilla/readability": "0.6.0",
"colors": "1.4.0",
"commander": "12.0.0",
Expand All @@ -118,7 +118,7 @@
"crypto-js": "4.2.0",
"destroyable": "0.12.62",
"dotenv": "16.3.1",
"elysia": "^1.2.25",
"elysia": "1.2.25",
"express": "4.21.2",
"glob-promise": "6.0.5",
"jsdom": "25.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cli-commands/start-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function $initializeStartServerCommand(program: Program) {

// console.log(path, await collection.listPipelines());

const server = startRemoteServer({
const server = await startRemoteServer({
rootPath,
port,
isAnonymousModeAllowed,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/promptbookCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { $initializeLoginCommand } from './cli-commands/login';
import { $initializeMakeCommand } from './cli-commands/make';
import { $initializePrettifyCommand } from './cli-commands/prettify';
import { $initializeRunCommand } from './cli-commands/run';
import { $initializeStartServerCommand } from './cli-commands/start-server';
import { $initializeTestCommand } from './cli-commands/test-command';
import { $addGlobalOptionsToCommand } from './common/$addGlobalOptionsToCommand';
import { $initializeStartServerCommand } from './cli-commands/start-server';

/**
* Runs CLI utilities of Promptbook package
Expand Down
5 changes: 2 additions & 3 deletions src/llm-providers/remote/playground/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ dotenv.config({ path: '.env' });
import colors from 'colors'; // <- TODO: [🔶] Make system to put color and style to both node and browser
import { forEver, forTime } from 'waitasecond';
import { createCollectionFromDirectory } from '../../../collection/constructors/createCollectionFromDirectory';
import { CLI_APP_ID } from '../../../config';
import { PLAYGROUND_APP_ID } from '../../../config';
import { CLI_APP_ID, PLAYGROUND_APP_ID } from '../../../config';
import { AuthenticationError } from '../../../errors/AuthenticationError';
import { startRemoteServer } from '../../../remote-server/startRemoteServer';
import { $provideFilesystemForNode } from '../../../scrapers/_common/register/$provideFilesystemForNode';
Expand All @@ -34,7 +33,7 @@ async function playground() {
//========================================>

console.info(colors.bgCyan('Playground:'), colors.bgWhite(`Starting remote server`));
startRemoteServer({
await startRemoteServer({
// TODO: !!!!! Test here remoteServerUrl to have some path
port: 4460,
isVerbose: true,
Expand Down
21 changes: 13 additions & 8 deletions src/remote-server/startRemoteServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { swagger } from '@elysiajs/swagger'; // <- TODO: [⭐] Cleanup other swagger packages that are not used anymore
import colors from 'colors'; // <- TODO: [🔶] Make system to put color and style to both node and browser
import { Elysia } from 'elysia';
import { DefaultEventsMap, Server, Socket } from 'socket.io';
import { spaceTrim } from 'spacetrim';
import { forTime } from 'waitasecond';
Expand Down Expand Up @@ -49,9 +47,9 @@ keepTypeImported<PromptbookServer_ListModels_Response>(); // <- Note: [🤛]
* @see https://github.com/webgptorg/promptbook#remote-server
* @public exported from `@promptbook/remote-server`
*/
export function startRemoteServer<TCustomOptions = undefined>(
export async function startRemoteServer<TCustomOptions = undefined>(
options: RemoteServerOptions<TCustomOptions>,
): RemoteServer {
): Promise<RemoteServer> /* <- TODO: [🧠] Should be this function async or not */ {
const {
port,
collection,
Expand All @@ -71,6 +69,13 @@ export function startRemoteServer<TCustomOptions = undefined>(
// <- TODO: [🦪] Some helper type to be able to use discriminant union types with destructuring
let { rootPath = '/' } = options;

// Note: Importing from `elysia` and `@elysiajs/swagger` !!!!!!
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { swagger } = require('@elysiajs/swagger');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Elysia } = require('elysia');
// <- TODO: [⭐] Cleanup other swagger packages that are not used anymore

if (!rootPath.startsWith('/')) {
rootPath = `/${rootPath}`;
} /* not else */
Expand Down Expand Up @@ -162,12 +167,12 @@ export function startRemoteServer<TCustomOptions = undefined>(
)
.decorate('startupDate', startupDate)
.decorate('runningExecutionTasks', [] as Array<ExecutionTask>)
.derive(({ request }) => ({
.derive(({ request }: TODO_any /* <- TODO: !!! */) => ({
fullUrl: request.url,
}));

// Add headers middleware
app.derive({ as: 'global' }, ({ set }) => {
app.derive({ as: 'global' }, ({ set }: TODO_any /* <- TODO: !!! */) => {
set.headers['X-Powered-By'] = 'Promptbook engine';
return {};
});
Expand Down Expand Up @@ -256,7 +261,7 @@ export function startRemoteServer<TCustomOptions = undefined>(

${block(
app.routes
.map((route) => `- ${route.path}`)
.map((route: TODO_any /* <- TODO: !!! */) => `- ${route.path}`)
.concat('/api-docs')
.join('\n'),
)}
Expand Down Expand Up @@ -606,7 +611,7 @@ export function startRemoteServer<TCustomOptions = undefined>(
},
*/

get elisiaApp(): Elysia {
get elisiaApp() /* : typeof Elysia */ {
return app as TODO_any;
},

Expand Down