@promptbook/anthropic-claude
Advanced tools
Comparing version 0.52.0-30 to 0.52.0-31
@@ -13,2 +13,3 @@ import type { IDestroyable } from 'destroyable'; | ||
/** | ||
* TODO: [⚖] Expose the library to be able to connect to same library via createPromptbookLibraryFromUrl | ||
* TODO: Handle progress - support streaming | ||
@@ -15,0 +16,0 @@ * TODO: [🤹♂️] Do not hang up immediately but wait until client closes OR timeout |
@@ -28,3 +28,4 @@ import { string_url } from '../../types/typeAliases'; | ||
/*** | ||
* TODO: [⚖] Compatible with remote server | ||
* TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package | ||
*/ |
{ | ||
"name": "@promptbook/anthropic-claude", | ||
"version": "0.52.0-30", | ||
"version": "0.52.0-31", | ||
"description": "Library to supercharge your use of large language models", | ||
@@ -51,3 +51,3 @@ "private": false, | ||
"peerDependencies": { | ||
"@promptbook/core": "0.52.0-30" | ||
"@promptbook/core": "0.52.0-31" | ||
}, | ||
@@ -54,0 +54,0 @@ "main": "./umd/index.umd.js", |
@@ -33,8 +33,99 @@ # ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook | ||
`@promptbook/anthropic-claude` integrates [Anthropic's Claude API](https://console.anthropic.com/) with [Promptbook](https://github.com/webgptorg/promptbook). It allows to execute Promptbooks with OpenAI Claude 2 and 3 models. | ||
## 🧡 Usage | ||
```typescript | ||
import { | ||
createPromptbookExecutor, | ||
createPromptbookLibraryFromDirectory, | ||
assertsExecutionSuccessful, | ||
} from '@promptbook/core'; | ||
import { JavascriptExecutionTools } from '@promptbook/execute-javascript'; | ||
import { OpenAiExecutionTools } from '@promptbook/openai'; | ||
// ▶ Create whole Promptbook library | ||
const library = await createPromptbookLibraryFromDirectory('./promptbook-library'); | ||
// ▶ Get one Promptbook | ||
const promptbook = await library.getPromptbookByUrl(`https://promptbook.studio/my-library/write-article.ptbk.md`); | ||
// ▶ Prepare tools | ||
const tools = { | ||
llm: new AnthropicClaudeExecutionTools({ | ||
isVerbose: true, | ||
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY, | ||
}), | ||
script: [new JavascriptExecutionTools()], | ||
}; | ||
// ▶ Create executor - the function that will execute the Promptbook | ||
const promptbookExecutor = createPromptbookExecutor({ promptbook, tools }); | ||
// ▶ Prepare input parameters | ||
const inputParameters = { word: 'rabbit' }; | ||
// 🚀▶ Execute the Promptbook | ||
const result = await promptbookExecutor(inputParameters); | ||
// ▶ Fail if the execution was not successful | ||
assertsExecutionSuccessful(result); | ||
// ▶ Handle the result | ||
const { isSuccessful, errors, outputParameters, executionReport } = result; | ||
console.info(outputParameters); | ||
``` | ||
## 💕 Usage of multiple LLM providers | ||
You can use multiple LLM providers in one Promptbook execution. The best model will be chosen automatically according to the prompt and the model's capabilities. | ||
```typescript | ||
import { | ||
createPromptbookExecutor, | ||
createPromptbookLibraryFromDirectory, | ||
assertsExecutionSuccessful, | ||
} from '@promptbook/core'; | ||
import { JavascriptExecutionTools } from '@promptbook/execute-javascript'; | ||
import { OpenAiExecutionTools } from '@promptbook/openai'; | ||
// ▶ Create whole Promptbook library | ||
const library = await createPromptbookLibraryFromDirectory('./promptbook-library'); | ||
// ▶ Get one Promptbook | ||
const promptbook = await library.getPromptbookByUrl(`https://promptbook.studio/my-library/write-article.ptbk.md`); | ||
// ▶ Prepare tools | ||
const tools = new MultipleLlmExecutionTools( | ||
// Note: You can use multiple LLM providers in one Promptbook execution. The best model will be chosen automatically according to the prompt and the model's capabilities. | ||
new AnthropicClaudeExecutionTools({ | ||
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY, | ||
}), | ||
new OpenAiExecutionTools({ | ||
apiKey: process.env.OPENAI_API_KEY, | ||
}), | ||
new AzureOpenAiExecutionTools({ | ||
resourceName: process.env.AZUREOPENAI_RESOURCE_NAME, | ||
deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME, | ||
apiKey: process.env.AZUREOPENAI_API_KEY, | ||
}), | ||
); | ||
// ▶ Create executor - the function that will execute the Promptbook | ||
const promptbookExecutor = createPromptbookExecutor({ promptbook, tools }); | ||
// ▶ Prepare input parameters | ||
const inputParameters = { word: 'bunny' }; | ||
// 🚀▶ Execute the Promptbook | ||
const result = await promptbookExecutor(inputParameters); | ||
// ▶ Fail if the execution was not successful | ||
assertsExecutionSuccessful(result); | ||
// ▶ Handle the result | ||
const { isSuccessful, errors, outputParameters, executionReport } = result; | ||
console.info(outputParameters); | ||
``` | ||
## 💙 Integration with other models | ||
@@ -41,0 +132,0 @@ |
@@ -13,2 +13,3 @@ import type { IDestroyable } from 'destroyable'; | ||
/** | ||
* TODO: [⚖] Expose the library to be able to connect to same library via createPromptbookLibraryFromUrl | ||
* TODO: Handle progress - support streaming | ||
@@ -15,0 +16,0 @@ * TODO: [🤹♂️] Do not hang up immediately but wait until client closes OR timeout |
@@ -28,3 +28,4 @@ import { string_url } from '../../types/typeAliases'; | ||
/*** | ||
* TODO: [⚖] Compatible with remote server | ||
* TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package | ||
*/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
477314
7990
815