Skip to content

Commit 32efa54

Browse files
authored
Merge branch 'develop' into feature/add-coinmarketcap-plugin
2 parents 39ad2a8 + 8bbdafb commit 32efa54

21 files changed

+941
-10
lines changed

.env.example

+12
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ SPHERON_WALLET_ADDRESS=
424424
# Stargaze NFT marketplace from Cosmos (You can use https://graphql.mainnet.stargaze-apis.com/graphql)
425425
STARGAZE_ENDPOINT=
426426

427+
# API key for giphy from https://developers.giphy.com/dashboard/
428+
GIPHY_API_KEY=
429+
427430
# GenLayer
428431
GENLAYER_PRIVATE_KEY= # Private key of the GenLayer account to use for the agent in this format (0x0000000000000000000000000000000000000000000000000000000000000000)
429432

@@ -433,3 +436,12 @@ OPEN_WEATHER_API_KEY= # OpenWeather API key
433436
# Allora
434437
ALLORA_API_KEY= # Allora API key, format: UP-f8db7d6558ab432ca0d92716
435438
ALLORA_CHAIN_SLUG= # must be one of mainnet, testnet. If not specified, it will use testnet by default
439+
440+
# Opacity zkTLS
441+
OPACITY_TEAM_ID=f309ac8ae8a9a14a7e62cd1a521b1c5f
442+
OPACITY_CLOUDFLARE_NAME=eigen-test
443+
OPACITY_PROVER_URL=https://opacity-ai-zktls-demo.vercel.app
444+
445+
# Verifiable Inference Configuration
446+
VERIFIABLE_INFERENCE_ENABLED=false # Set to false to disable verifiable inference
447+
VERIFIABLE_INFERENCE_PROVIDER=opacity # Options: opacity

agent/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@elizaos/plugin-solana-agentkit": "workspace:*",
5959
"@elizaos/plugin-starknet": "workspace:*",
6060
"@elizaos/plugin-stargaze": "workspace:*",
61+
"@elizaos/plugin-giphy": "workspace:*",
6162
"@elizaos/plugin-ton": "workspace:*",
6263
"@elizaos/plugin-sui": "workspace:*",
6364
"@elizaos/plugin-tee": "workspace:*",
@@ -78,6 +79,7 @@
7879
"@elizaos/plugin-obsidian": "workspace:*",
7980
"@elizaos/plugin-arthera": "workspace:*",
8081
"@elizaos/plugin-allora": "workspace:*",
82+
"@elizaos/plugin-opacity": "workspace:*",
8183
"readline": "1.3.0",
8284
"ws": "8.18.0",
8385
"yargs": "17.7.2"

agent/src/index.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,19 @@ import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
7979
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
8080
import { tonPlugin } from "@elizaos/plugin-ton";
8181
import { webSearchPlugin } from "@elizaos/plugin-web-search";
82+
83+
import { giphyPlugin } from "@elizaos/plugin-giphy";
84+
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
85+
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
86+
8287
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
8388
import Database from "better-sqlite3";
8489
import fs from "fs";
8590
import net from "net";
8691
import path from "path";
8792
import { fileURLToPath } from "url";
8893
import yargs from "yargs";
94+
import { OpacityAdapter } from "@elizaos/plugin-opacity";
8995

9096
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
9197
const __dirname = path.dirname(__filename); // get the name of the directory
@@ -554,6 +560,28 @@ export async function createAgent(
554560
// });
555561
// elizaLogger.log("Verifiable inference adapter initialized");
556562
// }
563+
// Initialize Opacity adapter if environment variables are present
564+
let verifiableInferenceAdapter;
565+
if (
566+
process.env.OPACITY_TEAM_ID &&
567+
process.env.OPACITY_CLOUDFLARE_NAME &&
568+
process.env.OPACITY_PROVER_URL &&
569+
process.env.VERIFIABLE_INFERENCE_ENABLED === "true"
570+
) {
571+
verifiableInferenceAdapter = new OpacityAdapter({
572+
teamId: process.env.OPACITY_TEAM_ID,
573+
teamName: process.env.OPACITY_CLOUDFLARE_NAME,
574+
opacityProverUrl: process.env.OPACITY_PROVER_URL,
575+
modelProvider: character.modelProvider,
576+
token: token,
577+
});
578+
elizaLogger.log("Verifiable inference adapter initialized");
579+
elizaLogger.log("teamId", process.env.OPACITY_TEAM_ID);
580+
elizaLogger.log("teamName", process.env.OPACITY_CLOUDFLARE_NAME);
581+
elizaLogger.log("opacityProverUrl", process.env.OPACITY_PROVER_URL);
582+
elizaLogger.log("modelProvider", character.modelProvider);
583+
elizaLogger.log("token", token);
584+
}
557585

558586
return new AgentRuntime({
559587
databaseAdapter: db,
@@ -663,6 +691,7 @@ export async function createAgent(
663691
? echoChambersPlugin
664692
: null,
665693
getSecret(character, "STARGAZE_ENDPOINT") ? stargazePlugin : null,
694+
getSecret(character, "GIPHY_API_KEY") ? giphyPlugin : null,
666695
getSecret(character, "GENLAYER_PRIVATE_KEY")
667696
? genLayerPlugin
668697
: null,
@@ -685,7 +714,7 @@ export async function createAgent(
685714
managers: [],
686715
cacheManager: cache,
687716
fetch: logFetch,
688-
// verifiableInferenceAdapter,
717+
verifiableInferenceAdapter,
689718
});
690719
}
691720

packages/client-telegram/src/messageManager.ts

+41-2
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,11 @@ export class MessageManager {
678678
): Promise<Message.TextMessage[]> {
679679
if (content.attachments && content.attachments.length > 0) {
680680
content.attachments.map(async (attachment: Media) => {
681-
if (attachment.contentType.startsWith("image")) {
682-
this.sendImage(ctx, attachment.url, attachment.description);
681+
if (attachment.contentType === "image/gif") {
682+
// Handle GIFs specifically
683+
await this.sendAnimation(ctx, attachment.url, attachment.description);
684+
} else if (attachment.contentType.startsWith("image")) {
685+
await this.sendImage(ctx, attachment.url, attachment.description);
683686
}
684687
});
685688
} else {
@@ -743,6 +746,42 @@ export class MessageManager {
743746
}
744747
}
745748

749+
private async sendAnimation(
750+
ctx: Context,
751+
animationPath: string,
752+
caption?: string
753+
): Promise<void> {
754+
try {
755+
if (/^(http|https):\/\//.test(animationPath)) {
756+
// Handle HTTP URLs
757+
await ctx.telegram.sendAnimation(ctx.chat.id, animationPath, {
758+
caption,
759+
});
760+
} else {
761+
// Handle local file paths
762+
if (!fs.existsSync(animationPath)) {
763+
throw new Error(`File not found: ${animationPath}`);
764+
}
765+
766+
const fileStream = fs.createReadStream(animationPath);
767+
768+
await ctx.telegram.sendAnimation(
769+
ctx.chat.id,
770+
{
771+
source: fileStream,
772+
},
773+
{
774+
caption,
775+
}
776+
);
777+
}
778+
779+
elizaLogger.info(`Animation sent successfully: ${animationPath}`);
780+
} catch (error) {
781+
elizaLogger.error("Error sending animation:", error);
782+
}
783+
}
784+
746785
// Split message into smaller parts
747786
private splitMessage(text: string): string[] {
748787
const chunks: string[] = [];

packages/core/src/generation.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,18 @@ export async function generateText({
212212
model: modelClass,
213213
verifiableInference,
214214
});
215-
215+
elizaLogger.log("Using provider:", runtime.modelProvider);
216216
// If verifiable inference is requested and adapter is provided, use it
217217
if (verifiableInference && runtime.verifiableInferenceAdapter) {
218+
elizaLogger.log("Using verifiable inference adapter:", runtime.verifiableInferenceAdapter);
218219
try {
219-
const result =
220+
const result: VerifiableInferenceResult =
220221
await runtime.verifiableInferenceAdapter.generateText(
221222
context,
222223
modelClass,
223224
verifiableInferenceOptions
224225
);
225-
226+
elizaLogger.log("Verifiable inference result:", result);
226227
// Verify the proof
227228
const isValid =
228229
await runtime.verifiableInferenceAdapter.verifyProof(result);

packages/core/src/types.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ export interface ISlackService extends Service {
14151415
* Available verifiable inference providers
14161416
*/
14171417
export enum VerifiableInferenceProvider {
1418-
RECLAIM = "reclaim",
1418+
OPACITY = "opacity",
14191419
}
14201420

14211421
/**
@@ -1436,8 +1436,10 @@ export interface VerifiableInferenceOptions {
14361436
export interface VerifiableInferenceResult {
14371437
/** Generated text */
14381438
text: string;
1439-
/** Proof data */
1440-
proof: unknown;
1439+
/** Proof */
1440+
proof: any;
1441+
/** Proof id */
1442+
id?: string;
14411443
/** Provider information */
14421444
provider: VerifiableInferenceProvider;
14431445
/** Timestamp */
@@ -1448,6 +1450,7 @@ export interface VerifiableInferenceResult {
14481450
* Interface for verifiable inference adapters
14491451
*/
14501452
export interface IVerifiableInferenceAdapter {
1453+
options: any;
14511454
/**
14521455
* Generate text with verifiable proof
14531456
* @param context The input text/prompt

packages/plugin-giphy/README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Plugin Giphy
2+
3+
A plugin for sending GIFs in response to user messages.
4+
5+
## Overview
6+
7+
The **Plugin Giphy** enhances your agent's interactions by enabling it to respond with relevant GIFs based on user inputs. Leveraging the [Giphy API](https://developers.giphy.com/), this plugin detects specific triggers in user messages and responds with appropriate GIFs to make conversations more engaging and expressive.
8+
9+
## Installation
10+
11+
```bash
12+
pnpm add @elizaos/plugin-giphy
13+
```
14+
15+
## Configuration
16+
17+
Set up your environment with the required Giphy API key:
18+
19+
| Variable Name | Description |
20+
|--------------|-------------|
21+
| `GIPHY_API_KEY` | Giphy API key for authenticating requests |
22+
23+
You need to obtain an API key by signing up at [Giphy Developers](https://developers.giphy.com/).
24+
25+
## Usage
26+
27+
```typescript
28+
import { giphyPlugin } from "@elizaos/plugin-giphy";
29+
30+
// Initialize the plugin
31+
const plugin = giphyPlugin;
32+
33+
// Add the plugin to your agent's plugin list
34+
const plugins = [
35+
giphyPlugin,
36+
// ... other plugins
37+
];
38+
39+
// Initialize your agent with the plugins
40+
// Example:
41+
// const agent = new Agent({ plugins, ...otherConfig });
42+
```
43+
44+
The plugin provides the `SEND_GIF` action, which automatically responds with a GIF based on the context of user messages. No additional setup is required beyond installing and configuring the plugin.
45+
46+
## License
47+
48+
MIT

packages/plugin-giphy/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@elizaos/plugin-giphy",
3+
"version": "0.1.0",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@elizaos/core": "workspace:*",
9+
"axios": "^1.6.7",
10+
"tsup": "^8.3.5",
11+
"zod": "^3.22.4"
12+
},
13+
"scripts": {
14+
"build": "tsup --format esm --dts",
15+
"dev": "tsup --format esm --dts --watch",
16+
"test": "vitest run"
17+
}
18+
}

0 commit comments

Comments
 (0)