Installation
Lyvo is a JavaScript library that can be used in Browser Extension, Node.js Enviroment, and Web Enviroment. This guide covers installation and setup for different environments.
Browser Extension
When building a browser extension that uses Lyvo, you’ll need to:
# install cli (used to initialize browser extension projects)pnpm install @lyvo-ai/lyvo-cli -g# initialize projectlyvo-cli init browser-extension-demo
cd browser-extension-demo# install dependenciespnpm install
Extension Project Structure
extension/├── src/│ ├── background/│ │ └── index.ts # Use Lyvo here│ ├── content/│ │ └── index.ts│ └── popup/│ └── index.ts├── package.json└── webpack.config.js
For a complete example of using Lyvo in a browser extension, check out our example extension project.
Usage Example
import { Lyvo } from "@lyvo-ai/lyvo";import { EkoConfig } from "@lyvo-ai/lyvo/types";import { getLLMConfig } from "@lyvo-ai/lyvo/extension";
export async function main() { // Load LLM model configuration // the current browser plugin project provides a page for configuring LLM parameters let config = await getLLMConfig();
// Initialize lyvo let lyvo = new Lyvo(config as EkoConfig);
// Generate workflow from natural language description let workflow = await lyvo.generate(` Search for Elon Musk, summarize search results and export as md `);
// Execute await lyvo.execute(workflow);}
Node.js Environment
Install
pnpm install @lyvo-ai/lyvo
Usage Example
import { Lyvo } from "@lyvo-ai/lyvo";import { loadTools } from "@lyvo-ai/lyvo/nodejs";
Lyvo.tools = loadTools();
async function main() { // Initialize lyvo let lyvo = new Lyvo({ llm: 'claude', apiKey: process.env.ANTHROPIC_API_KEY, });
// Generate workflow from natural language description let workflow = await lyvo.generate(` Clean up all files in the current directory larger than 1MB `);
// Execute await lyvo.execute(workflow);}
await main();
Web Environment
For web pages, you can include Lyvo using a module bundler like webpack or use it directly in the browser.
Install
pnpm install @lyvo-ai/lyvo
Usage Example
import { Lyvo, ClaudeProvider } from "@lyvo-ai/lyvo";import { loadTools } from "@lyvo-ai/lyvo/web";
Lyvo.tools = loadTools();
async function main() { // Initialize LLM provider let llmProvider = new ClaudeProvider({ // Please use your API endpoint for authentication and forwarding on the server side, do not expose API keys in the frontend baseURL: 'https://your-api-endpoint.com', // User Authentication Request Header defaultHeaders: { // 'Authorization': `Bearer ${getToken()}` } });
// Initialize lyvo let lyvo = new Lyvo(llmProvider);
// Generate workflow from natural language description // Lyvo will automatically select and sequence the appropriate tools const workflow = await lyvo.generate(` Open youtube, Search for Elon Musk, click on the first video, extract and summarize the content, and export as md. `);
// Execute await lyvo.execute(workflow);}
await main();