@baseai/core
Advanced tools
Comparing version
@@ -132,2 +132,3 @@ import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream'; | ||
maxCalls?: number; | ||
prod?: boolean; | ||
} | ||
@@ -146,2 +147,3 @@ interface ChoiceGenerate { | ||
private hasTools; | ||
private prod; | ||
constructor(options: PipeOptions); | ||
@@ -148,0 +150,0 @@ private getToolsFromPipe; |
@@ -754,4 +754,5 @@ "use strict"; | ||
} | ||
function getApiUrl() { | ||
return isProd() ? "https://api.langbase.com" : "http://localhost:9000"; | ||
function getApiUrl(prod) { | ||
if (prod) return "https://api.langbase.com"; | ||
else return "http://localhost:9000"; | ||
} | ||
@@ -762,3 +763,4 @@ | ||
try { | ||
const endpoint = getApiUrl(); | ||
const prod = isProd(); | ||
const endpoint = getApiUrl(prod); | ||
const response = await fetch(endpoint, { | ||
@@ -820,5 +822,8 @@ mode: "no-cors", | ||
constructor(options) { | ||
const baseUrl = getApiUrl(); | ||
var _a; | ||
this.prod = (_a = options.prod) != null ? _a : isProd(); | ||
const baseUrl = getApiUrl(this.prod); | ||
this.request = new Request({ apiKey: options.apiKey, baseUrl }); | ||
this.pipe = options; | ||
delete this.pipe.prod; | ||
delete this.pipe.apiKey; | ||
@@ -860,3 +865,3 @@ this.tools = this.getToolsFromPipe(this.pipe); | ||
getMessagesToSend(messages, responseMessage, toolResults) { | ||
return isProd() ? toolResults : [...messages, responseMessage, ...toolResults]; | ||
return this.prod ? toolResults : [...messages, responseMessage, ...toolResults]; | ||
} | ||
@@ -944,2 +949,5 @@ isStreamRequested(options) { | ||
if (!runTools) { | ||
if (!stream) { | ||
return response; | ||
} | ||
return response; | ||
@@ -1003,3 +1011,3 @@ } | ||
}; | ||
const isProdEnv = isProd(); | ||
const isProdEnv = this.prod; | ||
if (!isProdEnv) { | ||
@@ -1006,0 +1014,0 @@ const isServerRunning = await isLocalServerRunning(); |
{ | ||
"name": "@baseai/core", | ||
"description": "The Web AI Framework's core - BaseAI.dev", | ||
"version": "0.9.29", | ||
"version": "0.9.30-snapshot.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "sideEffects": false, |
@@ -112,2 +112,3 @@ import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream'; | ||
maxCalls?: number; | ||
prod?: boolean; | ||
} | ||
@@ -126,2 +127,3 @@ interface ChoiceGenerate { | ||
private hasTools; | ||
private prod; | ||
constructor(options: PipeOptions); | ||
@@ -128,0 +130,0 @@ private getToolsFromPipe; |
@@ -745,4 +745,5 @@ "use strict"; | ||
} | ||
function getApiUrl() { | ||
return isProd() ? "https://api.langbase.com" : "http://localhost:9000"; | ||
function getApiUrl(prod) { | ||
if (prod) return "https://api.langbase.com"; | ||
else return "http://localhost:9000"; | ||
} | ||
@@ -753,3 +754,4 @@ | ||
try { | ||
const endpoint = getApiUrl(); | ||
const prod = isProd(); | ||
const endpoint = getApiUrl(prod); | ||
const response = await fetch(endpoint, { | ||
@@ -811,5 +813,8 @@ mode: "no-cors", | ||
constructor(options) { | ||
const baseUrl = getApiUrl(); | ||
var _a; | ||
this.prod = (_a = options.prod) != null ? _a : isProd(); | ||
const baseUrl = getApiUrl(this.prod); | ||
this.request = new Request({ apiKey: options.apiKey, baseUrl }); | ||
this.pipe = options; | ||
delete this.pipe.prod; | ||
delete this.pipe.apiKey; | ||
@@ -851,3 +856,3 @@ this.tools = this.getToolsFromPipe(this.pipe); | ||
getMessagesToSend(messages, responseMessage, toolResults) { | ||
return isProd() ? toolResults : [...messages, responseMessage, ...toolResults]; | ||
return this.prod ? toolResults : [...messages, responseMessage, ...toolResults]; | ||
} | ||
@@ -935,2 +940,5 @@ isStreamRequested(options) { | ||
if (!runTools) { | ||
if (!stream) { | ||
return response; | ||
} | ||
return response; | ||
@@ -994,3 +1002,3 @@ } | ||
}; | ||
const isProdEnv = isProd(); | ||
const isProdEnv = this.prod; | ||
if (!isProdEnv) { | ||
@@ -997,0 +1005,0 @@ const isServerRunning = await isLocalServerRunning(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
463944
0.71%5468
0.66%