@promptbook/google
Advanced tools
Comparing version 0.77.0-6 to 0.77.0
@@ -16,3 +16,3 @@ import colors from 'colors'; | ||
*/ | ||
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-5'; | ||
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-6'; | ||
/** | ||
@@ -759,3 +759,3 @@ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine | ||
return createExecutionToolsFromVercelProvider(__assign({ title: 'Google', description: 'Implementation of Google models', vercelProvider: googleGeminiVercelProvider, availableModels: [ | ||
// TODO: !!!!!! Maybe list models in same way as in other providers | ||
// TODO: [๐] Maybe list models in same way as in other providers - in separate file with metadata | ||
'gemini-1.5-flash', | ||
@@ -782,6 +782,2 @@ 'gemini-1.5-flash-latest', | ||
/** | ||
* TODO: [๐ง ][main] !!!! Make anonymous this with all LLM providers | ||
* TODO: [๐ง ][๐งฑ][main] !!!! Maybe change all `new GoogleExecutionTools` -> `createGoogleExecutionTools` in manual | ||
* TODO: [๐ง ] Maybe auto-detect usage in browser and determine default value of `isProxied` | ||
* TODO: [๐ฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom? | ||
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory" | ||
@@ -788,0 +784,0 @@ */ |
@@ -37,3 +37,3 @@ import type { ModelVariant } from '../types/ModelVariant'; | ||
/** | ||
* TODO: !!!!!! Put pricing information here | ||
* TODO: (not only [๐]) Put pricing information here | ||
*/ |
@@ -13,7 +13,3 @@ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools'; | ||
/** | ||
* TODO: [๐ง ][main] !!!! Make anonymous this with all LLM providers | ||
* TODO: [๐ง ][๐งฑ][main] !!!! Maybe change all `new GoogleExecutionTools` -> `createGoogleExecutionTools` in manual | ||
* TODO: [๐ง ] Maybe auto-detect usage in browser and determine default value of `isProxied` | ||
* TODO: [๐ฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom? | ||
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory" | ||
*/ |
{ | ||
"name": "@promptbook/google", | ||
"version": "0.77.0-6", | ||
"version": "0.77.0", | ||
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin", | ||
@@ -57,3 +57,3 @@ "--note-0": " <- [๐]", | ||
"peerDependencies": { | ||
"@promptbook/core": "0.77.0-6" | ||
"@promptbook/core": "0.77.0" | ||
}, | ||
@@ -60,0 +60,0 @@ "dependencies": { |
173
README.md
@@ -26,6 +26,2 @@ <!-- โ ๏ธ WARNING: This code has been generated so that any manual changes will be overwritten --> | ||
<blockquote style="color: #ff8811"> | ||
<b>โ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>. | ||
</blockquote> | ||
## ๐ฆ Package `@promptbook/google` | ||
@@ -46,7 +42,174 @@ | ||
`@promptbook/anthropic-claude` integrates [Google's Gemini API](https://gemini.google.com/) with [Promptbook](https://github.com/webgptorg/promptbook). It allows to execute Promptbooks with Gemini models. | ||
`@promptbook/google` integrates [Google's Gemini API](https://gemini.google.com/) with [Promptbook](https://github.com/webgptorg/promptbook). It allows to execute Promptbooks with Gemini models. | ||
## ๐งก Usage | ||
```typescript | ||
import { createPipelineExecutor, createCollectionFromDirectory, assertsExecutionSuccessful } from '@promptbook/core'; | ||
import { | ||
createCollectionFromDirectory, | ||
$provideExecutionToolsForNode, | ||
$provideFilesystemForNode, | ||
} from '@promptbook/node'; | ||
import { JavascriptExecutionTools } from '@promptbook/execute-javascript'; | ||
import { GoogleExecutionTools } from '@promptbook/google'; | ||
// โถ Prepare tools | ||
const fs = $provideFilesystemForNode(); | ||
const llm = new GoogleExecutionTools( | ||
// <- TODO: [๐งฑ] Implement in a functional (not new Class) way | ||
{ | ||
isVerbose: true, | ||
apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY, | ||
}, | ||
); | ||
const executables = await $provideExecutablesForNode(); | ||
const tools = { | ||
llm, | ||
fs, | ||
scrapers: await $provideScrapersForNode({ fs, llm, executables }), | ||
script: [new JavascriptExecutionTools()], | ||
}; | ||
// โถ Create whole pipeline collection | ||
const collection = await createCollectionFromDirectory('./books', tools); | ||
// โถ Get single Pipeline | ||
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.book.md`); | ||
// โถ Create executor - the function that will execute the Pipeline | ||
const pipelineExecutor = createPipelineExecutor({ pipeline, tools }); | ||
// โถ Prepare input parameters | ||
const inputParameters = { word: 'rabbit' }; | ||
// ๐โถ Execute the Pipeline | ||
const result = await pipelineExecutor(inputParameters); | ||
// โถ Fail if the execution was not successful | ||
assertsExecutionSuccessful(result); | ||
// โถ Handle the result | ||
const { isSuccessful, errors, outputParameters, executionReport } = result; | ||
console.info(outputParameters); | ||
``` | ||
## ๐งโโ๏ธ Connect to LLM providers automatically | ||
You can just use `$provideExecutionToolsForNode` function to create all required tools from environment variables like `GOOGLE_GENERATIVE_AI_API_KEY` and `OPENAI_API_KEY` automatically. | ||
```typescript | ||
import { createPipelineExecutor, createCollectionFromDirectory, assertsExecutionSuccessful } from '@promptbook/core'; | ||
import { JavascriptExecutionTools } from '@promptbook/execute-javascript'; | ||
import { $provideExecutionToolsForNode } from '@promptbook/node'; | ||
import { $provideFilesystemForNode } from '@promptbook/node'; | ||
// โถ Prepare tools | ||
const tools = await $provideExecutionToolsForNode(); | ||
// โถ Create whole pipeline collection | ||
const collection = await createCollectionFromDirectory('./books', tools); | ||
// โถ Get single Pipeline | ||
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.book.md`); | ||
// โถ Create executor - the function that will execute the Pipeline | ||
const pipelineExecutor = createPipelineExecutor({ pipeline, tools }); | ||
// โถ Prepare input parameters | ||
const inputParameters = { word: 'dog' }; | ||
// ๐โถ Execute the Pipeline | ||
const result = await pipelineExecutor(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 { createPipelineExecutor, createCollectionFromDirectory, assertsExecutionSuccessful } from '@promptbook/core'; | ||
import { $provideExecutionToolsForNode } from '@promptbook/node'; | ||
import { $provideFilesystemForNode } from '@promptbook/node'; | ||
import { JavascriptExecutionTools } from '@promptbook/execute-javascript'; | ||
import { OpenAiExecutionTools } from '@promptbook/openai'; | ||
import { GoogleExecutionTools } from '@promptbook/google'; | ||
// โถ Prepare multiple tools | ||
const fs = $provideFilesystemForNode(); | ||
const llm = [ | ||
// 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 GoogleExecutionTools( | ||
// <- TODO: [๐งฑ] Implement in a functional (not new Class) way | ||
{ | ||
apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY, | ||
}, | ||
), | ||
new OpenAiExecutionTools( | ||
// <- TODO: [๐งฑ] Implement in a functional (not new Class) way | ||
{ | ||
apiKey: process.env.OPENAI_API_KEY, | ||
}, | ||
), | ||
new AzureOpenAiExecutionTools( | ||
// <- TODO: [๐งฑ] Implement in a functional (not new Class) way | ||
{ | ||
resourceName: process.env.AZUREOPENAI_RESOURCE_NAME, | ||
deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME, | ||
apiKey: process.env.AZUREOPENAI_API_KEY, | ||
}, | ||
), | ||
]; | ||
const executables = await $provideExecutablesForNode(); | ||
const tools = { | ||
llm, | ||
fs, | ||
scrapers: await $provideScrapersForNode({ fs, llm, executables }), | ||
script: [new JavascriptExecutionTools()], | ||
}; | ||
// โถ Create whole pipeline collection | ||
const collection = await createCollectionFromDirectory('./books', tools); | ||
// โถ Get single Pipeline | ||
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.book.md`); | ||
// โถ Create executor - the function that will execute the Pipeline | ||
const pipelineExecutor = createPipelineExecutor({ pipeline, tools }); | ||
// โถ Prepare input parameters | ||
const inputParameters = { word: 'bunny' }; | ||
// ๐โถ Execute the Pipeline | ||
const result = await pipelineExecutor(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 | ||
See the other model integrations: | ||
- [OpenAI](https://www.npmjs.com/package/@promptbook/openai) | ||
- [Anthropic Claude](https://www.npmjs.com/package/@promptbook/anthropic-claude) | ||
- [Google Gemini](https://www.npmjs.com/package/@promptbook/google) | ||
- [Vercel](https://www.npmjs.com/package/@promptbook/vercel) | ||
- [Azure OpenAI](https://www.npmjs.com/package/@promptbook/azure-openai) | ||
--- | ||
@@ -53,0 +216,0 @@ |
@@ -24,3 +24,3 @@ (function (global, factory) { | ||
*/ | ||
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-5'; | ||
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-6'; | ||
/** | ||
@@ -767,3 +767,3 @@ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine | ||
return createExecutionToolsFromVercelProvider(__assign({ title: 'Google', description: 'Implementation of Google models', vercelProvider: googleGeminiVercelProvider, availableModels: [ | ||
// TODO: !!!!!! Maybe list models in same way as in other providers | ||
// TODO: [๐] Maybe list models in same way as in other providers - in separate file with metadata | ||
'gemini-1.5-flash', | ||
@@ -790,6 +790,2 @@ 'gemini-1.5-flash-latest', | ||
/** | ||
* TODO: [๐ง ][main] !!!! Make anonymous this with all LLM providers | ||
* TODO: [๐ง ][๐งฑ][main] !!!! Maybe change all `new GoogleExecutionTools` -> `createGoogleExecutionTools` in manual | ||
* TODO: [๐ง ] Maybe auto-detect usage in browser and determine default value of `isProxied` | ||
* TODO: [๐ฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom? | ||
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory" | ||
@@ -796,0 +792,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
683747
582
13408