Skip to content

Commit 96041ee

Browse files
authored
[RHIDP-13414] Update lightspeed core host (#3059)
* use constant variable for lightspeed host across all instances Signed-off-by: Jordan Dubrick <jdubrick@redhat.com> * use 127.0.0.1 instead of 0.0.0.0 for LCORE instance Signed-off-by: Jordan Dubrick <jdubrick@redhat.com> * changeset Signed-off-by: Jordan Dubrick <jdubrick@redhat.com> --------- Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
1 parent 04d679f commit 96041ee

7 files changed

Lines changed: 26 additions & 12 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-lightspeed-backend': patch
3+
---
4+
5+
update default LCORE host from 0.0.0.0 to 127.0.0.1

workspaces/lightspeed/plugins/lightspeed-backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ lightspeed:
125125

126126
**Core Settings**:
127127

128-
- **`lightspeed.servicePort`** _(optional)_: Port where Lightspeed Core service is running (default: `8080`). The backend connects to Lightspeed Core at `http://0.0.0.0:{servicePort}` to proxy vector store operations.
128+
- **`lightspeed.servicePort`** _(optional)_: Port where Lightspeed Core service is running (default: `8080`). The backend connects to Lightspeed Core at `http://{DEFAULT_LIGHTSPEED_SERVICE_HOST}:{servicePort}` to proxy vector store operations. The host is defined by the `DEFAULT_LIGHTSPEED_SERVICE_HOST` constant in the source.
129129

130130
**Notebooks Settings**:
131131

workspaces/lightspeed/plugins/lightspeed-backend/__fixtures__/lcsHandlers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616

1717
import { http, HttpResponse, type HttpHandler } from 'msw';
1818

19-
export const LOCAL_LCS_ADDR = 'http://0.0.0.0:8080';
19+
import {
20+
DEFAULT_LIGHTSPEED_SERVICE_HOST,
21+
DEFAULT_LIGHTSPEED_SERVICE_PORT,
22+
} from '../src/service/constant';
23+
24+
export const LOCAL_LCS_ADDR = `http://${DEFAULT_LIGHTSPEED_SERVICE_HOST}:${DEFAULT_LIGHTSPEED_SERVICE_PORT}`;
2025

2126
function loadTestFixture(filePathFromFixturesDir: string) {
2227
return require(`${__dirname}/${filePathFromFixturesDir}`);

workspaces/lightspeed/plugins/lightspeed-backend/__fixtures__/lightspeedCoreHandlers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
import { http, HttpResponse, type HttpHandler } from 'msw';
1818

19+
import { DEFAULT_LIGHTSPEED_SERVICE_HOST } from '../src/service/constant';
20+
1921
// Use port 7007 for tests (matches notebooksRouter.test.ts config)
2022
const TEST_LIGHTSPEED_SERVICE_PORT = 7007;
21-
export const LIGHTSPEED_CORE_ADDR = `http://0.0.0.0:${TEST_LIGHTSPEED_SERVICE_PORT}`;
23+
export const LIGHTSPEED_CORE_ADDR = `http://${DEFAULT_LIGHTSPEED_SERVICE_HOST}:${TEST_LIGHTSPEED_SERVICE_PORT}`;
2224

2325
// Mock session data
2426
export const mockSession1 = {

workspaces/lightspeed/plugins/lightspeed-backend/config.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface Config {
5656
/**
5757
* Enable/disable AI Notebooks feature
5858
* When enabled, exposes AI Notebooks REST API endpoints for document-based conversations with RAG.
59-
* Requires Lightspeed service to be running (default: http://0.0.0.0:8080).
59+
* Requires Lightspeed service to be running (host and port default to 127.0.0.1 and 8080).
6060
* @default false
6161
* @visibility frontend
6262
*/

workspaces/lightspeed/plugins/lightspeed-backend/src/service/constant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const DEFAULT_CHUNKING_STRATEGY_TYPE = 'auto'; // auto chunking
2222
export const DEFAULT_MAX_CHUNK_SIZE_TOKENS = 512; // 512 tokens
2323
export const DEFAULT_CHUNK_OVERLAP_TOKENS = 50; // 50 tokens
2424
export const DEFAULT_LLAMA_STACK_PORT = 8321; // Llama Stack port
25-
export const DEFAULT_LIGHTSPEED_SERVICE_HOST = '0.0.0.0'; // Lightspeed core service host
25+
export const DEFAULT_LIGHTSPEED_SERVICE_HOST = '127.0.0.1'; // Lightspeed core service host
2626
export const DEFAULT_LIGHTSPEED_SERVICE_PORT = 8080; // Lightspeed service port
2727
export const DEFAULT_MAX_FILE_SIZE_MB = 20 * 1024 * 1024; // 20MB
2828
export const NOTEBOOKS_SYSTEM_PROMPT = `

workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
import { Readable } from 'node:stream';
3434

3535
import {
36+
DEFAULT_LIGHTSPEED_SERVICE_HOST,
3637
DEFAULT_LIGHTSPEED_SERVICE_PORT,
3738
PROXY_PASSTHROUGH_PATHS,
3839
} from './constant';
@@ -110,9 +111,10 @@ export async function createRouter(
110111
config.getOptionalNumber('lightspeed.servicePort') ??
111112
DEFAULT_LIGHTSPEED_SERVICE_PORT;
112113
const system_prompt = config.getOptionalString('lightspeed.systemPrompt');
114+
const lightspeedCoreBaseUrl = `http://${DEFAULT_LIGHTSPEED_SERVICE_HOST}:${port}`;
113115

114116
const vectorStoresOperator = VectorStoresOperator.getInstance(
115-
`http://0.0.0.0:${port}`,
117+
lightspeedCoreBaseUrl,
116118
logger,
117119
);
118120
let lightspeed_vector_store_id: string = '';
@@ -145,7 +147,7 @@ export async function createRouter(
145147

146148
async function refreshLcsUrlCache(): Promise<void> {
147149
try {
148-
const response = await fetch(`http://0.0.0.0:${port}/v1/mcp-servers`, {
150+
const response = await fetch(`${lightspeedCoreBaseUrl}/v1/mcp-servers`, {
149151
signal: AbortSignal.timeout(5000),
150152
});
151153
if (!response.ok) {
@@ -455,7 +457,7 @@ export async function createRouter(
455457
}
456458
// Proxy middleware configuration
457459
const apiProxy = createProxyMiddleware({
458-
target: `http://0.0.0.0:${port}`,
460+
target: lightspeedCoreBaseUrl,
459461
changeOrigin: true,
460462
pathRewrite: (path, _) => {
461463
const isSkippable = Array.from(SKIP_USER_ID_ENDPOINTS).some(endpoint =>
@@ -507,7 +509,7 @@ export async function createRouter(
507509
const userQueryParam = `user_id=${encodeURIComponent(user_id)}`;
508510
const requestBody = JSON.stringify(request.body);
509511
const fetchResponse = await fetch(
510-
`http://0.0.0.0:${port}/v1/feedback?${userQueryParam}`,
512+
`${lightspeedCoreBaseUrl}/v1/feedback?${userQueryParam}`,
511513
{
512514
method: 'POST',
513515
headers: {
@@ -555,7 +557,7 @@ export async function createRouter(
555557
const userQueryParam = `user_id=${encodeURIComponent(user_id)}`;
556558
const requestBody = JSON.stringify(request.body);
557559
const fetchResponse = await fetch(
558-
`http://0.0.0.0:${port}/v1/streaming_query/interrupt?${userQueryParam}`,
560+
`${lightspeedCoreBaseUrl}/v1/streaming_query/interrupt?${userQueryParam}`,
559561
{
560562
method: 'POST',
561563
headers: {
@@ -631,7 +633,7 @@ export async function createRouter(
631633
);
632634

633635
const fetchResponse = await fetch(
634-
`http://0.0.0.0:${port}/v1/streaming_query?${userQueryParam}`,
636+
`${lightspeedCoreBaseUrl}/v1/streaming_query?${userQueryParam}`,
635637
{
636638
method: 'POST',
637639
headers: {
@@ -690,7 +692,7 @@ export async function createRouter(
690692
);
691693
const userQueryParam = `user_id=${encodeURIComponent(user_id)}`;
692694
const fetchResponse = await fetch(
693-
`http://0.0.0.0:${port}/v2/conversations/${conversation_id}?${userQueryParam}`,
695+
`${lightspeedCoreBaseUrl}/v2/conversations/${conversation_id}?${userQueryParam}`,
694696
{
695697
method: 'PUT',
696698
headers: {

0 commit comments

Comments
 (0)