diff --git a/workspaces/lightspeed/.changeset/cold-taxis-relax.md b/workspaces/lightspeed/.changeset/cold-taxis-relax.md new file mode 100644 index 00000000000..f080f29c75b --- /dev/null +++ b/workspaces/lightspeed/.changeset/cold-taxis-relax.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-lightspeed-backend': patch +--- + +Make Lightspeed service port configurable diff --git a/workspaces/lightspeed/plugins/lightspeed-backend/README.md b/workspaces/lightspeed/plugins/lightspeed-backend/README.md index 937ef53e0d5..ce316a901b6 100644 --- a/workspaces/lightspeed/plugins/lightspeed-backend/README.md +++ b/workspaces/lightspeed/plugins/lightspeed-backend/README.md @@ -35,7 +35,8 @@ lightspeed: - id: url: token: - questionValidation: true # Optional - To disable question (prompt) validation set it to false. + questionValidation: true # Optional - To disable question (prompt) validation set it to false. + servicePort: # Optional - Change the LS service port nubmer. Defaults to 8080. ``` Example local development configuration: diff --git a/workspaces/lightspeed/plugins/lightspeed-backend/config.d.ts b/workspaces/lightspeed/plugins/lightspeed-backend/config.d.ts index e8ed4ed905f..3e680d72dc1 100644 --- a/workspaces/lightspeed/plugins/lightspeed-backend/config.d.ts +++ b/workspaces/lightspeed/plugins/lightspeed-backend/config.d.ts @@ -42,5 +42,10 @@ export interface Config { * @visibility frontend */ questionValidation?: boolean; + /** + * configure the port number for the lightspeed service. + * @visibility backend + */ + servicePort?: number; }; } diff --git a/workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts b/workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts index af1c2cf2562..5ce6bb49dc7 100644 --- a/workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts +++ b/workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts @@ -51,6 +51,8 @@ export async function createRouter( const router = Router(); router.use(express.json()); + const port = config.getOptionalNumber('lightspeed.servicePort') ?? 8080; + router.get('/health', (_, response) => { response.json({ status: 'ok' }); }); @@ -127,7 +129,7 @@ export async function createRouter( // Proxy middleware configuration const apiProxy = createProxyMiddleware({ // target: config.getConfigArray('lightspeed.servers')[0].getString('url'), // currently only single llm server is supported - target: 'http://0.0.0.0:8080', + target: `http://0.0.0.0:${port}`, changeOrigin: true, pathRewrite: (path, _) => { // Add user query parameter from the authenticated user @@ -170,7 +172,7 @@ export async function createRouter( request.body.media_type = 'application/json'; // set media_type to receive start and end event const requestBody = JSON.stringify(request.body); const fetchResponse = await fetch( - `http://0.0.0.0:8080/v1/streaming_query?${userQueryParam}`, + `http://0.0.0.0:${port}/v1/streaming_query?${userQueryParam}`, { method: 'POST', headers: {