@@ -20,6 +20,11 @@ export type EmbeddingProviderOptions = {
2020 config : ClawdbotConfig ;
2121 agentDir ?: string ;
2222 provider : "openai" | "local" ;
23+ remote ?: {
24+ baseUrl ?: string ;
25+ apiKey ?: string ;
26+ headers ?: Record < string , string > ;
27+ } ;
2328 model : string ;
2429 fallback : "openai" | "none" ;
2530 local ?: {
@@ -42,16 +47,23 @@ function normalizeOpenAiModel(model: string): string {
4247async function createOpenAiEmbeddingProvider (
4348 options : EmbeddingProviderOptions ,
4449) : Promise < EmbeddingProvider > {
45- const { apiKey } = await resolveApiKeyForProvider ( {
46- provider : "openai" ,
47- cfg : options . config ,
48- agentDir : options . agentDir ,
49- } ) ;
50+ const remote = options . config . agents ?. defaults ?. memorySearch ?. remote ;
51+
52+ const { apiKey } = remote ?. apiKey
53+ ? { apiKey : remote . apiKey }
54+ : await resolveApiKeyForProvider ( {
55+ provider : "openai" ,
56+ cfg : options . config ,
57+ agentDir : options . agentDir ,
58+ } ) ;
5059
5160 const providerConfig = options . config . models ?. providers ?. openai ;
52- const baseUrl = providerConfig ?. baseUrl ?. trim ( ) || DEFAULT_OPENAI_BASE_URL ;
61+ const baseUrl =
62+ remote ?. baseUrl ?. trim ( ) ||
63+ providerConfig ?. baseUrl ?. trim ( ) ||
64+ DEFAULT_OPENAI_BASE_URL ;
5365 const url = `${ baseUrl . replace ( / \/ $ / , "" ) } /embeddings` ;
54- const headerOverrides = providerConfig ?. headers ?? { } ;
66+ const headerOverrides = remote ?. headers ?? providerConfig ?. headers ?? { } ;
5567 const headers : Record < string , string > = {
5668 "Content-Type" : "application/json" ,
5769 Authorization : `Bearer ${ apiKey } ` ,
0 commit comments