@promptbook/cli 0.93.0 → 0.94.0-1
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 +5 -6
- package/esm/index.es.js +161 -2
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/ollama.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/wizzard.index.d.ts +4 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +3 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +19 -0
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionToolsOptions.d.ts +12 -0
- package/esm/typings/src/llm-providers/ollama/createOllamaExecutionTools.d.ts +11 -0
- package/esm/typings/src/llm-providers/ollama/playground/playground.d.ts +6 -0
- package/esm/typings/src/llm-providers/ollama/register-configuration.d.ts +14 -0
- package/esm/typings/src/llm-providers/ollama/register-constructor.d.ts +15 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +166 -5
- package/umd/index.umd.js.map +1 -1
|
@@ -8,6 +8,8 @@ import { _DeepseekMetadataRegistration } from '../llm-providers/deepseek/registe
|
|
|
8
8
|
import { _DeepseekRegistration } from '../llm-providers/deepseek/register-constructor';
|
|
9
9
|
import { _GoogleMetadataRegistration } from '../llm-providers/google/register-configuration';
|
|
10
10
|
import { _GoogleRegistration } from '../llm-providers/google/register-constructor';
|
|
11
|
+
import { _OllamaMetadataRegistration } from '../llm-providers/ollama/register-configuration';
|
|
12
|
+
import { _OllamaRegistration } from '../llm-providers/ollama/register-constructor';
|
|
11
13
|
import { _OpenAiMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
12
14
|
import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
13
15
|
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
|
|
@@ -36,6 +38,8 @@ export { _DeepseekMetadataRegistration };
|
|
|
36
38
|
export { _DeepseekRegistration };
|
|
37
39
|
export { _GoogleMetadataRegistration };
|
|
38
40
|
export { _GoogleRegistration };
|
|
41
|
+
export { _OllamaMetadataRegistration };
|
|
42
|
+
export { _OllamaRegistration };
|
|
39
43
|
export { _OpenAiMetadataRegistration };
|
|
40
44
|
export { _OpenAiAssistantMetadataRegistration };
|
|
41
45
|
export { _OpenAiRegistration };
|
|
@@ -108,6 +108,7 @@ import { _AnthropicClaudeMetadataRegistration } from '../llm-providers/anthropic
|
|
|
108
108
|
import { _AzureOpenAiMetadataRegistration } from '../llm-providers/azure-openai/register-configuration';
|
|
109
109
|
import { _DeepseekMetadataRegistration } from '../llm-providers/deepseek/register-configuration';
|
|
110
110
|
import { _GoogleMetadataRegistration } from '../llm-providers/google/register-configuration';
|
|
111
|
+
import { _OllamaMetadataRegistration } from '../llm-providers/ollama/register-configuration';
|
|
111
112
|
import { _OpenAiMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
112
113
|
import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
113
114
|
import { migratePipeline } from '../migrations/migratePipeline';
|
|
@@ -255,6 +256,7 @@ export { _AnthropicClaudeMetadataRegistration };
|
|
|
255
256
|
export { _AzureOpenAiMetadataRegistration };
|
|
256
257
|
export { _DeepseekMetadataRegistration };
|
|
257
258
|
export { _GoogleMetadataRegistration };
|
|
259
|
+
export { _OllamaMetadataRegistration };
|
|
258
260
|
export { _OpenAiMetadataRegistration };
|
|
259
261
|
export { _OpenAiAssistantMetadataRegistration };
|
|
260
262
|
export { migratePipeline };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
+
import { createOllamaExecutionTools } from '../llm-providers/ollama/createOllamaExecutionTools';
|
|
3
|
+
import { OllamaExecutionTools } from '../llm-providers/ollama/OllamaExecutionTools';
|
|
4
|
+
import { _OllamaRegistration } from '../llm-providers/ollama/register-constructor';
|
|
5
|
+
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
6
|
+
export { createOllamaExecutionTools };
|
|
7
|
+
export { OllamaExecutionTools };
|
|
8
|
+
export { _OllamaRegistration };
|
|
@@ -79,6 +79,7 @@ import type { AnthropicClaudeExecutionToolsProxiedOptions } from '../llm-provide
|
|
|
79
79
|
import type { AzureOpenAiExecutionToolsOptions } from '../llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions';
|
|
80
80
|
import type { DeepseekExecutionToolsOptions } from '../llm-providers/deepseek/DeepseekExecutionToolsOptions';
|
|
81
81
|
import type { GoogleExecutionToolsOptions } from '../llm-providers/google/GoogleExecutionToolsOptions';
|
|
82
|
+
import type { OllamaExecutionToolsOptions } from '../llm-providers/ollama/OllamaExecutionToolsOptions';
|
|
82
83
|
import type { OpenAiAssistantExecutionToolsOptions } from '../llm-providers/openai/OpenAiAssistantExecutionToolsOptions';
|
|
83
84
|
import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
|
|
84
85
|
import type { VercelExecutionToolsOptions } from '../llm-providers/vercel/VercelExecutionToolsOptions';
|
|
@@ -377,6 +378,7 @@ export type { AnthropicClaudeExecutionToolsProxiedOptions };
|
|
|
377
378
|
export type { AzureOpenAiExecutionToolsOptions };
|
|
378
379
|
export type { DeepseekExecutionToolsOptions };
|
|
379
380
|
export type { GoogleExecutionToolsOptions };
|
|
381
|
+
export type { OllamaExecutionToolsOptions };
|
|
380
382
|
export type { OpenAiAssistantExecutionToolsOptions };
|
|
381
383
|
export type { OpenAiExecutionToolsOptions };
|
|
382
384
|
export type { VercelExecutionToolsOptions };
|
|
@@ -7,6 +7,8 @@ import { _DeepseekMetadataRegistration } from '../llm-providers/deepseek/registe
|
|
|
7
7
|
import { _DeepseekRegistration } from '../llm-providers/deepseek/register-constructor';
|
|
8
8
|
import { _GoogleMetadataRegistration } from '../llm-providers/google/register-configuration';
|
|
9
9
|
import { _GoogleRegistration } from '../llm-providers/google/register-constructor';
|
|
10
|
+
import { _OllamaMetadataRegistration } from '../llm-providers/ollama/register-configuration';
|
|
11
|
+
import { _OllamaRegistration } from '../llm-providers/ollama/register-constructor';
|
|
10
12
|
import { _OpenAiMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
11
13
|
import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
12
14
|
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
|
|
@@ -35,6 +37,8 @@ export { _DeepseekMetadataRegistration };
|
|
|
35
37
|
export { _DeepseekRegistration };
|
|
36
38
|
export { _GoogleMetadataRegistration };
|
|
37
39
|
export { _GoogleRegistration };
|
|
40
|
+
export { _OllamaMetadataRegistration };
|
|
41
|
+
export { _OllamaRegistration };
|
|
38
42
|
export { _OpenAiMetadataRegistration };
|
|
39
43
|
export { _OpenAiAssistantMetadataRegistration };
|
|
40
44
|
export { _OpenAiRegistration };
|
|
@@ -72,6 +72,8 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
72
72
|
readonly taskId: task_id;
|
|
73
73
|
/**
|
|
74
74
|
* Human-readable title of the task - used for displaying in the UI
|
|
75
|
+
*
|
|
76
|
+
* For example name of the book which is being executed
|
|
75
77
|
*/
|
|
76
78
|
readonly title: string;
|
|
77
79
|
/**
|
|
@@ -99,7 +101,7 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
99
101
|
/**
|
|
100
102
|
* Gets just the current value which is mutated during the task processing
|
|
101
103
|
*/
|
|
102
|
-
currentValue: PartialDeep<TTaskResult>;
|
|
104
|
+
readonly currentValue: PartialDeep<TTaskResult>;
|
|
103
105
|
/**
|
|
104
106
|
* List of errors that occurred during the task processing
|
|
105
107
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
|
+
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
|
+
import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions';
|
|
5
|
+
/**
|
|
6
|
+
* Execution Tools for calling a local Ollama model via HTTP API
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/ollama`
|
|
9
|
+
*/
|
|
10
|
+
export declare class OllamaExecutionTools implements LlmExecutionTools {
|
|
11
|
+
protected readonly options: OllamaExecutionToolsOptions;
|
|
12
|
+
private limiter;
|
|
13
|
+
constructor(options: OllamaExecutionToolsOptions);
|
|
14
|
+
get title(): string;
|
|
15
|
+
get description(): string;
|
|
16
|
+
checkConfiguration(): Promise<void>;
|
|
17
|
+
listModels(): Promise<ReadonlyArray<AvailableModel>>;
|
|
18
|
+
callChatModel(prompt: Pick<import('../../types/Prompt').Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<ChatPromptResult>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface OllamaExecutionToolsOptions {
|
|
2
|
+
/** Base URL of Ollama API, e.g., http://localhost:11434 */
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
/** Model name to use for requests */
|
|
5
|
+
model: string;
|
|
6
|
+
/** Optional rate limit: max requests per minute */
|
|
7
|
+
maxRequestsPerMinute?: number;
|
|
8
|
+
/** Verbose logging */
|
|
9
|
+
isVerbose?: boolean;
|
|
10
|
+
/** Optional user identifier */
|
|
11
|
+
userId?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OllamaExecutionTools } from "./OllamaExecutionTools";
|
|
2
|
+
import { OllamaExecutionToolsOptions } from "./OllamaExecutionToolsOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Execution Tools for calling Ollama API
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/ollama`
|
|
7
|
+
*/
|
|
8
|
+
export declare const createOllamaExecutionTools: ((options: OllamaExecutionToolsOptions) => OllamaExecutionTools) & {
|
|
9
|
+
packageName: string;
|
|
10
|
+
className: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Registration } from '../../utils/$Register';
|
|
2
|
+
/**
|
|
3
|
+
* Registration of LLM provider metadata
|
|
4
|
+
*
|
|
5
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
6
|
+
*
|
|
7
|
+
* @public exported from `@promptbook/core`
|
|
8
|
+
* @public exported from `@promptbook/wizzard`
|
|
9
|
+
* @public exported from `@promptbook/cli`
|
|
10
|
+
*/
|
|
11
|
+
export declare const _OllamaMetadataRegistration: Registration;
|
|
12
|
+
/**
|
|
13
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
14
|
+
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Registration } from '../../utils/$Register';
|
|
2
|
+
/**
|
|
3
|
+
* Registration of LLM provider
|
|
4
|
+
*
|
|
5
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
6
|
+
*
|
|
7
|
+
* @public exported from `@promptbook/ollama`
|
|
8
|
+
* @public exported from `@promptbook/wizzard`
|
|
9
|
+
* @public exported from `@promptbook/cli`
|
|
10
|
+
*/
|
|
11
|
+
export declare const _OllamaRegistration: Registration;
|
|
12
|
+
/**
|
|
13
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
14
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
15
|
+
*/
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.
|
|
18
|
+
* It follows semantic versioning (e.g., `0.94.0-0`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
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('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';
|
|
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('node-fetch'), 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', 'node-fetch', '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.fetch$1, 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, fetch$1, 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,6 +41,7 @@
|
|
|
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);
|
|
44
45
|
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
45
46
|
|
|
46
47
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
* @generated
|
|
58
59
|
* @see https://github.com/webgptorg/promptbook
|
|
59
60
|
*/
|
|
60
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
61
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.94.0-1';
|
|
61
62
|
/**
|
|
62
63
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
63
64
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7069,6 +7070,13 @@
|
|
|
7069
7070
|
* Note: This is a flag to prevent `onProgress` call after the pipeline execution is finished
|
|
7070
7071
|
*/
|
|
7071
7072
|
let isReturned = false;
|
|
7073
|
+
// Note: Report all output parameters upfront as empty strings
|
|
7074
|
+
if (onProgress) {
|
|
7075
|
+
const emptyOutputParameters = Object.fromEntries(preparedPipeline.parameters.filter((param) => !param.isInput).map((param) => [param.name, '']));
|
|
7076
|
+
onProgress({
|
|
7077
|
+
outputParameters: emptyOutputParameters,
|
|
7078
|
+
});
|
|
7079
|
+
}
|
|
7072
7080
|
// Note: Check that all input input parameters are defined
|
|
7073
7081
|
for (const parameter of preparedPipeline.parameters.filter(({ isInput }) => isInput)) {
|
|
7074
7082
|
if (inputParameters[parameter.name] === undefined) {
|
|
@@ -16994,6 +17002,157 @@
|
|
|
16994
17002
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
16995
17003
|
*/
|
|
16996
17004
|
|
|
17005
|
+
/**
|
|
17006
|
+
* Registration of LLM provider metadata
|
|
17007
|
+
*
|
|
17008
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
17009
|
+
*
|
|
17010
|
+
* @public exported from `@promptbook/core`
|
|
17011
|
+
* @public exported from `@promptbook/wizzard`
|
|
17012
|
+
* @public exported from `@promptbook/cli`
|
|
17013
|
+
*/
|
|
17014
|
+
const _OllamaMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
17015
|
+
title: 'Ollama',
|
|
17016
|
+
packageName: '@promptbook/ollama',
|
|
17017
|
+
className: 'OllamaExecutionTools',
|
|
17018
|
+
envVariables: ['OLLAMA_BASE_URL', 'OLLAMA_MODEL'],
|
|
17019
|
+
trustLevel: 'CLOSED_LOCAL',
|
|
17020
|
+
order: MODEL_ORDERS.NORMAL,
|
|
17021
|
+
getBoilerplateConfiguration() {
|
|
17022
|
+
return {
|
|
17023
|
+
title: 'Ollama',
|
|
17024
|
+
packageName: '@promptbook/ollama',
|
|
17025
|
+
className: 'OllamaExecutionTools',
|
|
17026
|
+
options: {
|
|
17027
|
+
baseUrl: 'http://localhost:11434',
|
|
17028
|
+
model: 'llama2',
|
|
17029
|
+
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17030
|
+
},
|
|
17031
|
+
};
|
|
17032
|
+
},
|
|
17033
|
+
createConfigurationFromEnv(env) {
|
|
17034
|
+
if (typeof env.OLLAMA_BASE_URL === 'string') {
|
|
17035
|
+
return {
|
|
17036
|
+
title: 'Ollama (from env)',
|
|
17037
|
+
packageName: '@promptbook/ollama',
|
|
17038
|
+
className: 'OllamaExecutionTools',
|
|
17039
|
+
options: {
|
|
17040
|
+
baseUrl: env.OLLAMA_BASE_URL,
|
|
17041
|
+
model: env.OLLAMA_MODEL || 'llama2',
|
|
17042
|
+
maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
|
|
17043
|
+
},
|
|
17044
|
+
};
|
|
17045
|
+
}
|
|
17046
|
+
return null;
|
|
17047
|
+
},
|
|
17048
|
+
});
|
|
17049
|
+
/**
|
|
17050
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17051
|
+
*/
|
|
17052
|
+
|
|
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
|
+
|
|
16997
17156
|
/**
|
|
16998
17157
|
* Registration of LLM provider metadata
|
|
16999
17158
|
*
|
|
@@ -18973,6 +19132,8 @@
|
|
|
18973
19132
|
exports._MarkdownScraperRegistration = _MarkdownScraperRegistration;
|
|
18974
19133
|
exports._MarkitdownScraperMetadataRegistration = _MarkitdownScraperMetadataRegistration;
|
|
18975
19134
|
exports._MarkitdownScraperRegistration = _MarkitdownScraperRegistration;
|
|
19135
|
+
exports._OllamaMetadataRegistration = _OllamaMetadataRegistration;
|
|
19136
|
+
exports._OllamaRegistration = _OllamaRegistration;
|
|
18976
19137
|
exports._OpenAiAssistantMetadataRegistration = _OpenAiAssistantMetadataRegistration;
|
|
18977
19138
|
exports._OpenAiAssistantRegistration = _OpenAiAssistantRegistration;
|
|
18978
19139
|
exports._OpenAiMetadataRegistration = _OpenAiMetadataRegistration;
|