@promptbook/node 0.110.0-8 → 0.110.0
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 +0 -4
- package/esm/index.es.js +487 -97
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +6 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +22 -21
- package/esm/typings/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +8 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.agentReferenceResolver.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +4 -5
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +42 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatInputArea.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +26 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +31 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +24 -2
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +2 -10
- package/esm/typings/src/book-components/Chat/utils/parseCitationMarker.d.ts +75 -0
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +3 -1
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.test.d.ts +1 -0
- package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +17 -4
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +9 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +39 -0
- package/esm/typings/src/types/LlmToolDefinition.d.ts +1 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +9 -0
- package/esm/typings/src/utils/DEFAULT_THINKING_MESSAGES.d.ts +8 -0
- package/esm/typings/src/utils/knowledge/inlineKnowledgeSource.d.ts +38 -0
- package/esm/typings/src/utils/knowledge/inlineKnowledgeSource.test.d.ts +1 -0
- package/esm/typings/src/utils/language/getBrowserPreferredSpeechRecognitionLanguage.d.ts +35 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +487 -97
- package/umd/index.umd.js.map +1 -1
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported arrow directions.
|
|
3
|
+
*
|
|
4
|
+
* @private internal typing helper for `<ArrowIcon/>`
|
|
5
|
+
*/
|
|
6
|
+
type ArrowDirection = 'DOWN' | 'UP';
|
|
7
|
+
/**
|
|
8
|
+
* Props for rendering a directional arrow icon.
|
|
9
|
+
*
|
|
10
|
+
* @private internal props typing for `<ArrowIcon/>`
|
|
11
|
+
*/
|
|
12
|
+
type ArrowIconProps = {
|
|
13
|
+
direction: ArrowDirection;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
1
16
|
/**
|
|
2
17
|
* Shows simple arrow icon pointing up or down
|
|
3
18
|
*
|
|
4
19
|
* @public exported from `@promptbook/components`
|
|
5
20
|
*/
|
|
6
|
-
export declare const ArrowIcon: ({ direction, size }:
|
|
7
|
-
|
|
8
|
-
size: number;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const ArrowIcon: ({ direction, size }: ArrowIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -57,6 +57,15 @@ export declare abstract class BaseCommitmentDefinition<TBookCommitment extends s
|
|
|
57
57
|
* Helper method to append content to the system message
|
|
58
58
|
*/
|
|
59
59
|
protected appendToSystemMessage(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
|
|
60
|
+
/**
|
|
61
|
+
* Helper method to create a new requirements object with updated prompt suffix
|
|
62
|
+
*/
|
|
63
|
+
protected updatePromptSuffix(requirements: AgentModelRequirements, contentUpdate: string | ((currentSuffix: string) => string)): AgentModelRequirements;
|
|
64
|
+
/**
|
|
65
|
+
* Helper method to append content to the prompt suffix
|
|
66
|
+
* Default separator is a single newline for bullet lists.
|
|
67
|
+
*/
|
|
68
|
+
protected appendToPromptSuffix(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
|
|
60
69
|
/**
|
|
61
70
|
* Helper method to add a comment section to the system message
|
|
62
71
|
* Comments are lines starting with # that will be removed from the final system message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Agent as AgentFromKit } from '@openai/agents';
|
|
2
|
+
import OpenAI from 'openai';
|
|
3
|
+
import { TODO_any } from '../../_packages/types.index';
|
|
2
4
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
5
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
6
|
import type { ModelRequirements } from '../../types/ModelRequirements';
|
|
@@ -6,6 +8,42 @@ import type { Prompt } from '../../types/Prompt';
|
|
|
6
8
|
import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
|
|
7
9
|
import type { OpenAiAgentKitExecutionToolsOptions } from './OpenAiAgentKitExecutionToolsOptions';
|
|
8
10
|
import { OpenAiVectorStoreHandler } from './OpenAiVectorStoreHandler';
|
|
11
|
+
/**
|
|
12
|
+
* Represents the AgentKit output configuration used to match OpenAI `response_format` expectations.
|
|
13
|
+
*
|
|
14
|
+
* @private utility of Open AI
|
|
15
|
+
*/
|
|
16
|
+
export type AgentOutputType = 'text' | JsonSchemaDefinition;
|
|
17
|
+
type JsonSchemaDefinitionEntry = {
|
|
18
|
+
type?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
properties?: Record<string, JsonSchemaDefinitionEntry>;
|
|
21
|
+
required?: Array<string>;
|
|
22
|
+
items?: JsonSchemaDefinitionEntry;
|
|
23
|
+
[key: string]: TODO_any;
|
|
24
|
+
};
|
|
25
|
+
type JsonSchemaDefinition = {
|
|
26
|
+
type: 'json_schema';
|
|
27
|
+
name: string;
|
|
28
|
+
strict: boolean;
|
|
29
|
+
schema: {
|
|
30
|
+
type: 'object';
|
|
31
|
+
properties: Record<string, JsonSchemaDefinitionEntry>;
|
|
32
|
+
required: Array<string>;
|
|
33
|
+
additionalProperties: boolean;
|
|
34
|
+
description?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type OpenAiChatResponseFormat = OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming['response_format'];
|
|
38
|
+
/**
|
|
39
|
+
* Maps OpenAI `response_format` payloads to AgentKit output types so the runner can forward
|
|
40
|
+
* structured-output preferences to OpenAI while still reusing the same AgentKit agent instance.
|
|
41
|
+
*
|
|
42
|
+
* @param responseFormat - The OpenAI `response_format` payload from the user request.
|
|
43
|
+
* @returns An Agent output type compatible with the requested schema or `undefined` when no impact is required.
|
|
44
|
+
* @private utility of Open AI
|
|
45
|
+
*/
|
|
46
|
+
export declare function mapResponseFormatToAgentOutputType(responseFormat?: OpenAiChatResponseFormat): AgentOutputType | undefined;
|
|
9
47
|
/**
|
|
10
48
|
* Alias for OpenAI AgentKit agent to avoid naming confusion with Promptbook agents.
|
|
11
49
|
*/
|
|
@@ -82,6 +120,7 @@ export declare class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandl
|
|
|
82
120
|
readonly prompt: Prompt;
|
|
83
121
|
readonly rawPromptContent?: string;
|
|
84
122
|
readonly onProgress: (chunk: ChatPromptResult) => void;
|
|
123
|
+
readonly responseFormatOutputType?: AgentOutputType;
|
|
85
124
|
}): Promise<ChatPromptResult>;
|
|
86
125
|
/**
|
|
87
126
|
* Builds AgentKit input items from the prompt and optional thread.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LlmToolDefinition } from './LlmToolDefinition';
|
|
2
2
|
import type { ModelVariant } from './ModelVariant';
|
|
3
3
|
import type { number_model_temperature, number_seed, string_model_name, string_system_message } from './typeAliases';
|
|
4
|
+
import type OpenAI from 'openai';
|
|
4
5
|
/**
|
|
5
6
|
* Abstract way to specify the LLM.
|
|
6
7
|
* It does not specify the LLM with concrete version itself, only the requirements for the LLM.
|
|
@@ -54,6 +55,14 @@ export type ChatModelRequirements = CommonModelRequirements & {
|
|
|
54
55
|
* Maximum number of tokens that can be generated by the model
|
|
55
56
|
*/
|
|
56
57
|
readonly maxTokens?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Optional OpenAI `response_format` override that should be forwarded to compatible APIs.
|
|
60
|
+
*/
|
|
61
|
+
readonly responseFormat?: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming['response_format'];
|
|
62
|
+
/**
|
|
63
|
+
* Optional OpenAI `tool_choice` override that should be forwarded to compatible APIs.
|
|
64
|
+
*/
|
|
65
|
+
readonly toolChoice?: OpenAI.Chat.Completions.ChatCompletionToolChoiceOption;
|
|
57
66
|
};
|
|
58
67
|
/**
|
|
59
68
|
* Model requirements for the image generation variant
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default placeholder variants shown when an agent is still composing a response.
|
|
3
|
+
*
|
|
4
|
+
* @private BUT maybe export via some package
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_THINKING_MESSAGES: readonly ["Thinking...", "Searching for information...", "Sorting information..."];
|
|
7
|
+
/** @internal */
|
|
8
|
+
export type ThinkingMessageVariant = (typeof DEFAULT_THINKING_MESSAGES)[number];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { string_data_url, string_filename } from '../../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* @@@
|
|
6
|
+
*
|
|
7
|
+
* @private thing of inline knowledge
|
|
8
|
+
*/
|
|
9
|
+
export type InlineKnowledgeSourceFile = {
|
|
10
|
+
readonly filename: string_filename;
|
|
11
|
+
readonly mimeType: string;
|
|
12
|
+
readonly url: string_data_url;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates a data URL that represents the inline knowledge content as a text file.
|
|
16
|
+
*
|
|
17
|
+
* @private thing of inline knowledge
|
|
18
|
+
*/
|
|
19
|
+
export declare function createInlineKnowledgeSourceFile(content: string): InlineKnowledgeSourceFile;
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether the provided source string is a data URL that can be decoded.
|
|
22
|
+
*
|
|
23
|
+
* @private thing of inline knowledge
|
|
24
|
+
*/
|
|
25
|
+
export declare function isDataUrlKnowledgeSource(source: string): source is string_data_url;
|
|
26
|
+
/**
|
|
27
|
+
* Parses a data URL-based knowledge source into its raw buffer, filename, and MIME type.
|
|
28
|
+
*
|
|
29
|
+
* @private thing of inline knowledge
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseDataUrlKnowledgeSource(source: string): {
|
|
32
|
+
readonly buffer: Buffer;
|
|
33
|
+
readonly filename: string_filename;
|
|
34
|
+
readonly mimeType: string;
|
|
35
|
+
} | null;
|
|
36
|
+
/**
|
|
37
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
38
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @@@
|
|
3
|
+
*
|
|
4
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
5
|
+
*/
|
|
6
|
+
type ResolveSpeechRecognitionLanguageOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Overrides the default language resolution when provided.
|
|
9
|
+
*/
|
|
10
|
+
readonly overrideLanguage?: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Optional Accept-Language header string to derive the speaker language from server-side requests.
|
|
13
|
+
*/
|
|
14
|
+
readonly acceptLanguageHeader?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Parses the primary language out of an Accept-Language header value.
|
|
18
|
+
*
|
|
19
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseSpeechRecognitionLanguageFromAcceptLanguageHeader(header?: string | null): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Reads the browser-reported preferred language list and returns the first valid tag.
|
|
24
|
+
*
|
|
25
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
26
|
+
*/
|
|
27
|
+
export declare function getBrowserPreferredSpeechRecognitionLanguage(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a speech recognition language tag by checking an optional override, then the Accept-Language header,
|
|
30
|
+
* then the browser preferences, and finally falling back to a default of `en-US`.
|
|
31
|
+
*
|
|
32
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveSpeechRecognitionLanguage(options?: ResolveSpeechRecognitionLanguageOptions): string;
|
|
35
|
+
export {};
|
|
@@ -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.110.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.110.0-11`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.110.0
|
|
3
|
+
"version": "0.110.0",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"module": "./esm/index.es.js",
|
|
97
97
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"@promptbook/core": "0.110.0
|
|
99
|
+
"@promptbook/core": "0.110.0"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@mozilla/readability": "0.6.0",
|