@promptbook/cli 0.94.0-1 → 0.94.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/esm/index.es.js +181 -223
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/ollama.index.d.ts +4 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +9 -1
- package/esm/typings/src/llm-providers/_common/filterModels.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/GoogleExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionToolsOptions.d.ts +23 -12
- package/esm/typings/src/llm-providers/ollama/createOllamaExecutionTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/createOpenAiExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -7
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +185 -227
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +0 -19
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('prompts'), require('path'), require('fs/promises'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('socket.io-client'), require('rxjs'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'prompts', 'path', 'fs/promises', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'socket.io-client', 'rxjs', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.prompts, global.path, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.crypto, global.socket_ioClient, global.rxjs, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.Anthropic, global.Bottleneck, global.openai, global.
|
|
5
|
-
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, prompts, path, promises, dotenv, hexEncoder, sha256, crypto, socket_ioClient, rxjs, child_process, JSZip, prettier, parserHtml, papaparse, cryptoJs, mimeTypes, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, Anthropic, Bottleneck, openai,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('prompts'), require('path'), require('fs/promises'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('socket.io-client'), require('rxjs'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'prompts', 'path', 'fs/promises', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'socket.io-client', 'rxjs', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.prompts, global.path, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.crypto, global.socket_ioClient, global.rxjs, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.Anthropic, global.Bottleneck, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
+
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, prompts, path, promises, dotenv, hexEncoder, sha256, crypto, socket_ioClient, rxjs, child_process, JSZip, prettier, parserHtml, papaparse, cryptoJs, mimeTypes, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, Anthropic, Bottleneck, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
var swaggerUi__default = /*#__PURE__*/_interopDefaultLegacy(swaggerUi);
|
|
42
42
|
var Anthropic__default = /*#__PURE__*/_interopDefaultLegacy(Anthropic);
|
|
43
43
|
var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
|
|
44
|
-
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch$1);
|
|
45
44
|
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
46
45
|
|
|
47
46
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
* @generated
|
|
59
58
|
* @see https://github.com/webgptorg/promptbook
|
|
60
59
|
*/
|
|
61
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.94.0-
|
|
60
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.94.0-2';
|
|
62
61
|
/**
|
|
63
62
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
64
63
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -17024,7 +17023,7 @@
|
|
|
17024
17023
|
packageName: '@promptbook/ollama',
|
|
17025
17024
|
className: 'OllamaExecutionTools',
|
|
17026
17025
|
options: {
|
|
17027
|
-
|
|
17026
|
+
baseURL: 'http://localhost:11434',
|
|
17028
17027
|
model: 'llama2',
|
|
17029
17028
|
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17030
17029
|
},
|
|
@@ -17037,7 +17036,7 @@
|
|
|
17037
17036
|
packageName: '@promptbook/ollama',
|
|
17038
17037
|
className: 'OllamaExecutionTools',
|
|
17039
17038
|
options: {
|
|
17040
|
-
|
|
17039
|
+
baseURL: env.OLLAMA_BASE_URL,
|
|
17041
17040
|
model: env.OLLAMA_MODEL || 'llama2',
|
|
17042
17041
|
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17043
17042
|
},
|
|
@@ -17050,203 +17049,6 @@
|
|
|
17050
17049
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17051
17050
|
*/
|
|
17052
17051
|
|
|
17053
|
-
/**
|
|
17054
|
-
* Execution Tools for calling a local Ollama model via HTTP API
|
|
17055
|
-
*
|
|
17056
|
-
* @public exported from `@promptbook/ollama`
|
|
17057
|
-
*/
|
|
17058
|
-
class OllamaExecutionTools {
|
|
17059
|
-
constructor(options) {
|
|
17060
|
-
this.options = options;
|
|
17061
|
-
this.limiter = new Bottleneck__default["default"]({
|
|
17062
|
-
minTime: 60000 / (options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
|
|
17063
|
-
});
|
|
17064
|
-
}
|
|
17065
|
-
get title() {
|
|
17066
|
-
return 'Ollama';
|
|
17067
|
-
}
|
|
17068
|
-
get description() {
|
|
17069
|
-
return 'Local Ollama LLM via HTTP';
|
|
17070
|
-
}
|
|
17071
|
-
async checkConfiguration() {
|
|
17072
|
-
const res = await fetch__default["default"](`${this.options.baseUrl}/models`);
|
|
17073
|
-
if (!res.ok)
|
|
17074
|
-
throw new UnexpectedError(`Failed to reach Ollama API at ${this.options.baseUrl}`);
|
|
17075
|
-
}
|
|
17076
|
-
async listModels() {
|
|
17077
|
-
const res = await fetch__default["default"](`${this.options.baseUrl}/models`);
|
|
17078
|
-
if (!res.ok)
|
|
17079
|
-
throw new UnexpectedError(`Error listing Ollama models: ${res.statusText}`);
|
|
17080
|
-
const data = (await res.json());
|
|
17081
|
-
return data.map((m) => ({ modelName: m.name, modelVariant: 'CHAT' }));
|
|
17082
|
-
}
|
|
17083
|
-
async callChatModel(prompt) {
|
|
17084
|
-
const { content, parameters, modelRequirements } = prompt;
|
|
17085
|
-
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
17086
|
-
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
17087
|
-
}
|
|
17088
|
-
const modelName = modelRequirements.modelName || this.options.model;
|
|
17089
|
-
const body = {
|
|
17090
|
-
model: modelName,
|
|
17091
|
-
messages: [
|
|
17092
|
-
...(modelRequirements.systemMessage
|
|
17093
|
-
? [{ role: 'system', content: modelRequirements.systemMessage }]
|
|
17094
|
-
: []),
|
|
17095
|
-
{ role: 'user', content: content },
|
|
17096
|
-
],
|
|
17097
|
-
parameters: parameters,
|
|
17098
|
-
};
|
|
17099
|
-
const start = $getCurrentDate();
|
|
17100
|
-
const res = await this.limiter.schedule(() => fetch__default["default"](`${this.options.baseUrl}/chat/completions`, {
|
|
17101
|
-
method: 'POST',
|
|
17102
|
-
headers: { 'Content-Type': 'application/json' },
|
|
17103
|
-
body: JSON.stringify(body),
|
|
17104
|
-
}));
|
|
17105
|
-
if (!res.ok)
|
|
17106
|
-
throw new PipelineExecutionError(`Ollama API error: ${res.statusText}`);
|
|
17107
|
-
const json = await res.json();
|
|
17108
|
-
const complete = $getCurrentDate();
|
|
17109
|
-
if (!json.choices || !json.choices[0]) {
|
|
17110
|
-
throw new PipelineExecutionError('No choices from Ollama');
|
|
17111
|
-
}
|
|
17112
|
-
const resultContent = json.choices[0].message.content;
|
|
17113
|
-
const usage = { price: { value: 0, isUncertain: true }, input: {}, output: {} }; /* <- !!! */
|
|
17114
|
-
return exportJson({
|
|
17115
|
-
name: 'promptResult',
|
|
17116
|
-
message: 'Result of Ollama',
|
|
17117
|
-
order: [],
|
|
17118
|
-
value: {
|
|
17119
|
-
content: resultContent,
|
|
17120
|
-
modelName,
|
|
17121
|
-
timing: { start, complete },
|
|
17122
|
-
usage,
|
|
17123
|
-
rawPromptContent: content,
|
|
17124
|
-
rawRequest: body,
|
|
17125
|
-
rawResponse: json,
|
|
17126
|
-
},
|
|
17127
|
-
});
|
|
17128
|
-
}
|
|
17129
|
-
}
|
|
17130
|
-
|
|
17131
|
-
/**
|
|
17132
|
-
* Execution Tools for calling Ollama API
|
|
17133
|
-
*
|
|
17134
|
-
* @public exported from `@promptbook/ollama`
|
|
17135
|
-
*/
|
|
17136
|
-
const createOllamaExecutionTools = Object.assign((options) => new OllamaExecutionTools(options), {
|
|
17137
|
-
packageName: '@promptbook/ollama',
|
|
17138
|
-
className: 'OllamaExecutionTools',
|
|
17139
|
-
});
|
|
17140
|
-
|
|
17141
|
-
/**
|
|
17142
|
-
* Registration of LLM provider
|
|
17143
|
-
*
|
|
17144
|
-
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
17145
|
-
*
|
|
17146
|
-
* @public exported from `@promptbook/ollama`
|
|
17147
|
-
* @public exported from `@promptbook/wizzard`
|
|
17148
|
-
* @public exported from `@promptbook/cli`
|
|
17149
|
-
*/
|
|
17150
|
-
const _OllamaRegistration = $llmToolsRegister.register(createOllamaExecutionTools);
|
|
17151
|
-
/**
|
|
17152
|
-
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
17153
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17154
|
-
*/
|
|
17155
|
-
|
|
17156
|
-
/**
|
|
17157
|
-
* Registration of LLM provider metadata
|
|
17158
|
-
*
|
|
17159
|
-
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
17160
|
-
*
|
|
17161
|
-
* @public exported from `@promptbook/core`
|
|
17162
|
-
* @public exported from `@promptbook/wizzard`
|
|
17163
|
-
* @public exported from `@promptbook/cli`
|
|
17164
|
-
*/
|
|
17165
|
-
const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
17166
|
-
title: 'Open AI',
|
|
17167
|
-
packageName: '@promptbook/openai',
|
|
17168
|
-
className: 'OpenAiExecutionTools',
|
|
17169
|
-
envVariables: ['OPENAI_API_KEY'],
|
|
17170
|
-
trustLevel: 'CLOSED',
|
|
17171
|
-
order: MODEL_ORDERS.TOP_TIER,
|
|
17172
|
-
getBoilerplateConfiguration() {
|
|
17173
|
-
return {
|
|
17174
|
-
title: 'Open AI',
|
|
17175
|
-
packageName: '@promptbook/openai',
|
|
17176
|
-
className: 'OpenAiExecutionTools',
|
|
17177
|
-
options: {
|
|
17178
|
-
apiKey: 'sk-',
|
|
17179
|
-
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17180
|
-
},
|
|
17181
|
-
};
|
|
17182
|
-
},
|
|
17183
|
-
createConfigurationFromEnv(env) {
|
|
17184
|
-
// Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
|
|
17185
|
-
if (typeof env.OPENAI_API_KEY === 'string') {
|
|
17186
|
-
return {
|
|
17187
|
-
title: 'Open AI (from env)',
|
|
17188
|
-
packageName: '@promptbook/openai',
|
|
17189
|
-
className: 'OpenAiExecutionTools',
|
|
17190
|
-
options: {
|
|
17191
|
-
apiKey: env.OPENAI_API_KEY,
|
|
17192
|
-
},
|
|
17193
|
-
};
|
|
17194
|
-
}
|
|
17195
|
-
return null;
|
|
17196
|
-
},
|
|
17197
|
-
});
|
|
17198
|
-
/**
|
|
17199
|
-
* Registration of the OpenAI Assistant metadata
|
|
17200
|
-
*
|
|
17201
|
-
* Note: [🏐] Configurations registrations are done in the metadata registration section, but the constructor registration is handled separately.
|
|
17202
|
-
*
|
|
17203
|
-
* @public exported from `@promptbook/core`
|
|
17204
|
-
* @public exported from `@promptbook/wizzard`
|
|
17205
|
-
* @public exported from `@promptbook/cli`
|
|
17206
|
-
*/
|
|
17207
|
-
const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
17208
|
-
title: 'Open AI Assistant',
|
|
17209
|
-
packageName: '@promptbook/openai',
|
|
17210
|
-
className: 'OpenAiAssistantExecutionTools',
|
|
17211
|
-
envVariables: null,
|
|
17212
|
-
// <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
|
|
17213
|
-
trustLevel: 'CLOSED',
|
|
17214
|
-
order: MODEL_ORDERS.NORMAL,
|
|
17215
|
-
getBoilerplateConfiguration() {
|
|
17216
|
-
return {
|
|
17217
|
-
title: 'Open AI Assistant',
|
|
17218
|
-
packageName: '@promptbook/openai',
|
|
17219
|
-
className: 'OpenAiAssistantExecutionTools',
|
|
17220
|
-
options: {
|
|
17221
|
-
apiKey: 'sk-',
|
|
17222
|
-
assistantId: 'asst_',
|
|
17223
|
-
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17224
|
-
},
|
|
17225
|
-
};
|
|
17226
|
-
},
|
|
17227
|
-
createConfigurationFromEnv(env) {
|
|
17228
|
-
return null;
|
|
17229
|
-
/*
|
|
17230
|
-
if (typeof env.OPENAI_API_KEY === 'string' || typeof env.OPENAI_XXX === 'string') {
|
|
17231
|
-
return {
|
|
17232
|
-
title: 'Open AI Assistant (from env)',
|
|
17233
|
-
packageName: '@promptbook/openai',
|
|
17234
|
-
className: 'OpenAiAssistantExecutionTools',
|
|
17235
|
-
options: {
|
|
17236
|
-
apiKey: env.OPENAI_API_KEY!,
|
|
17237
|
-
assistantId: env.OPENAI_XXX!
|
|
17238
|
-
},
|
|
17239
|
-
};
|
|
17240
|
-
}
|
|
17241
|
-
|
|
17242
|
-
return null;
|
|
17243
|
-
*/
|
|
17244
|
-
},
|
|
17245
|
-
});
|
|
17246
|
-
/**
|
|
17247
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17248
|
-
*/
|
|
17249
|
-
|
|
17250
17052
|
/**
|
|
17251
17053
|
* Computes the usage of the OpenAI API based on the response from OpenAI
|
|
17252
17054
|
*
|
|
@@ -17359,7 +17161,7 @@
|
|
|
17359
17161
|
/**
|
|
17360
17162
|
* List all available OpenAI models that can be used
|
|
17361
17163
|
*/
|
|
17362
|
-
listModels() {
|
|
17164
|
+
async listModels() {
|
|
17363
17165
|
/*
|
|
17364
17166
|
Note: Dynamic lising of the models
|
|
17365
17167
|
const models = await this.openai.models.list({});
|
|
@@ -17367,7 +17169,26 @@
|
|
|
17367
17169
|
console.log({ models });
|
|
17368
17170
|
console.log(models.data);
|
|
17369
17171
|
*/
|
|
17370
|
-
|
|
17172
|
+
const client = await this.getClient();
|
|
17173
|
+
const rawModelsList = await client.models.list();
|
|
17174
|
+
const availableModels = rawModelsList.data
|
|
17175
|
+
.sort((a, b) => (a.created > b.created ? 1 : -1))
|
|
17176
|
+
.map((modelFromApi) => {
|
|
17177
|
+
// TODO: !!!! What about other model compatibilities?
|
|
17178
|
+
const modelFromList = OPENAI_MODELS.find(({ modelName }) => modelName === modelFromApi.id ||
|
|
17179
|
+
modelName.startsWith(modelFromApi.id) ||
|
|
17180
|
+
modelFromApi.id.startsWith(modelName));
|
|
17181
|
+
if (modelFromList !== undefined) {
|
|
17182
|
+
return modelFromList;
|
|
17183
|
+
}
|
|
17184
|
+
return {
|
|
17185
|
+
modelVariant: 'CHAT',
|
|
17186
|
+
modelTitle: modelFromApi.id,
|
|
17187
|
+
modelName: modelFromApi.id,
|
|
17188
|
+
modelDescription: '',
|
|
17189
|
+
};
|
|
17190
|
+
});
|
|
17191
|
+
return availableModels;
|
|
17371
17192
|
}
|
|
17372
17193
|
/**
|
|
17373
17194
|
* Calls OpenAI API to use a chat model.
|
|
@@ -17647,6 +17468,163 @@
|
|
|
17647
17468
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
17648
17469
|
*/
|
|
17649
17470
|
|
|
17471
|
+
/**
|
|
17472
|
+
* Execution Tools for calling OpenAI API
|
|
17473
|
+
*
|
|
17474
|
+
* Note: This can be also used for other OpenAI compatible APIs, like Ollama
|
|
17475
|
+
*
|
|
17476
|
+
* @public exported from `@promptbook/openai`
|
|
17477
|
+
*/
|
|
17478
|
+
const createOpenAiExecutionTools = Object.assign((options) => {
|
|
17479
|
+
// TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
|
|
17480
|
+
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
17481
|
+
options = { ...options, dangerouslyAllowBrowser: true };
|
|
17482
|
+
}
|
|
17483
|
+
return new OpenAiExecutionTools(options);
|
|
17484
|
+
}, {
|
|
17485
|
+
packageName: '@promptbook/openai',
|
|
17486
|
+
className: 'OpenAiExecutionTools',
|
|
17487
|
+
});
|
|
17488
|
+
/**
|
|
17489
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
17490
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
17491
|
+
*/
|
|
17492
|
+
|
|
17493
|
+
/**
|
|
17494
|
+
* Default base URL for Ollama API
|
|
17495
|
+
*
|
|
17496
|
+
* @public exported from `@promptbook/ollama`
|
|
17497
|
+
*/
|
|
17498
|
+
const DEFAULT_OLLAMA_BASE_URL = 'http://localhost:11434'; // <- TODO: !!!! What is the correct base URL? /v1?
|
|
17499
|
+
|
|
17500
|
+
/**
|
|
17501
|
+
* Execution Tools for calling Ollama API
|
|
17502
|
+
*
|
|
17503
|
+
* @public exported from `@promptbook/ollama`
|
|
17504
|
+
*/
|
|
17505
|
+
const createOllamaExecutionTools = Object.assign((ollamaOptions) => {
|
|
17506
|
+
const openAiCompatibleOptions = {
|
|
17507
|
+
baseURL: DEFAULT_OLLAMA_BASE_URL,
|
|
17508
|
+
...ollamaOptions,
|
|
17509
|
+
userId: 'ollama',
|
|
17510
|
+
};
|
|
17511
|
+
// TODO: !!!! Listing the models - do it dynamically in OpenAiExecutionTools
|
|
17512
|
+
// TODO: !!!! Do not allow to create Assistant from OpenAi compatible tools
|
|
17513
|
+
return createOpenAiExecutionTools(openAiCompatibleOptions);
|
|
17514
|
+
}, {
|
|
17515
|
+
packageName: '@promptbook/ollama',
|
|
17516
|
+
className: 'OllamaExecutionTools',
|
|
17517
|
+
});
|
|
17518
|
+
|
|
17519
|
+
/**
|
|
17520
|
+
* Registration of LLM provider
|
|
17521
|
+
*
|
|
17522
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
17523
|
+
*
|
|
17524
|
+
* @public exported from `@promptbook/ollama`
|
|
17525
|
+
* @public exported from `@promptbook/wizzard`
|
|
17526
|
+
* @public exported from `@promptbook/cli`
|
|
17527
|
+
*/
|
|
17528
|
+
const _OllamaRegistration = $llmToolsRegister.register(createOllamaExecutionTools);
|
|
17529
|
+
/**
|
|
17530
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
17531
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17532
|
+
*/
|
|
17533
|
+
|
|
17534
|
+
/**
|
|
17535
|
+
* Registration of LLM provider metadata
|
|
17536
|
+
*
|
|
17537
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
17538
|
+
*
|
|
17539
|
+
* @public exported from `@promptbook/core`
|
|
17540
|
+
* @public exported from `@promptbook/wizzard`
|
|
17541
|
+
* @public exported from `@promptbook/cli`
|
|
17542
|
+
*/
|
|
17543
|
+
const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
17544
|
+
title: 'Open AI',
|
|
17545
|
+
packageName: '@promptbook/openai',
|
|
17546
|
+
className: 'OpenAiExecutionTools',
|
|
17547
|
+
envVariables: ['OPENAI_API_KEY'],
|
|
17548
|
+
trustLevel: 'CLOSED',
|
|
17549
|
+
order: MODEL_ORDERS.TOP_TIER,
|
|
17550
|
+
getBoilerplateConfiguration() {
|
|
17551
|
+
return {
|
|
17552
|
+
title: 'Open AI',
|
|
17553
|
+
packageName: '@promptbook/openai',
|
|
17554
|
+
className: 'OpenAiExecutionTools',
|
|
17555
|
+
options: {
|
|
17556
|
+
apiKey: 'sk-',
|
|
17557
|
+
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17558
|
+
},
|
|
17559
|
+
};
|
|
17560
|
+
},
|
|
17561
|
+
createConfigurationFromEnv(env) {
|
|
17562
|
+
// Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
|
|
17563
|
+
if (typeof env.OPENAI_API_KEY === 'string') {
|
|
17564
|
+
return {
|
|
17565
|
+
title: 'Open AI (from env)',
|
|
17566
|
+
packageName: '@promptbook/openai',
|
|
17567
|
+
className: 'OpenAiExecutionTools',
|
|
17568
|
+
options: {
|
|
17569
|
+
apiKey: env.OPENAI_API_KEY,
|
|
17570
|
+
},
|
|
17571
|
+
};
|
|
17572
|
+
}
|
|
17573
|
+
return null;
|
|
17574
|
+
},
|
|
17575
|
+
});
|
|
17576
|
+
/**
|
|
17577
|
+
* Registration of the OpenAI Assistant metadata
|
|
17578
|
+
*
|
|
17579
|
+
* Note: [🏐] Configurations registrations are done in the metadata registration section, but the constructor registration is handled separately.
|
|
17580
|
+
*
|
|
17581
|
+
* @public exported from `@promptbook/core`
|
|
17582
|
+
* @public exported from `@promptbook/wizzard`
|
|
17583
|
+
* @public exported from `@promptbook/cli`
|
|
17584
|
+
*/
|
|
17585
|
+
const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
17586
|
+
title: 'Open AI Assistant',
|
|
17587
|
+
packageName: '@promptbook/openai',
|
|
17588
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
17589
|
+
envVariables: null,
|
|
17590
|
+
// <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
|
|
17591
|
+
trustLevel: 'CLOSED',
|
|
17592
|
+
order: MODEL_ORDERS.NORMAL,
|
|
17593
|
+
getBoilerplateConfiguration() {
|
|
17594
|
+
return {
|
|
17595
|
+
title: 'Open AI Assistant',
|
|
17596
|
+
packageName: '@promptbook/openai',
|
|
17597
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
17598
|
+
options: {
|
|
17599
|
+
apiKey: 'sk-',
|
|
17600
|
+
assistantId: 'asst_',
|
|
17601
|
+
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17602
|
+
},
|
|
17603
|
+
};
|
|
17604
|
+
},
|
|
17605
|
+
createConfigurationFromEnv(env) {
|
|
17606
|
+
return null;
|
|
17607
|
+
/*
|
|
17608
|
+
if (typeof env.OPENAI_API_KEY === 'string' || typeof env.OPENAI_XXX === 'string') {
|
|
17609
|
+
return {
|
|
17610
|
+
title: 'Open AI Assistant (from env)',
|
|
17611
|
+
packageName: '@promptbook/openai',
|
|
17612
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
17613
|
+
options: {
|
|
17614
|
+
apiKey: env.OPENAI_API_KEY!,
|
|
17615
|
+
assistantId: env.OPENAI_XXX!
|
|
17616
|
+
},
|
|
17617
|
+
};
|
|
17618
|
+
}
|
|
17619
|
+
|
|
17620
|
+
return null;
|
|
17621
|
+
*/
|
|
17622
|
+
},
|
|
17623
|
+
});
|
|
17624
|
+
/**
|
|
17625
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17626
|
+
*/
|
|
17627
|
+
|
|
17650
17628
|
/**
|
|
17651
17629
|
* Execution Tools for calling OpenAI API Assistants
|
|
17652
17630
|
*
|
|
@@ -17834,26 +17812,6 @@
|
|
|
17834
17812
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
17835
17813
|
*/
|
|
17836
17814
|
|
|
17837
|
-
/**
|
|
17838
|
-
* Execution Tools for calling OpenAI API
|
|
17839
|
-
*
|
|
17840
|
-
* @public exported from `@promptbook/openai`
|
|
17841
|
-
*/
|
|
17842
|
-
const createOpenAiExecutionTools = Object.assign((options) => {
|
|
17843
|
-
// TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
|
|
17844
|
-
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
17845
|
-
options = { ...options, dangerouslyAllowBrowser: true };
|
|
17846
|
-
}
|
|
17847
|
-
return new OpenAiExecutionTools(options);
|
|
17848
|
-
}, {
|
|
17849
|
-
packageName: '@promptbook/openai',
|
|
17850
|
-
className: 'OpenAiExecutionTools',
|
|
17851
|
-
});
|
|
17852
|
-
/**
|
|
17853
|
-
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
17854
|
-
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
17855
|
-
*/
|
|
17856
|
-
|
|
17857
17815
|
/**
|
|
17858
17816
|
* Registration of LLM provider
|
|
17859
17817
|
*
|