File size: 622 Bytes
90d354b
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import {AsyncLocalStorage} from 'node:async_hooks'

// The cloud gateway supplies a worker-local GPU bridge for this request only.
export const runtimeContext = new AsyncLocalStorage()
export function modelUrl(route) {
  const base = runtimeContext.getStore()?.modelBase || process.env.HOME_PULSE_MODEL_URL || 'http://127.0.0.1:8765'
  return base.replace(/\/$/,'') + route
}
export const cloudMode = () => process.env.HOME_PULSE_CLOUD === '1'
export function modelHeaders(){
  return {'Content-Type':'application/json',...(runtimeContext.getStore()?.modelBase?{'X-Bridge-Key':process.env.HOME_PULSE_INTERNAL_KEY}: {})}
}