@promptbook/openai 0.103.0-48 → 0.103.0-49
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/esm/index.es.js +50 -22
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +1 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +12 -2
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +14 -8
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +28 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/config.d.ts +1 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +2 -2
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/ExecutionTask.d.ts +2 -2
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +6 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +11 -3
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +6 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +6 -1
- package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
- package/esm/typings/src/utils/color/Color.d.ts +7 -0
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +50 -22
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-49';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -580,6 +580,9 @@
|
|
|
580
580
|
if (hex.length === 3) {
|
|
581
581
|
return Color.fromHex3(hex);
|
|
582
582
|
}
|
|
583
|
+
if (hex.length === 4) {
|
|
584
|
+
return Color.fromHex4(hex);
|
|
585
|
+
}
|
|
583
586
|
if (hex.length === 6) {
|
|
584
587
|
return Color.fromHex6(hex);
|
|
585
588
|
}
|
|
@@ -600,6 +603,19 @@
|
|
|
600
603
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
601
604
|
return take(new Color(r, g, b));
|
|
602
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
608
|
+
*
|
|
609
|
+
* @param color in hex for example `09df`
|
|
610
|
+
* @returns Color object
|
|
611
|
+
*/
|
|
612
|
+
static fromHex4(hex) {
|
|
613
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
614
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
615
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
616
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
617
|
+
return take(new Color(r, g, b, a));
|
|
618
|
+
}
|
|
603
619
|
/**
|
|
604
620
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
605
621
|
*
|
|
@@ -790,7 +806,8 @@
|
|
|
790
806
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
791
807
|
*/
|
|
792
808
|
static isHexColorString(value) {
|
|
793
|
-
return typeof value === 'string' &&
|
|
809
|
+
return (typeof value === 'string' &&
|
|
810
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
794
811
|
}
|
|
795
812
|
/**
|
|
796
813
|
* Creates new Color object
|
|
@@ -1097,6 +1114,7 @@
|
|
|
1097
1114
|
({
|
|
1098
1115
|
TITLE: Color.fromHex('#244EA8'),
|
|
1099
1116
|
LINE: Color.fromHex('#eeeeee'),
|
|
1117
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1100
1118
|
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1101
1119
|
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1102
1120
|
});
|
|
@@ -1476,7 +1494,7 @@
|
|
|
1476
1494
|
TODO: [🧠] Is there a better implementation?
|
|
1477
1495
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1478
1496
|
> for (const propertyName of propertyNames) {
|
|
1479
|
-
> const value = (objectValue as
|
|
1497
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
1480
1498
|
> if (value && typeof value === 'object') {
|
|
1481
1499
|
> deepClone(value);
|
|
1482
1500
|
> }
|
|
@@ -3562,11 +3580,12 @@
|
|
|
3562
3580
|
*
|
|
3563
3581
|
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
3564
3582
|
*
|
|
3565
|
-
*
|
|
3583
|
+
* Note: [🦖] There are several different things in Promptbook:
|
|
3566
3584
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
3567
3585
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
3568
3586
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
3569
3587
|
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
3588
|
+
* - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
|
|
3570
3589
|
*
|
|
3571
3590
|
* @public exported from `@promptbook/openai`
|
|
3572
3591
|
*/
|
|
@@ -3601,6 +3620,12 @@
|
|
|
3601
3620
|
* Calls OpenAI API to use a chat model.
|
|
3602
3621
|
*/
|
|
3603
3622
|
async callChatModel(prompt) {
|
|
3623
|
+
return this.callChatModelStream(prompt, () => { });
|
|
3624
|
+
}
|
|
3625
|
+
/**
|
|
3626
|
+
* Calls OpenAI API to use a chat model with streaming.
|
|
3627
|
+
*/
|
|
3628
|
+
async callChatModelStream(prompt, onProgress) {
|
|
3604
3629
|
var _a, _b, _c;
|
|
3605
3630
|
if (this.options.isVerbose) {
|
|
3606
3631
|
console.info('💬 OpenAI callChatModel call', { prompt });
|
|
@@ -3668,21 +3693,24 @@
|
|
|
3668
3693
|
console.info('connect', stream.currentEvent);
|
|
3669
3694
|
}
|
|
3670
3695
|
});
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
this.options.isVerbose &&
|
|
3675
|
-
messageDelta &&
|
|
3676
|
-
messageDelta.content &&
|
|
3677
|
-
messageDelta.content[0] &&
|
|
3678
|
-
messageDelta.content[0].type === 'text'
|
|
3679
|
-
) {
|
|
3680
|
-
console.info('messageDelta', messageDelta.content[0].text?.value);
|
|
3696
|
+
stream.on('textDelta', (textDelta, snapshot) => {
|
|
3697
|
+
if (this.options.isVerbose && textDelta.value) {
|
|
3698
|
+
console.info('textDelta', textDelta.value);
|
|
3681
3699
|
}
|
|
3682
|
-
|
|
3683
|
-
|
|
3700
|
+
const chunk = {
|
|
3701
|
+
content: textDelta.value || '',
|
|
3702
|
+
modelName: 'assistant',
|
|
3703
|
+
timing: {
|
|
3704
|
+
start,
|
|
3705
|
+
complete: $getCurrentDate(),
|
|
3706
|
+
},
|
|
3707
|
+
usage: UNCERTAIN_USAGE,
|
|
3708
|
+
rawPromptContent,
|
|
3709
|
+
rawRequest,
|
|
3710
|
+
rawResponse: snapshot,
|
|
3711
|
+
};
|
|
3712
|
+
onProgress(chunk);
|
|
3684
3713
|
});
|
|
3685
|
-
*/
|
|
3686
3714
|
stream.on('messageCreated', (message) => {
|
|
3687
3715
|
if (this.options.isVerbose) {
|
|
3688
3716
|
console.info('messageCreated', message);
|
|
@@ -3718,7 +3746,7 @@
|
|
|
3718
3746
|
}
|
|
3719
3747
|
return exportJson({
|
|
3720
3748
|
name: 'promptResult',
|
|
3721
|
-
message: `Result of \`OpenAiAssistantExecutionTools.
|
|
3749
|
+
message: `Result of \`OpenAiAssistantExecutionTools.callChatModelStream\``,
|
|
3722
3750
|
order: [],
|
|
3723
3751
|
value: {
|
|
3724
3752
|
content: resultContent,
|
|
@@ -3857,9 +3885,9 @@
|
|
|
3857
3885
|
}
|
|
3858
3886
|
const assistant = await client.beta.assistants.create(assistantConfig);
|
|
3859
3887
|
console.log(`✅ Assistant created: ${assistant.id}`);
|
|
3860
|
-
// TODO:
|
|
3861
|
-
// TODO:
|
|
3862
|
-
// TODO:
|
|
3888
|
+
// TODO: [🐱🚀] Try listing existing assistants
|
|
3889
|
+
// TODO: [🐱🚀] Try marking existing assistants by DISCRIMINANT
|
|
3890
|
+
// TODO: [🐱🚀] Allow to update and reconnect to existing assistants
|
|
3863
3891
|
return new OpenAiAssistantExecutionTools({
|
|
3864
3892
|
...this.options,
|
|
3865
3893
|
isCreatingNewAssistantsAllowed: false,
|
|
@@ -4072,7 +4100,7 @@
|
|
|
4072
4100
|
}
|
|
4073
4101
|
}
|
|
4074
4102
|
/**
|
|
4075
|
-
* TODO:
|
|
4103
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
4076
4104
|
*/
|
|
4077
4105
|
|
|
4078
4106
|
/**
|