@promptbook/core 0.94.0-1 → 0.94.0-3

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.
@@ -1,8 +1,10 @@
1
1
  import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
2
  import { createOllamaExecutionTools } from '../llm-providers/ollama/createOllamaExecutionTools';
3
- import { OllamaExecutionTools } from '../llm-providers/ollama/OllamaExecutionTools';
3
+ import { DEFAULT_OLLAMA_BASE_URL } from '../llm-providers/ollama/OllamaExecutionToolsOptions';
4
+ import type { OllamaExecutionToolsOptions } from '../llm-providers/ollama/OllamaExecutionToolsOptions';
4
5
  import { _OllamaRegistration } from '../llm-providers/ollama/register-constructor';
5
6
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
6
7
  export { createOllamaExecutionTools };
7
- export { OllamaExecutionTools };
8
+ export { DEFAULT_OLLAMA_BASE_URL };
9
+ export type { OllamaExecutionToolsOptions };
8
10
  export { _OllamaRegistration };
@@ -1,4 +1,5 @@
1
1
  import type { ModelVariant } from '../types/ModelVariant';
2
+ import type { number_usd } from '../types/typeAliases';
2
3
  import type { string_model_description } from '../types/typeAliases';
3
4
  import type { string_model_name } from '../types/typeAliases';
4
5
  import type { string_title } from '../types/typeAliases';
@@ -32,7 +33,14 @@ export type AvailableModel = {
32
33
  * @example "Model with 1 billion parameters and advanced reasoning capabilities"
33
34
  */
34
35
  readonly modelDescription?: string_model_description;
36
+ /**
37
+ * Pricing information for the model
38
+ */
39
+ readonly pricing?: {
40
+ readonly prompt: number_usd;
41
+ readonly output: number_usd;
42
+ };
35
43
  };
36
44
  /**
37
- * TODO: (not only [🕘]) Put pricing information here
45
+ * TODO: [🧠] Maybe rename to something else - like `ModelInformation` or `ModelMetadata`
38
46
  */
@@ -4,12 +4,12 @@ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
4
  * Creates a wrapper around LlmExecutionTools that only exposes models matching the filter function
5
5
  *
6
6
  * @param llmTools The original LLM execution tools to wrap
7
- * @param modelFilter Function that determines whether a model should be included
7
+ * @param predicate Function that determines whether a model should be included
8
8
  * @returns A new LlmExecutionTools instance with filtered models
9
9
  *
10
10
  * @public exported from `@promptbook/core`
11
11
  */
12
- export declare function filterModels<TLlmTools extends LlmExecutionTools>(llmTools: TLlmTools, modelFilter: (model: AvailableModel) => boolean): TLlmTools;
12
+ export declare function filterModels<TLlmTools extends LlmExecutionTools>(llmTools: TLlmTools, predicate: (model: AvailableModel) => boolean): TLlmTools;
13
13
  /**
14
14
  * TODO: !!! [models] Test that this is working
15
15
  */
@@ -2,7 +2,7 @@ import type { ClientOptions } from '@anthropic-ai/sdk';
2
2
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
3
  import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
4
4
  /**
5
- * Options for `AnthropicClaudeExecutionTools`
5
+ * Options for `createAnthropicClaudeExecutionTools` and `AnthropicClaudeExecutionTools`
6
6
  *
7
7
  * This extends Anthropic's `ClientOptions` with are directly passed to the Anthropic client.
8
8
  * @public exported from `@promptbook/anthropic-claude`
@@ -3,7 +3,7 @@ import type { string_name } from '../../types/typeAliases';
3
3
  import type { string_token } from '../../types/typeAliases';
4
4
  import type { string_user_id } from '../../types/typeAliases';
5
5
  /**
6
- * Options for `AzureOpenAiExecutionTools`
6
+ * Options for `createAzureOpenAiExecutionTools` and `AzureOpenAiExecutionTools`
7
7
  *
8
8
  * @see https://oai.azure.com/portal/
9
9
  * @public exported from `@promptbook/azure-openai`
@@ -1,7 +1,7 @@
1
1
  import type { createDeepSeek } from '@ai-sdk/deepseek';
2
2
  import type { VercelExecutionToolsOptions } from '../vercel/VercelExecutionToolsOptions';
3
3
  /**
4
- * Options for `DeepseekExecutionTools`
4
+ * Options for `createDeepseekExecutionTools`
5
5
  *
6
6
  * This combines options for Promptbook, Deepseek and Vercel together
7
7
  * @public exported from `@promptbook/deepseek`
@@ -1,7 +1,7 @@
1
1
  import type { createGoogleGenerativeAI } from '@ai-sdk/google';
2
2
  import type { VercelExecutionToolsOptions } from '../vercel/VercelExecutionToolsOptions';
3
3
  /**
4
- * Options for `GoogleExecutionTools`
4
+ * Options for `createGoogleExecutionTools`
5
5
  *
6
6
  * This combines options for Promptbook, Google and Vercel together
7
7
  * @public exported from `@promptbook/google`
@@ -1,12 +1,23 @@
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
- }
1
+ import type { OpenAiExecutionToolsOptions } from '../openai/OpenAiExecutionToolsOptions';
2
+ /**
3
+ * Default base URL for Ollama API
4
+ *
5
+ * @public exported from `@promptbook/ollama`
6
+ */
7
+ export declare const DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434";
8
+ /**
9
+ * Options for `createOllamaExecutionTools`
10
+ *
11
+ * This combines options for Promptbook, Google and Vercel together
12
+ * @public exported from `@promptbook/ollama`
13
+ */
14
+ export type OllamaExecutionToolsOptions = {
15
+ /**
16
+ * Base URL of Ollama API
17
+ *
18
+ * Note: Naming this `baseURL` not `baseUrl` to be consistent with OpenAI API
19
+ *
20
+ * @default `DEFAULT_OLLAMA_BASE_URL`
21
+ */
22
+ baseURL?: string;
23
+ } & Omit<OpenAiExecutionToolsOptions, 'baseURL' | 'userId'>;
@@ -1,11 +1,11 @@
1
- import { OllamaExecutionTools } from "./OllamaExecutionTools";
2
- import { OllamaExecutionToolsOptions } from "./OllamaExecutionToolsOptions";
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions';
3
3
  /**
4
4
  * Execution Tools for calling Ollama API
5
5
  *
6
6
  * @public exported from `@promptbook/ollama`
7
7
  */
8
- export declare const createOllamaExecutionTools: ((options: OllamaExecutionToolsOptions) => OllamaExecutionTools) & {
8
+ export declare const createOllamaExecutionTools: ((ollamaOptions: OllamaExecutionToolsOptions) => LlmExecutionTools) & {
9
9
  packageName: string;
10
10
  className: string;
11
11
  };
@@ -2,7 +2,7 @@ import type { ClientOptions } from 'openai';
2
2
  import type { string_token } from '../../types/typeAliases';
3
3
  import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
4
4
  /**
5
- * Options for `OpenAiAssistantExecutionTools`
5
+ * Options for `createOpenAiAssistantExecutionTools` and `OpenAiAssistantExecutionTools`
6
6
  *
7
7
  * @public exported from `@promptbook/openai`
8
8
  */
@@ -40,7 +40,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
40
40
  /**
41
41
  * List all available OpenAI models that can be used
42
42
  */
43
- listModels(): ReadonlyArray<AvailableModel>;
43
+ listModels(): Promise<ReadonlyArray<AvailableModel>>;
44
44
  /**
45
45
  * Calls OpenAI API to use a chat model.
46
46
  */
@@ -1,7 +1,7 @@
1
1
  import type { ClientOptions } from 'openai';
2
2
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
3
  /**
4
- * Options for `OpenAiExecutionTools`
4
+ * Options for `createOpenAiExecutionTools` and `OpenAiExecutionTools`
5
5
  *
6
6
  * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
7
7
  * Rest is used by the `OpenAiExecutionTools`.
@@ -3,6 +3,8 @@ import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions'
3
3
  /**
4
4
  * Execution Tools for calling OpenAI API
5
5
  *
6
+ * Note: This can be also used for other OpenAI compatible APIs, like Ollama
7
+ *
6
8
  * @public exported from `@promptbook/openai`
7
9
  */
8
10
  export declare const createOpenAiExecutionTools: ((options: OpenAiExecutionToolsOptions) => OpenAiExecutionTools) & {
@@ -1,5 +1,4 @@
1
1
  import type { AvailableModel } from '../../execution/AvailableModel';
2
- import type { number_usd } from '../../types/typeAliases';
3
2
  /**
4
3
  * List of available OpenAI models with pricing
5
4
  *
@@ -9,12 +8,7 @@ import type { number_usd } from '../../types/typeAliases';
9
8
  * @see https://openai.com/api/pricing/
10
9
  * @public exported from `@promptbook/openai`
11
10
  */
12
- export declare const OPENAI_MODELS: ReadonlyArray<AvailableModel & {
13
- pricing?: {
14
- readonly prompt: number_usd;
15
- readonly output: number_usd;
16
- };
17
- }>;
11
+ export declare const OPENAI_MODELS: ReadonlyArray<AvailableModel>;
18
12
  /**
19
13
  * Note: [🤖] Add models of new variant
20
14
  * TODO: [🧠] Some mechanism to propagate unsureness
@@ -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.94.0-0`).
18
+ * It follows semantic versioning (e.g., `0.94.0-2`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.94.0-1",
3
+ "version": "0.94.0-3",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.94.0-1';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.94.0-3';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10365,12 +10365,12 @@
10365
10365
  * Creates a wrapper around LlmExecutionTools that only exposes models matching the filter function
10366
10366
  *
10367
10367
  * @param llmTools The original LLM execution tools to wrap
10368
- * @param modelFilter Function that determines whether a model should be included
10368
+ * @param predicate Function that determines whether a model should be included
10369
10369
  * @returns A new LlmExecutionTools instance with filtered models
10370
10370
  *
10371
10371
  * @public exported from `@promptbook/core`
10372
10372
  */
10373
- function filterModels(llmTools, modelFilter) {
10373
+ function filterModels(llmTools, predicate) {
10374
10374
  const filteredTools = {
10375
10375
  // Keep all properties from the original llmTools
10376
10376
  ...llmTools,
@@ -10387,10 +10387,10 @@
10387
10387
  const originalModels = await llmTools.listModels();
10388
10388
  // Handle both synchronous and Promise return types
10389
10389
  if (originalModels instanceof Promise) {
10390
- return originalModels.then((models) => models.filter(modelFilter));
10390
+ return originalModels.then((models) => models.filter(predicate));
10391
10391
  }
10392
10392
  else {
10393
- return originalModels.filter(modelFilter);
10393
+ return originalModels.filter(predicate);
10394
10394
  }
10395
10395
  },
10396
10396
  };
@@ -11150,7 +11150,7 @@
11150
11150
  packageName: '@promptbook/ollama',
11151
11151
  className: 'OllamaExecutionTools',
11152
11152
  options: {
11153
- baseUrl: 'http://localhost:11434',
11153
+ baseURL: 'http://localhost:11434',
11154
11154
  model: 'llama2',
11155
11155
  maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
11156
11156
  },
@@ -11163,7 +11163,7 @@
11163
11163
  packageName: '@promptbook/ollama',
11164
11164
  className: 'OllamaExecutionTools',
11165
11165
  options: {
11166
- baseUrl: env.OLLAMA_BASE_URL,
11166
+ baseURL: env.OLLAMA_BASE_URL,
11167
11167
  model: env.OLLAMA_MODEL || 'llama2',
11168
11168
  maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
11169
11169
  },