MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / createRequest

Method createRequest

packages/core/src/pipes/pipes.ts:389–418  ·  view source on GitHub ↗
(endpoint: string, body: any)

Source from the content-addressed store, hash-verified

387 }
388
389 private async createRequest<T>(endpoint: string, body: any): Promise<T> {
390 const isProdEnv = this.prod;
391 const prodOptions = {
392 endpoint,
393 body: {
394 ...body,
395 name: this.pipe.name,
396 },
397 };
398
399 let localOptions = {} as any;
400
401 if (!isProdEnv) {
402 const providerString = this.pipe.model.split(':')[0];
403 const modelProvider = getProvider(providerString);
404 localOptions = {
405 endpoint,
406 body: {
407 ...body,
408 pipe: this.pipe,
409 llmApiKey: getLLMApiKey(modelProvider),
410 },
411 };
412
413 const isServerRunning = await isLocalServerRunning();
414 if (!isServerRunning) return {} as T;
415 }
416
417 return this.request.post<T>(isProdEnv ? prodOptions : localOptions);
418 }
419}
420
421/**

Callers

nothing calls this directly

Calls 4

getProviderFunction · 0.90
getLLMApiKeyFunction · 0.90
isLocalServerRunningFunction · 0.90
postMethod · 0.80

Tested by

no test coverage detected