Skip to content

Commit

Permalink
Hyperbolic plugin for ElizaOS preparation to the PR (#2701)
Browse files Browse the repository at this point in the history
  • Loading branch information
AIFlowML authored Jan 23, 2025
1 parent 02f6114 commit 02518fa
Show file tree
Hide file tree
Showing 26 changed files with 2,517 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -809,3 +809,12 @@ SUNO_API_KEY=

# Udio AI Music Generation
UDIO_AUTH_TOKEN=

# ####################################
# #### Hyperbolic Configuration ####
# ####################################
HYPERBOLIC_ENV=production
HYPERBOLIC_API_KEY=
HYPERBOLIC_GRANULAR_LOG=true
HYPERBOLIC_SPASH=true
HYPERBOLIC_LOG_LEVEL=debug
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"@elizaos/plugin-omniflix": "workspace:*",
"@elizaos/plugin-suno": "workspace:*",
"@elizaos/plugin-udio": "workspace:*",
"@elizaos/plugin-hyperbolic": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand Down
8 changes: 4 additions & 4 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,11 @@ import { pythDataPlugin } from "@elizaos/plugin-pyth-data";
import { openaiPlugin } from "@elizaos/plugin-openai";
import nitroPlugin from "@elizaos/plugin-router-nitro";
import { devinPlugin } from "@elizaos/plugin-devin";

import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";

import { chainbasePlugin } from "@elizaos/plugin-chainbase";

import { nvidiaNimPlugin } from "@elizaos/plugin-nvidia-nim";

import { zxPlugin } from "@elizaos/plugin-0x";
import { hyperbolicPlugin } from "@elizaos/plugin-hyperbolic";
import Database from "better-sqlite3";
import fs from "fs";
import net from "net";
Expand Down Expand Up @@ -1161,6 +1158,9 @@ export async function createAgent(
getSecret(character, "EMAIL_INCOMING_USER") && getSecret(character, "EMAIL_INCOMING_PASS") ||
getSecret(character, "EMAIL_OUTGOING_USER") && getSecret(character, "EMAIL_OUTGOING_PASS") ?
emailPlugin : null,
getSecret(character, "HYPERBOLIC_API_KEY")
? hyperbolicPlugin
: null,
getSecret(character, "SUNO_API_KEY") ? sunoPlugin : null,
getSecret(character, "UDIO_AUTH_TOKEN") ? udioPlugin : null
].filter(Boolean),
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-hyperbolic/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
41 changes: 41 additions & 0 deletions packages/plugin-hyperbolic/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "error"
},
"style": {
"useConst": "error",
"useImportType": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "es5"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
56 changes: 56 additions & 0 deletions packages/plugin-hyperbolic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@elizaos/plugin-hyperbolic",
"version": "0.1.8+build.1",
"description": "HyperBolic Plugin for ElizaOS",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"clean": "rm -rf dist",
"lint": "biome lint .",
"lint:fix": "biome check --apply .",
"format": "biome format .",
"format:fix": "biome format --write .",
"test": "vitest",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"axios": "^1.6.5",
"chalk": "^5.3.0",
"cli-table3": "^0.6.3",
"dotenv": "^16.4.1",
"ora": "^8.0.1",
"zod": "^3.22.4",
"ssh2": "^1.15.0",
"@coinbase/coinbase-sdk": "^0.15.0",
"viem": "^2.0.0",
"decimal.js": "^10.4.3"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/dotenv": "^8.2.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.11.5",
"@types/ssh2": "^1.11.18",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@vitest/coverage-v8": "^1.2.1",
"@vitest/ui": "^0.34.6",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-tsconfig-paths": "^4.2.2",
"vitest": "^1.2.1"
},
"peerDependencies": {
"@elizaos/core": "workspace:*"
},
"engines": {
"node": ">=18.0.0"
}
}
133 changes: 133 additions & 0 deletions packages/plugin-hyperbolic/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

![alt text](src/assets/hyperbolic.png)

# Hyperbolic Plugin
A powerful plugin for managing GPU instances on the Hyperbolic platform through Eliza AI.

## Features

- List available GPUs with specifications and pricing
- Check account balance
- Monitor GPU instance status
- View spending history
- Rent GPU instances
- Terminate GPU instances

## Actions

### 1. GET_HB_AVAILABLE_GPUS
Lists all available GPU machines on the Hyperbolic platform with their specifications and pricing.

**Example prompt:**
```
Show me available GPUs on Hyperbolic
```

### 2. GET_CURRENT_BALANCE
Checks your current balance on the Hyperbolic platform.

**Example prompt:**
```
Show my current balance on Hyperbolic
```

### 3. GET_GPU_STATUS
Monitors the status of all your GPU instances.

**Example prompt:**
```
Check status of all my GPU instances on Hyperbolic
```

### 4. GET_SPEND_HISTORY
Shows your spending history on the Hyperbolic platform.

**Example prompt:**
```
Show my spending history on Hyperbolic
```

### 5. RENT_HB_COMPUTE
Rents a GPU instance using node ID and cluster name.

**Example prompt:**
```
Create a GPU instance on the Hyperbolic
[nodeid]las1-prd-acl-msi-09.fen.intra[/nodeid]
[cluster]circular-snapdragon-worm[/cluster]
```

**Required format:**
- Node ID must be wrapped in `[nodeid]` tags
- Cluster name must be wrapped in `[cluster]` tags

### 6. TERMINATE_COMPUTE
Terminates a running GPU instance.

**Example prompts:**
```
Terminate the Hyperbolic instance [gpu]worse-walnut-viper[/gpu]
```
```
Terminate the Hyperbolic instance [gpu]puny-clover-basilisk[/gpu]
```

**Important Note:** When terminating an instance, you must provide the instance ID wrapped in `[gpu]` tags. The examples above show two different instance IDs (`worse-walnut-viper` and `puny-clover-basilisk`) to demonstrate the format.

## Configuration

The plugin requires the following environment variables:

```bash
HYPERBOLIC_API_KEY=your_api_key_here
HYPERBOLIC_ENV=production # or development
HYPERBOLIC_GRANULAR_LOG=true # optional, for detailed logging
HYPERBOLIC_LOG_LEVEL=debug # optional, to control the level
HYPERBOLIC_SPASH=true # to show the splash
```

## Response Format

All actions return structured responses with:
- Success/failure status
- Detailed error messages when applicable
- Formatted text output
- Additional data specific to each action

## Error Handling

The plugin includes comprehensive error handling for:
- Invalid API keys
- Network issues
- Invalid input formats
- API rate limits
- Server errors

## Logging

Granular logging is available by setting `HYPERBOLIC_GRANULAR_LOG=true`. This provides detailed information about:
- API requests and responses
- Validation steps
- Error details
- Action execution flow

## Development

To extend or modify this plugin:

1. All actions are in the `src/actions` directory
2. Utility functions are in `src/utils`
3. Environment configuration is in `src/environment.ts`
4. Error types are in `src/error/base.ts`

## Dependencies

- @elizaos/core
- axios
- chalk (for console output)
- cli-table3 (for formatted tables)
- ora (for loading spinners)

## License

MIT License
Loading

0 comments on commit 02518fa

Please sign in to comment.