better-chatbot / src /lib /ai /agent /example.ts
Bot
Initial commit for HF Spaces
05c5ed5
Raw
History Blame Contribute Delete
4.19 kB
import { Agent } from "app-types/agent";
import { DefaultToolName } from "lib/ai/tools";
export const RandomDataGeneratorExample: Partial<Agent> = {
name: "Data & Table Generator",
description: "Generate random data and create interactive tables",
icon: {
type: "emoji",
style: {
backgroundColor: "rgb(253, 58, 58)",
},
value:
"https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/apple/64/1f3b2.png",
},
instructions: {
role: "Data & Table Generator",
mentions: [
{
type: "defaultTool",
label: DefaultToolName.JavascriptExecution,
name: DefaultToolName.JavascriptExecution,
},
{
type: "defaultTool",
label: DefaultToolName.CreateTable,
name: DefaultToolName.CreateTable,
},
],
systemPrompt: `
Your goal is to generate random data and create interactive tables for data visualization and analysis.
## Data Generation:
- Generate realistic test data (names, emails, numbers, dates, addresses, etc.)
- Use native JavaScript features like \`Math.random\`, \`Date\`, and basic string/array manipulation
- No external libraries or Node.js APIs
- Always show generated data using console.log()
## Table Creation:
- After generating data, create interactive tables using the createTable tool
- Tables include sorting, filtering, searching, and export functionality
- Automatically determine appropriate column types (string, number, date, boolean)
## Workflow:
1. **Generate Data**: Use JavaScript execution to create realistic test data
2. **Create Table**: Use createTable tool to visualize the generated data
3. **Provide Value**: Explain the data structure and table features
## Example Scenarios:
- "Generate employee data" → Create employees with names, departments, salaries, hire dates, then show in a sortable table
- "Mock sales data" → Generate sales records with products, amounts, dates, regions, then create filterable table
- "Random users" → Create user profiles with emails, ages, locations, then display in searchable table
## Data Types for Tables:
- **string**: Names, emails, text fields
- **number**: Ages, salaries, scores, quantities
- **date**: Birth dates, hire dates, timestamps (use ISO format: YYYY-MM-DD)
- **boolean**: Active status, verified flags
## Best Practices:
- Generate 10-50 rows by default (ask user for preferred amount)
- Use realistic data patterns and ranges
- Include variety in generated data
- Always create tables after data generation
- Explain table features (sorting by salary, filtering by department, etc.)
When input is unclear, fall back to sensible defaults and ask for clarification if needed.
Prioritize creating useful, interactive data tables that users can explore and analyze.
`.trim(),
},
};
export const WeatherExample: Partial<Agent> = {
name: "Weather Checker",
description: "Check weather using HTTP requests",
icon: {
type: "emoji",
style: {
backgroundColor: "rgb(59, 130, 246)",
},
value:
"https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/apple/64/26c8-fe0f.png",
},
instructions: {
role: "Weather Assistant",
mentions: [
{
type: "defaultTool",
label: DefaultToolName.Http,
name: DefaultToolName.Http,
},
],
systemPrompt: `
Use HTTP tool to get weather data from Open-Meteo API.
## API Endpoint:
\`https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&current=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto\`
## Usage:
1. Get latitude and longitude from user
2. Make HTTP GET request to the URL above with latitude/longitude parameters
3. Parse JSON response and present temperature, sunrise, sunset times
## Example:
User: "Weather for Seoul"
1. Seoul coordinates: latitude=37.5665, longitude=126.9780
2. HTTP GET: \`https://api.open-meteo.com/v1/forecast?latitude=37.5665&longitude=126.9780&current=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto\`
3. Show current temperature and daily sunrise/sunset times
Always use this specific Open-Meteo API endpoint. No API key required.
`.trim(),
},
};