Skip to content

Commit

Permalink
Merge branch 'develop' into tcm-fix-plugin-twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 authored Jan 10, 2025
2 parents 6e61d9e + e1b7c80 commit 0774129
Show file tree
Hide file tree
Showing 51 changed files with 3,614 additions and 407 deletions.
11 changes: 10 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ TOGETHER_API_KEY= # Together API Key
#### Crypto Plugin Configurations ####
######################################

# COIN DATA SOURCES
# CoinMarketCap / CMC
COINMARKETCAP_API_KEY=

# CoinGecko
COINGECKO_API_KEY=
COINGECKO_PRO_API_KEY=

# EVM
EVM_PRIVATE_KEY=
Expand Down Expand Up @@ -438,6 +441,8 @@ GIPHY_API_KEY=
# OpenWeather
OPEN_WEATHER_API_KEY= # OpenWeather API key



# EchoChambers Configuration
ECHOCHAMBERS_API_URL=http://127.0.0.1:3333
ECHOCHAMBERS_API_KEY=testingkey0011
Expand Down Expand Up @@ -471,3 +476,7 @@ TAVILY_API_KEY=
# Verifiable Inference Configuration
VERIFIABLE_INFERENCE_ENABLED=false # Set to false to disable verifiable inference
VERIFIABLE_INFERENCE_PROVIDER=opacity # Options: opacity

# Autonome Configuration
AUTONOME_JWT_TOKEN=
AUTONOME_RPC=https://wizard-bff-rpc.alt.technology/v1/bff/aaa/apps
4 changes: 2 additions & 2 deletions .github/workflows/pnpm-lockfile-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Pnpm Lockfile Check

on:
pull_request:
branches: ["*"]
branches: [main]

jobs:
check-lockfile:
Expand Down Expand Up @@ -38,4 +38,4 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ The pnpm-lockfile is out of date. Please run `pnpm install --no-frozen-lockfile` and commit the updated pnpm-lock.yaml file.'
})
})
5 changes: 4 additions & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-coinmarketcap": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-binance": "workspace:*",
Expand All @@ -56,6 +57,7 @@
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-solana-agentkit": "workspace:*",
"@elizaos/plugin-autonome": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-stargaze": "workspace:*",
"@elizaos/plugin-giphy": "workspace:*",
Expand All @@ -73,6 +75,7 @@
"@elizaos/plugin-3d-generation": "workspace:*",
"@elizaos/plugin-fuel": "workspace:*",
"@elizaos/plugin-avalanche": "workspace:*",
"@elizaos/plugin-video-generation": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-letzai": "workspace:*",
"@elizaos/plugin-thirdweb": "workspace:*",
Expand All @@ -94,4 +97,4 @@
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
}
}
62 changes: 45 additions & 17 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,19 @@ import { nearPlugin } from "@elizaos/plugin-near";
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
import { createNodePlugin } from "@elizaos/plugin-node";
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { solanaPlugin } from "@elizaos/plugin-solana";
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
import { autonomePlugin } from "@elizaos/plugin-autonome";
import { storyPlugin } from "@elizaos/plugin-story";
import { suiPlugin } from "@elizaos/plugin-sui";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
import { tonPlugin } from "@elizaos/plugin-ton";
import { webSearchPlugin } from "@elizaos/plugin-web-search";

import { coingeckoPlugin } from "@elizaos/plugin-coingecko";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
Expand Down Expand Up @@ -141,10 +143,6 @@ function tryLoadFile(filePath: string): string | null {
}
}

function isAllStrings(arr: unknown[]): boolean {
return Array.isArray(arr) && arr.every((item) => typeof item === "string");
}

export async function loadCharacters(
charactersArg: string
): Promise<Character[]> {
Expand Down Expand Up @@ -230,16 +228,9 @@ export async function loadCharacters(
}

// Handle plugins
if (isAllStrings(character.plugins)) {
elizaLogger.info("Plugins are: ", character.plugins);
const importedPlugins = await Promise.all(
character.plugins.map(async (plugin) => {
const importedPlugin = await import(plugin);
return importedPlugin.default;
})
);
character.plugins = importedPlugins;
}
character.plugins = await handlePluginImporting(
character.plugins
);

loadedCharacters.push(character);
elizaLogger.info(
Expand All @@ -262,6 +253,36 @@ export async function loadCharacters(
return loadedCharacters;
}

async function handlePluginImporting(plugins: string[]) {
if (plugins.length > 0) {
elizaLogger.info("Plugins are: ", plugins);
const importedPlugins = await Promise.all(
plugins.map(async (plugin) => {
try {
const importedPlugin = await import(plugin);
const functionName =
plugin
.replace("@elizaos/plugin-", "")
.replace(/-./g, (x) => x[1].toUpperCase()) +
"Plugin"; // Assumes plugin function is camelCased with Plugin suffix
return (
importedPlugin.default || importedPlugin[functionName]
);
} catch (importError) {
elizaLogger.error(
`Failed to import plugin: ${plugin}`,
importError
);
return []; // Return null for failed imports
}
})
);
return importedPlugins;
} else {
return [];
}
}

export function getTokenForProvider(
provider: ModelProviderName,
character: Character
Expand Down Expand Up @@ -617,6 +638,7 @@ export async function createAgent(
getSecret(character, "SOLANA_PRIVATE_KEY")
? solanaAgentkitPlguin
: null,
getSecret(character, "AUTONOME_JWT_TOKEN") ? autonomePlugin : null,
(getSecret(character, "NEAR_ADDRESS") ||
getSecret(character, "NEAR_WALLET_PUBLIC_KEY")) &&
getSecret(character, "NEAR_WALLET_SECRET_KEY")
Expand Down Expand Up @@ -678,7 +700,10 @@ export async function createAgent(
? webhookPlugin
: null,
goatPlugin,
getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null,
getSecret(character, "COINGECKO_API_KEY") ||
getSecret(character, "COINGECKO_PRO_API_KEY")
? coingeckoPlugin
: null,
getSecret(character, "EVM_PROVIDER_URL") ? goatPlugin : null,
getSecret(character, "ABSTRACT_PRIVATE_KEY")
? abstractPlugin
Expand Down Expand Up @@ -917,7 +942,10 @@ const startAgents = async () => {
}

// upload some agent functionality into directClient
directClient.startAgent = async (character: Character) => {
directClient.startAgent = async (character) => {
// Handle plugins
character.plugins = await handlePluginImporting(character.plugins);

// wrap it so we don't have to inject directClient later
return startAgent(character, directClient);
};
Expand Down
83 changes: 83 additions & 0 deletions docs/docs/advanced/verified-inference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
sidebar_position: 18
---

# 🪪 Verified Inference

## Overview

With verified inference, you can turn your Eliza agent fully verifiable on-chain on Solana with an OpenAI compatible TEE API. This proves that your agent’s thoughts and outputs are free from human control thus increasing the trust of the agent.

Compared to [fully deploying the agent in a TEE](https://elizaos.github.io/eliza/docs/advanced/eliza-in-tee/), this is a more light-weight solution which only verifies the inference calls and only needs a single line of code change.

The API supports all OpenAI models out of the box, including your fine-tuned models. The following guide will walk you through how to use verified inference API with Eliza.

## Background

The API is built on top of [Sentience Stack](https://github.com/galadriel-ai/Sentience), which cryptographically verifies agent's LLM inferences inside TEEs, posts those proofs on-chain on Solana, and makes the verified inference logs available to read and display to users.

Here’s how it works:
![](https://i.imgur.com/SNwSHam.png)

1. The agent sends a request containing a message with the desired LLM model to the TEE.
2. The TEE securely processes the request by calling the LLM API.
3. The TEE sends back the `{Message, Proof}` to the agent.
4. The TEE submits the attestation with `{Message, Proof}` to Solana.
5. The Proof of Sentience SDK is used to read the attestation from Solana and verify it with `{Message, Proof}`. The proof log can be added to the agent website/app.

To verify the code running inside the TEE, use instructions [from here](https://github.com/galadriel-ai/sentience/tree/main/verified-inference/verify).

## Tutorial

1. **Create a free API key on [Galadriel dashboard](https://dashboard.galadriel.com/login)**
2. **Configure the environment variables**
```bash
GALADRIEL_API_KEY=gal-* # Get from https://dashboard.galadriel.com/
# Use any model supported by OpenAI
SMALL_GALADRIEL_MODEL= # Default: gpt-4o-mini
MEDIUM_GALADRIEL_MODEL= # Default: gpt-4o
LARGE_GALADRIEL_MODEL= # Default: gpt-4o
# If you wish to use a fine-tuned model you will need to provide your own OpenAI API key
GALADRIEL_FINE_TUNE_API_KEY= # starting with sk-
```
3. **Configure your character to use `galadriel`**

In your character file set the `modelProvider` as `galadriel`.
```
"modelProvider": "galadriel"
```
4. **Run your agent.**

Reminder how to run an agent is [here](https://elizaos.github.io/eliza/docs/quickstart/#create-your-first-agent).
```bash
pnpm start --character="characters/<your_character>.json"
pnpm start:client
```
5. **Get the history of all of your verified inference calls**
```javascript
const url = 'https://api.galadriel.com/v1/verified/chat/completions?limit=100&filter=mine';
const headers = {
'accept': 'application/json',
'Authorization': 'Bearer <GALADRIEL_API_KEY>'// Replace with your Galadriel API key
};
const response = await fetch(url, { method: 'GET', headers });
const data = await response.json();
console.log(data);
```
Use this to build a verified logs terminal to your agent front end, for example:
![](https://i.imgur.com/yejIlao.png)
6. **Check your inferences in the explorer.**
You can also see your inferences with proofs in the [Galadriel explorer](https://explorer.galadriel.com/). For specific inference responses use `https://explorer.galadriel.com/details/<hash>`
The `hash` param is returned with every inference request.
![](https://i.imgur.com/QazDxbE.png)
7. **Check proofs posted on Solana.**
You can also see your inferences with proofs on Solana. For specific inference responses: `https://explorer.solana.com/tx/<>tx_hash?cluster=devnet`
The `tx_hash` param is returned with every inference request.
30 changes: 15 additions & 15 deletions docs/docs/packages/clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ graph TD

## Available Clients

- **Discord** (`@eliza/client-discord`) - Full Discord bot integration
- **Twitter** (`@eliza/client-twitter`) - Twitter bot and interaction handling
- **Telegram** (`@eliza/client-telegram`) - Telegram bot integration
- **Direct** (`@eliza/client-direct`) - Direct API interface for custom integrations
- **Auto** (`@eliza/client-auto`) - Automated trading and interaction client
- **Discord** (`@elizaos/client-discord`) - Full Discord bot integration
- **Twitter** (`@elizaos/client-twitter`) - Twitter bot and interaction handling
- **Telegram** (`@elizaos/client-telegram`) - Telegram bot integration
- **Direct** (`@elizaos/client-direct`) - Direct API interface for custom integrations
- **Auto** (`@elizaos/client-auto`) - Automated trading and interaction client

---

## Installation

```bash
# Discord
pnpm add @eliza/client-discord
pnpm add @elizaos/client-discord

# Twitter
pnpm add @eliza/client-twitter
pnpm add @elizaos/client-twitter

# Telegram
pnpm add @eliza/client-telegram
pnpm add @elizaos/client-telegram

# Direct API
pnpm add @eliza/client-direct
pnpm add @elizaos/client-direct

# Auto Client
pnpm add @eliza/client-auto
pnpm add @elizaos/client-auto
```

---
Expand All @@ -71,7 +71,7 @@ The Discord client provides full integration with Discord's features including v
### Basic Setup

```typescript
import { DiscordClientInterface } from "@eliza/client-discord";
import { DiscordClientInterface } from "@elizaos/client-discord";

// Initialize client
const client = await DiscordClientInterface.start(runtime);
Expand Down Expand Up @@ -133,7 +133,7 @@ The Twitter client enables posting, searching, and interacting with Twitter user
### Basic Setup

```typescript
import { TwitterClientInterface } from "@eliza/client-twitter";
import { TwitterClientInterface } from "@elizaos/client-twitter";
// Initialize client
const client = await TwitterClientInterface.start(runtime);

Expand Down Expand Up @@ -192,7 +192,7 @@ The Telegram client provides messaging and bot functionality for Telegram.
### Basic Setup

```typescript
import { TelegramClientInterface } from "@eliza/client-telegram";
import { TelegramClientInterface } from "@elizaos/client-telegram";

// Initialize client
const client = await TelegramClientInterface.start(runtime);
Expand Down Expand Up @@ -225,7 +225,7 @@ The Direct client provides a REST API interface for custom integrations.
### Basic Setup

```typescript
import { DirectClientInterface } from "@eliza/client-direct";
import { DirectClientInterface } from "@elizaos/client-direct";

// Initialize client
const client = await DirectClientInterface.start(runtime);
Expand Down Expand Up @@ -258,7 +258,7 @@ The Auto client enables automated interactions and trading.
### Basic Setup

```typescript
import { AutoClientInterface } from "@eliza/client-auto";
import { AutoClientInterface } from "@elizaos/client-auto";

// Initialize client
const client = await AutoClientInterface.start(runtime);
Expand Down
5 changes: 5 additions & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ const sidebars = {
id: "advanced/eliza-in-tee",
label: "Eliza in TEE",
},
{
type: "doc",
id: "advanced/verified-inference",
label: "Verified Inference",
},
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/client-telegram/src/messageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ export class MessageManager {

// Check if team member has direct interest first
if (
this.runtime.character.clientConfig?.discord?.isPartOfTeam &&
this.runtime.character.clientConfig?.telegram?.isPartOfTeam &&
!this._isTeamLeader() &&
this._isRelevantToTeamMember(messageText, chatId)
) {
Expand Down
Loading

0 comments on commit 0774129

Please sign in to comment.