refactor: different Jan builds should have different Cortex server port (#4699)
* refactor: different Jan instances should have different Cortex server port configurations * chore: update workflow to use env input * chore: update env for cortex port setting
This commit is contained in:
parent
eba6884abb
commit
badc632ee4
@ -18,6 +18,7 @@ jobs:
|
||||
public_provider: github
|
||||
new_version: ${{ needs.get-update-version.outputs.new_version }}
|
||||
beta: true
|
||||
cortex_api_port: "39271"
|
||||
|
||||
build-windows-x64:
|
||||
uses: ./.github/workflows/template-build-windows-x64.yml
|
||||
@ -28,6 +29,7 @@ jobs:
|
||||
public_provider: github
|
||||
new_version: ${{ needs.get-update-version.outputs.new_version }}
|
||||
beta: true
|
||||
cortex_api_port: "39271"
|
||||
|
||||
build-linux-x64:
|
||||
uses: ./.github/workflows/template-build-linux-x64.yml
|
||||
@ -38,6 +40,7 @@ jobs:
|
||||
public_provider: github
|
||||
new_version: ${{ needs.get-update-version.outputs.new_version }}
|
||||
beta: true
|
||||
cortex_api_port: "39271"
|
||||
|
||||
sync-temp-to-latest:
|
||||
needs: [build-macos, build-windows-x64, build-linux-x64]
|
||||
|
||||
@ -55,6 +55,7 @@ jobs:
|
||||
ref: ${{ needs.set-public-provider.outputs.ref }}
|
||||
public_provider: ${{ needs.set-public-provider.outputs.public_provider }}
|
||||
new_version: ${{ needs.get-update-version.outputs.new_version }}
|
||||
cortex_api_port: "39261"
|
||||
|
||||
build-windows-x64:
|
||||
uses: ./.github/workflows/template-build-windows-x64.yml
|
||||
@ -64,6 +65,7 @@ jobs:
|
||||
ref: ${{ needs.set-public-provider.outputs.ref }}
|
||||
public_provider: ${{ needs.set-public-provider.outputs.public_provider }}
|
||||
new_version: ${{ needs.get-update-version.outputs.new_version }}
|
||||
cortex_api_port: "39261"
|
||||
|
||||
|
||||
build-linux-x64:
|
||||
@ -74,6 +76,7 @@ jobs:
|
||||
ref: ${{ needs.set-public-provider.outputs.ref }}
|
||||
public_provider: ${{ needs.set-public-provider.outputs.public_provider }}
|
||||
new_version: ${{ needs.get-update-version.outputs.new_version }}
|
||||
cortex_api_port: "39261"
|
||||
|
||||
sync-temp-to-latest:
|
||||
needs: [set-public-provider, build-windows-x64, build-linux-x64, build-macos]
|
||||
|
||||
@ -23,6 +23,10 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
cortex_api_port:
|
||||
required: false
|
||||
type: string
|
||||
default: null
|
||||
secrets:
|
||||
DELTA_AWS_S3_BUCKET_NAME:
|
||||
required: false
|
||||
@ -115,6 +119,7 @@ jobs:
|
||||
AWS_MAX_ATTEMPTS: '5'
|
||||
POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}
|
||||
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
|
||||
CORTEX_API_PORT: ${{ inputs.cortex_api_port }}
|
||||
|
||||
- name: Build and publish app to github
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
|
||||
|
||||
5
.github/workflows/template-build-macos.yml
vendored
5
.github/workflows/template-build-macos.yml
vendored
@ -23,6 +23,10 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
cortex_api_port:
|
||||
required: false
|
||||
type: string
|
||||
default: null
|
||||
secrets:
|
||||
DELTA_AWS_S3_BUCKET_NAME:
|
||||
required: false
|
||||
@ -154,6 +158,7 @@ jobs:
|
||||
AWS_MAX_ATTEMPTS: '5'
|
||||
POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}
|
||||
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
|
||||
CORTEX_API_PORT: ${{ inputs.cortex_api_port }}
|
||||
|
||||
- name: Build and publish app to github
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
|
||||
|
||||
@ -23,6 +23,10 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
cortex_api_port:
|
||||
required: false
|
||||
type: string
|
||||
default: null
|
||||
secrets:
|
||||
DELTA_AWS_S3_BUCKET_NAME:
|
||||
required: false
|
||||
@ -153,6 +157,7 @@ jobs:
|
||||
AWS_MAX_ATTEMPTS: '5'
|
||||
POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}
|
||||
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
|
||||
CORTEX_API_PORT: ${{ inputs.cortex_api_port }}
|
||||
|
||||
- name: Build app and publish app to github
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && inputs.public_provider == 'github' && inputs.beta == false
|
||||
|
||||
@ -26,6 +26,9 @@ export default defineConfig([
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts'],
|
||||
},
|
||||
define: {
|
||||
CORTEX_API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
},
|
||||
platform: 'node',
|
||||
},
|
||||
])
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
declare const NODE: string
|
||||
declare const VERSION: string
|
||||
declare const CORTEX_API_URL: string
|
||||
|
||||
@ -28,7 +28,7 @@ export class Retrieval {
|
||||
this.timeWeightedVectorStore = new MemoryVectorStore(
|
||||
new OpenAIEmbeddings(
|
||||
{ openAIApiKey: 'cortex-embedding' },
|
||||
{ basePath: 'http://127.0.0.1:39291/v1' }
|
||||
{ basePath: `${CORTEX_API_URL}/v1` }
|
||||
)
|
||||
)
|
||||
this.timeWeightedretriever = new TimeWeightedVectorStoreRetriever({
|
||||
@ -51,7 +51,7 @@ export class Retrieval {
|
||||
this.embeddingModel = new OpenAIEmbeddings(
|
||||
{ openAIApiKey: 'cortex-embedding', model },
|
||||
// TODO: Raw settings
|
||||
{ basePath: 'http://127.0.0.1:39291/v1' }
|
||||
{ basePath: `${CORTEX_API_URL}/v1` }
|
||||
)
|
||||
|
||||
// update time-weighted embedding model
|
||||
|
||||
@ -8,7 +8,6 @@ export default defineConfig({
|
||||
},
|
||||
platform: 'browser',
|
||||
define: {
|
||||
API_URL: JSON.stringify('http://127.0.0.1:39291'),
|
||||
SOCKET_URL: JSON.stringify('ws://127.0.0.1:39291'),
|
||||
API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
},
|
||||
})
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
declare const API_URL: string
|
||||
declare const SOCKET_URL: string
|
||||
|
||||
interface Core {
|
||||
api: APIFunctions
|
||||
|
||||
@ -11,8 +11,7 @@ export default defineConfig([
|
||||
},
|
||||
define: {
|
||||
NODE: JSON.stringify(`${pkgJson.name}/${pkgJson.node}`),
|
||||
API_URL: JSON.stringify('http://127.0.0.1:39291'),
|
||||
SOCKET_URL: JSON.stringify('ws://127.0.0.1:39291'),
|
||||
API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
PLATFORM: JSON.stringify(process.platform),
|
||||
CORTEX_ENGINE_VERSION: JSON.stringify('v0.1.49'),
|
||||
DEFAULT_REMOTE_ENGINES: JSON.stringify(engines),
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
declare const API_URL: string
|
||||
declare const CORTEX_ENGINE_VERSION: string
|
||||
declare const PLATFORM: string
|
||||
declare const SOCKET_URL: string
|
||||
declare const NODE: string
|
||||
declare const DEFAULT_REQUEST_PAYLOAD_TRANSFORM: string
|
||||
declare const DEFAULT_RESPONSE_BODY_TRANSFORM: string
|
||||
|
||||
@ -10,8 +10,7 @@ export default defineConfig([
|
||||
},
|
||||
define: {
|
||||
NODE: JSON.stringify(`${pkgJson.name}/${pkgJson.node}`),
|
||||
API_URL: JSON.stringify('http://127.0.0.1:39291'),
|
||||
SOCKET_URL: JSON.stringify('ws://127.0.0.1:39291'),
|
||||
API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
declare const API_URL: string
|
||||
declare const SOCKET_URL: string
|
||||
declare const NODE: string
|
||||
|
||||
interface Core {
|
||||
|
||||
@ -122,8 +122,8 @@ export default defineConfig([
|
||||
]),
|
||||
NODE: JSON.stringify(`${packageJson.name}/${packageJson.node}`),
|
||||
SETTINGS: JSON.stringify(defaultSettingJson),
|
||||
CORTEX_API_URL: JSON.stringify('http://127.0.0.1:39291'),
|
||||
CORTEX_SOCKET_URL: JSON.stringify('ws://127.0.0.1:39291'),
|
||||
CORTEX_API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
CORTEX_SOCKET_URL: JSON.stringify(`ws://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
CORTEX_ENGINE_VERSION: JSON.stringify('v0.1.49'),
|
||||
},
|
||||
},
|
||||
@ -139,6 +139,9 @@ export default defineConfig([
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.json'],
|
||||
},
|
||||
define: {
|
||||
CORTEX_API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
},
|
||||
platform: 'node',
|
||||
},
|
||||
])
|
||||
|
||||
@ -3,13 +3,11 @@ import {
|
||||
appResourcePath,
|
||||
getJanDataFolderPath,
|
||||
log,
|
||||
SystemInformation,
|
||||
} from '@janhq/core/node'
|
||||
import { ProcessWatchdog } from './watchdog'
|
||||
import { readdir, symlink } from 'fs/promises'
|
||||
|
||||
// The HOST address to use for the Nitro subprocess
|
||||
const LOCAL_PORT = '39291'
|
||||
const LOCAL_PORT = CORTEX_API_URL.split(":").pop() ?? "39291"
|
||||
let watchdog: ProcessWatchdog | undefined = undefined
|
||||
|
||||
/**
|
||||
|
||||
@ -11,8 +11,7 @@ export default defineConfig({
|
||||
platform: 'browser',
|
||||
define: {
|
||||
SETTINGS: JSON.stringify(settingJson),
|
||||
API_URL: JSON.stringify('http://127.0.0.1:39291'),
|
||||
SOCKET_URL: JSON.stringify('ws://127.0.0.1:39291'),
|
||||
API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
DEFAULT_MODEL_SOURCES: JSON.stringify(modelSources),
|
||||
},
|
||||
})
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
declare const NODE: string
|
||||
declare const API_URL: string
|
||||
declare const SOCKET_URL: string
|
||||
declare const SETTINGS: SettingComponentProps[]
|
||||
declare const DEFAULT_MODEL_SOURCES: any
|
||||
|
||||
|
||||
1
server/global.d.ts
vendored
Normal file
1
server/global.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare const CORTEX_API_URL: string
|
||||
@ -98,7 +98,7 @@ export const startServer = async (configs?: ServerConfig): Promise<boolean> => {
|
||||
})
|
||||
|
||||
server.register(require('@fastify/http-proxy'), {
|
||||
upstream: 'http://127.0.0.1:39291/v1',
|
||||
upstream: `${CORTEX_API_URL}/v1`,
|
||||
prefix: configs?.prefix ?? '/v1',
|
||||
http2: false,
|
||||
})
|
||||
|
||||
@ -14,5 +14,8 @@ export default defineConfig([
|
||||
},
|
||||
external: ['@fastify/swagger-ui'],
|
||||
platform: 'node',
|
||||
define: {
|
||||
CORTEX_API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
@ -35,7 +35,8 @@ const nextConfig = {
|
||||
POSTHOG_HOST: JSON.stringify(process.env.POSTHOG_HOST),
|
||||
ANALYTICS_HOST: JSON.stringify(process.env.ANALYTICS_HOST),
|
||||
API_BASE_URL: JSON.stringify(
|
||||
process.env.API_BASE_URL ?? 'http://127.0.0.1:39291'
|
||||
process.env.API_BASE_URL ??
|
||||
`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? '39291'}`
|
||||
),
|
||||
isMac: process.platform === 'darwin',
|
||||
isWindows: process.platform === 'win32',
|
||||
|
||||
@ -290,7 +290,7 @@ const HubScreen = () => {
|
||||
)}
|
||||
{hubBannerOption === 'upload' && (
|
||||
<div
|
||||
className={`m-2 flex h-[172px] w-full cursor-pointer items-center justify-center rounded-md border`}
|
||||
className={`mx-2 mb-2 flex h-[172px] cursor-pointer items-center justify-center rounded-md border`}
|
||||
onClick={() => {
|
||||
imageInputRef.current?.click()
|
||||
}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user