@promptbook/markdown-utils 0.105.0-1 → 0.105.0-4
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 +36 -77
- package/esm/index.es.js +80 -63
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +10 -3
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +11 -1
- package/esm/typings/src/book-2.0/agent-source/communication-samples.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.blocks.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.import.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.import.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.blocks.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +40 -0
- package/esm/typings/src/commitments/USE_TIME/USE_TIME.test.d.ts +1 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +8 -0
- package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +8 -0
- package/esm/typings/src/commitments/index.d.ts +11 -2
- package/esm/typings/src/config.d.ts +1 -0
- package/esm/typings/src/import-plugins/$fileImportPlugins.d.ts +7 -0
- package/esm/typings/src/import-plugins/AgentFileImportPlugin.d.ts +7 -0
- package/esm/typings/src/import-plugins/FileImportPlugin.d.ts +24 -0
- package/esm/typings/src/import-plugins/JsonFileImportPlugin.d.ts +7 -0
- package/esm/typings/src/import-plugins/TextFileImportPlugin.d.ts +7 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +9 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +10 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +6 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +6 -12
- package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +2 -3
- package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +7 -1
- package/esm/typings/src/utils/organization/keepImported.d.ts +9 -0
- package/esm/typings/src/utils/organization/keepTypeImported.d.ts +0 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +80 -63
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -144,19 +144,20 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
144
144
|
|
|
145
145
|
## 📖 The Book Whitepaper
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
Nowadays, the biggest challenge for most business applications isn't the raw capabilities of AI models. Large language models such as GPT-5.2 and Claude-4.5 are incredibly capable.
|
|
148
148
|
|
|
149
|
-
The main challenge
|
|
149
|
+
The main challenge lies in **managing the context**, providing rules and knowledge, and narrowing the personality.
|
|
150
150
|
|
|
151
|
-
Promptbook
|
|
151
|
+
In Promptbook, you can define your context **using simple Books** that are very explicit, easy to understand and write, reliable, and highly portable.
|
|
152
152
|
|
|
153
153
|
<table style="border: 1px solid #777; border-radius: 10px;"><tr><td>
|
|
154
154
|
|
|
155
|
-
**<ins>Paul Smith
|
|
155
|
+
**<ins>Paul Smith</ins>**<br/>
|
|
156
156
|
<br/>
|
|
157
157
|
**PERSONA** You are a company lawyer.<br/>
|
|
158
158
|
Your job is to provide legal advice and support to the company and its employees.<br/>
|
|
159
|
-
You are knowledgeable, professional, and detail-oriented.<br/>
|
|
159
|
+
**RULE** You are knowledgeable, professional, and detail-oriented.<br/>
|
|
160
|
+
TEAM You are part of the legal team of Paul Smith & Associés, you discuss with {Emily White}, the head of the compliance department. {George Brown} is expert in corporate law and {Sophia Black} is expert in labor law.<br/>
|
|
160
161
|
|
|
161
162
|
</td></tr></table>
|
|
162
163
|
|
|
@@ -166,7 +167,9 @@ You are knowledgeable, professional, and detail-oriented.<br/>
|
|
|
166
167
|
|
|
167
168
|
We have created a language called **Book**, which allows you to write AI agents in their native language and create your own AI persona. Book provides a guide to define all the traits and commitments.
|
|
168
169
|
|
|
169
|
-
You can look at it as prompting (or writing a system message), but decorated by **commitments**.
|
|
170
|
+
You can look at it as "prompting" _(or writing a system message)_, but decorated by **commitments**.
|
|
171
|
+
|
|
172
|
+
**Commitments** are special syntax elements that define contracts between you and the AI agent. They are transformed by Promptbook Engine into low-level parameters like which model to use, its temperature, system message, RAG index, MCP servers, and many other parameters. For some commitments _(for example `RULE` commitment)_ Promptbook Engine can even create adversary agents and extra checks to enforce the rules.
|
|
170
173
|
|
|
171
174
|
#### `Persona` commitment
|
|
172
175
|
|
|
@@ -177,8 +180,6 @@ Personas define the character of your AI persona, its role, and how it should in
|
|
|
177
180
|
**<ins>Paul Smith & Associés</ins>**<br/>
|
|
178
181
|
<br/>
|
|
179
182
|
**PERSONA** You are a company lawyer.<br/>
|
|
180
|
-
Your job is to provide legal advice and support to the company and its employees.<br/>
|
|
181
|
-
You are knowledgeable, professional, and detail-oriented.<br/>
|
|
182
183
|
|
|
183
184
|
</td></tr></table>
|
|
184
185
|
|
|
@@ -198,7 +199,7 @@ Promptbook Engine will automatically enforce this knowledge during interactions.
|
|
|
198
199
|
Your job is to provide legal advice and support to the company and its employees.<br/>
|
|
199
200
|
You are knowledgeable, professional, and detail-oriented.<br/>
|
|
200
201
|
<br/>
|
|
201
|
-
**KNOWLEDGE**
|
|
202
|
+
**KNOWLEDGE** https://company.com/company-policies.pdf<br/>
|
|
202
203
|
**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
|
|
203
204
|
|
|
204
205
|
</td></tr></table>
|
|
@@ -220,14 +221,14 @@ You are knowledgeable, professional, and detail-oriented.<br/>
|
|
|
220
221
|
**RULE** Always ensure compliance with laws and regulations.<br/>
|
|
221
222
|
**RULE** Never provide legal advice outside your area of expertise.<br/>
|
|
222
223
|
**RULE** Never provide legal advice about criminal law.<br/>
|
|
223
|
-
**KNOWLEDGE**
|
|
224
|
+
**KNOWLEDGE** https://company.com/company-policies.pdf<br/>
|
|
224
225
|
**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
|
|
225
226
|
|
|
226
227
|
</td></tr></table>
|
|
227
228
|
|
|
228
|
-
#### `
|
|
229
|
+
#### `Team` commitment
|
|
229
230
|
|
|
230
|
-
|
|
231
|
+
Team commitment allows you to define the team structure and advisory fellow members the AI can consult with. This allows the AI to simulate collaboration and consultation with other experts, enhancing the quality of its responses.
|
|
231
232
|
|
|
232
233
|
<table style="border: 1px solid #777; border-radius: 10px;"><tr><td>
|
|
233
234
|
|
|
@@ -240,81 +241,36 @@ You are knowledgeable, professional, and detail-oriented.<br/>
|
|
|
240
241
|
**RULE** Always ensure compliance with laws and regulations.<br/>
|
|
241
242
|
**RULE** Never provide legal advice outside your area of expertise.<br/>
|
|
242
243
|
**RULE** Never provide legal advice about criminal law.<br/>
|
|
243
|
-
**KNOWLEDGE**
|
|
244
|
+
**KNOWLEDGE** https://company.com/company-policies.pdf<br/>
|
|
244
245
|
**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
|
|
245
|
-
|
|
246
|
+
TEAM You are part of the legal team of Paul Smith & Associés, you discuss with {Emily White}, the head of the compliance department. {George Brown} is expert in corporate law and {Sophia Black} is expert in labor law.<br/>
|
|
246
247
|
|
|
247
248
|
</td></tr></table>
|
|
248
249
|
|
|
249
|
-
[Read more about the language](./BLUEPRINT.md)
|
|
250
|
-
|
|
251
|
-
<div style="page-break-after: always;"></div>
|
|
252
|
-
|
|
253
|
-
### Where to use your AI agent in book
|
|
254
|
-
|
|
255
|
-
Books can be useful in various applications and scenarios. Here are some examples:
|
|
256
|
-
|
|
257
|
-
#### Chat apps:
|
|
258
250
|
|
|
259
|
-
Create your own chat shopping assistant and place it in your eShop.
|
|
260
|
-
You will be able to answer customer questions, help them find products, and provide personalized recommendations. Everything is tightly controlled by the book you have written.
|
|
261
251
|
|
|
262
|
-
|
|
252
|
+
### Promptbook Ecosystem
|
|
263
253
|
|
|
264
|
-
|
|
254
|
+
!!!@@@
|
|
265
255
|
|
|
266
|
-
####
|
|
267
|
-
|
|
268
|
-
Do you love Vibecoding, but the AI code is not always aligned with your coding style and architecture, rules, security, etc.? Create your own coding agent to help enforce your specific coding standards and practices.
|
|
269
|
-
|
|
270
|
-
This can be integrated to almost any Vibecoding platform, like GitHub Copilot, Amazon CodeWhisperer, Cursor, Cline, Kilocode, Roocode,...
|
|
271
|
-
|
|
272
|
-
They will work the same as you are used to, but with your specific rules written in book.
|
|
273
|
-
|
|
274
|
-
#### Internal Expertise
|
|
275
|
-
|
|
276
|
-
Do you have an app written in TypeScript, Python, C#, Java, or any other language, and you are integrating the AI.
|
|
277
|
-
|
|
278
|
-
You can avoid struggle with choosing the best model, its settings like temperature, max tokens, etc., by writing a book agent and using it as your AI expertise.
|
|
279
|
-
|
|
280
|
-
Doesn't matter if you do automations, data analysis, customer support, sentiment analysis, classification, or any other task. Your AI agent will be tailored to your specific needs and requirements.
|
|
281
|
-
|
|
282
|
-
Even works in no-code platforms!
|
|
283
|
-
|
|
284
|
-
<div style="page-break-after: always;"></div>
|
|
256
|
+
#### Promptbook Server
|
|
285
257
|
|
|
286
|
-
|
|
258
|
+
!!!@@@
|
|
287
259
|
|
|
288
|
-
|
|
260
|
+
#### Promptbook Engine
|
|
289
261
|
|
|
290
|
-
|
|
262
|
+
!!!@@@
|
|
291
263
|
|
|
292
|
-
We have written ai asistant in book who can help you with writing your first book.
|
|
293
264
|
|
|
294
|
-
#### Your AI twin
|
|
295
265
|
|
|
296
|
-
Copy your own behavior, personality, and knowledge into book and create your AI twin. It can help you with your work, personal life, or any other task.
|
|
297
266
|
|
|
298
|
-
#### AI persona workpool
|
|
299
267
|
|
|
300
|
-
Or you can pick from our library of pre-written books for various roles and tasks. You can find books for customer support, coding, marketing, sales, HR, legal, and many other roles.
|
|
301
268
|
|
|
302
269
|
|
|
303
270
|
|
|
304
271
|
|
|
305
272
|
|
|
306
273
|
|
|
307
|
-
## 🚀 Get started
|
|
308
|
-
|
|
309
|
-
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
310
|
-
|
|
311
|
-
- [Hello Book](https://github.com/webgptorg/hello-world)
|
|
312
|
-
- [Hello Book in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
313
|
-
- [Hello Book in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
274
|
|
|
319
275
|
|
|
320
276
|
## 💜 The Promptbook Project
|
|
@@ -330,33 +286,32 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
330
286
|
</thead>
|
|
331
287
|
<tbody>
|
|
332
288
|
<tr>
|
|
333
|
-
<td><a href="https://
|
|
289
|
+
<td><a href="https://gallery.ptbk.io/">Agents Server</a></td>
|
|
334
290
|
<td>
|
|
335
|
-
|
|
336
|
-
<hr>
|
|
337
|
-
There is also <a href="https://github.com/webgptorg/book-extension">a plugin for VSCode</a> to support <code>.book</code> file extension
|
|
291
|
+
Place where you "AI agents live". It allows to create, manage, deploy, and interact with AI agents created in Book language.
|
|
338
292
|
</td>
|
|
339
293
|
</tr>
|
|
340
294
|
<tr>
|
|
341
|
-
<td><a href="https://github.com/webgptorg/
|
|
295
|
+
<td><a href="https://github.com/webgptorg/book">Book language</a></td>
|
|
342
296
|
<td>
|
|
343
|
-
|
|
297
|
+
Human-friendly, high-level language that abstracts away low-level details of AI. It allows to focus on personality, behavior, knowledge, and rules of AI agents rather than on models, parameters, and prompt engineering.
|
|
298
|
+
<hr>
|
|
299
|
+
There is also <a href="https://github.com/webgptorg/book-extension">a plugin for VSCode</a> to support <code>.book</code> file extension
|
|
344
300
|
</td>
|
|
345
301
|
</tr>
|
|
346
302
|
<tr>
|
|
347
|
-
<td><a href="https://promptbook
|
|
303
|
+
<td><a href="https://github.com/webgptorg/promptbook">Promptbook Engine</a></td>
|
|
348
304
|
<td>
|
|
349
|
-
Promptbook
|
|
305
|
+
Promptbook engine can run AI agents based on Book language.
|
|
306
|
+
It is released as <a href="https://www.npmjs.com/package/@promptbook/core#-packages-for-developers">multiple NPM packages</a> and <a href="https://hub.docker.com/r/hejny/promptbook">Promptbook Agent Server as Docker Package</a>
|
|
307
|
+
Agent Server is based on Promptbook Engine.
|
|
350
308
|
</td>
|
|
351
309
|
</tr>
|
|
310
|
+
|
|
352
311
|
</tbody>
|
|
353
312
|
</table>
|
|
354
313
|
|
|
355
|
-
Hello world examples:
|
|
356
314
|
|
|
357
|
-
- [Hello world](https://github.com/webgptorg/hello-world)
|
|
358
|
-
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
359
|
-
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
360
315
|
|
|
361
316
|
### 🌐 Community & Social Media
|
|
362
317
|
|
|
@@ -414,6 +369,8 @@ Join our growing community of developers and users:
|
|
|
414
369
|
|
|
415
370
|
|
|
416
371
|
|
|
372
|
+
|
|
373
|
+
|
|
417
374
|
## 📚 Documentation
|
|
418
375
|
|
|
419
376
|
See detailed guides and API reference in the [docs](https://github.com/webgptorg/promptbook/discussions/categories/concepts) or [online](https://discord.gg/x3QWNaa89N).
|
|
@@ -490,6 +447,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
490
447
|
|
|
491
448
|
_Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
492
449
|
|
|
450
|
+
|
|
451
|
+
|
|
493
452
|
### 💯 Core concepts
|
|
494
453
|
|
|
495
454
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
package/esm/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-4';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1117,6 +1117,7 @@ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
|
1117
1117
|
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1118
1118
|
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1119
1119
|
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1120
|
+
CODE_BLOCK: Color.fromHex('#7700ffff'),
|
|
1120
1121
|
});
|
|
1121
1122
|
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1122
1123
|
/**
|
|
@@ -3493,74 +3494,90 @@ function addUsage(...usageItems) {
|
|
|
3493
3494
|
* in real-time through an observable.
|
|
3494
3495
|
*
|
|
3495
3496
|
* @param llmTools - The LLM tools to be intercepted and tracked
|
|
3496
|
-
* @returns
|
|
3497
|
+
* @returns Full proxy of the tools with added usage tracking capabilities
|
|
3497
3498
|
* @public exported from `@promptbook/core`
|
|
3498
3499
|
*/
|
|
3499
3500
|
function countUsage(llmTools) {
|
|
3500
3501
|
let totalUsage = ZERO_USAGE;
|
|
3501
3502
|
const spending = new Subject();
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
//
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
//
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
//
|
|
3524
|
-
|
|
3503
|
+
// Create a Proxy to intercept all property access and ensure full proxying of all properties
|
|
3504
|
+
const proxyTools = new Proxy(llmTools, {
|
|
3505
|
+
get(target, prop, receiver) {
|
|
3506
|
+
// Handle title property
|
|
3507
|
+
if (prop === 'title') {
|
|
3508
|
+
return `${target.title} (+usage)`;
|
|
3509
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
3510
|
+
// <- TODO: [🧈][🧠] Does it make sense to suffix "(+usage)"?
|
|
3511
|
+
}
|
|
3512
|
+
// Handle description property
|
|
3513
|
+
if (prop === 'description') {
|
|
3514
|
+
return `${target.description} (+usage)`;
|
|
3515
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
3516
|
+
// <- TODO: [🧈][🧠] Does it make sense to suffix "(+usage)"?
|
|
3517
|
+
}
|
|
3518
|
+
// Handle spending method (new method added by this wrapper)
|
|
3519
|
+
if (prop === 'spending') {
|
|
3520
|
+
return () => {
|
|
3521
|
+
return spending.asObservable();
|
|
3522
|
+
};
|
|
3523
|
+
}
|
|
3524
|
+
// Handle getTotalUsage method (new method added by this wrapper)
|
|
3525
|
+
if (prop === 'getTotalUsage') {
|
|
3526
|
+
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
3527
|
+
return () => {
|
|
3528
|
+
return totalUsage;
|
|
3529
|
+
};
|
|
3530
|
+
}
|
|
3531
|
+
// Handle callChatModel method with usage counting
|
|
3532
|
+
if (prop === 'callChatModel' && target.callChatModel !== undefined) {
|
|
3533
|
+
return async (prompt) => {
|
|
3534
|
+
// console.info('[🚕] callChatModel through countTotalUsage');
|
|
3535
|
+
const promptResult = await target.callChatModel(prompt);
|
|
3536
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3537
|
+
spending.next(promptResult.usage);
|
|
3538
|
+
return promptResult;
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
// Handle callCompletionModel method with usage counting
|
|
3542
|
+
if (prop === 'callCompletionModel' && target.callCompletionModel !== undefined) {
|
|
3543
|
+
return async (prompt) => {
|
|
3544
|
+
// console.info('[🚕] callCompletionModel through countTotalUsage');
|
|
3545
|
+
const promptResult = await target.callCompletionModel(prompt);
|
|
3546
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3547
|
+
spending.next(promptResult.usage);
|
|
3548
|
+
return promptResult;
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
// Handle callEmbeddingModel method with usage counting
|
|
3552
|
+
if (prop === 'callEmbeddingModel' && target.callEmbeddingModel !== undefined) {
|
|
3553
|
+
return async (prompt) => {
|
|
3554
|
+
// console.info('[🚕] callEmbeddingModel through countTotalUsage');
|
|
3555
|
+
const promptResult = await target.callEmbeddingModel(prompt);
|
|
3556
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3557
|
+
spending.next(promptResult.usage);
|
|
3558
|
+
return promptResult;
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3561
|
+
// Handle callImageGenerationModel method with usage counting
|
|
3562
|
+
if (prop === 'callImageGenerationModel' && target.callImageGenerationModel !== undefined) {
|
|
3563
|
+
return async (prompt) => {
|
|
3564
|
+
// console.info('[🚕] callImageGenerationModel through countTotalUsage');
|
|
3565
|
+
const promptResult = await target.callImageGenerationModel(prompt);
|
|
3566
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3567
|
+
spending.next(promptResult.usage);
|
|
3568
|
+
return promptResult;
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
// <- Note: [🤖]
|
|
3572
|
+
// For all other properties and methods, delegate to the original target
|
|
3573
|
+
const value = Reflect.get(target, prop, receiver);
|
|
3574
|
+
// If it's a function, bind it to the target to preserve context
|
|
3575
|
+
if (typeof value === 'function') {
|
|
3576
|
+
return value.bind(target);
|
|
3577
|
+
}
|
|
3578
|
+
return value;
|
|
3525
3579
|
},
|
|
3526
|
-
};
|
|
3527
|
-
if (llmTools.callChatModel !== undefined) {
|
|
3528
|
-
proxyTools.callChatModel = async (prompt) => {
|
|
3529
|
-
// console.info('[🚕] callChatModel through countTotalUsage');
|
|
3530
|
-
const promptResult = await llmTools.callChatModel(prompt);
|
|
3531
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3532
|
-
spending.next(promptResult.usage);
|
|
3533
|
-
return promptResult;
|
|
3534
|
-
};
|
|
3535
|
-
}
|
|
3536
|
-
if (llmTools.callCompletionModel !== undefined) {
|
|
3537
|
-
proxyTools.callCompletionModel = async (prompt) => {
|
|
3538
|
-
// console.info('[🚕] callCompletionModel through countTotalUsage');
|
|
3539
|
-
const promptResult = await llmTools.callCompletionModel(prompt);
|
|
3540
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3541
|
-
spending.next(promptResult.usage);
|
|
3542
|
-
return promptResult;
|
|
3543
|
-
};
|
|
3544
|
-
}
|
|
3545
|
-
if (llmTools.callEmbeddingModel !== undefined) {
|
|
3546
|
-
proxyTools.callEmbeddingModel = async (prompt) => {
|
|
3547
|
-
// console.info('[🚕] callEmbeddingModel through countTotalUsage');
|
|
3548
|
-
const promptResult = await llmTools.callEmbeddingModel(prompt);
|
|
3549
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3550
|
-
spending.next(promptResult.usage);
|
|
3551
|
-
return promptResult;
|
|
3552
|
-
};
|
|
3553
|
-
}
|
|
3554
|
-
if (llmTools.callImageGenerationModel !== undefined) {
|
|
3555
|
-
proxyTools.callImageGenerationModel = async (prompt) => {
|
|
3556
|
-
// console.info('[🚕] callImageGenerationModel through countTotalUsage');
|
|
3557
|
-
const promptResult = await llmTools.callImageGenerationModel(prompt);
|
|
3558
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3559
|
-
spending.next(promptResult.usage);
|
|
3560
|
-
return promptResult;
|
|
3561
|
-
};
|
|
3562
|
-
}
|
|
3563
|
-
// <- Note: [🤖]
|
|
3580
|
+
});
|
|
3564
3581
|
return proxyTools;
|
|
3565
3582
|
}
|
|
3566
3583
|
/**
|