Skip to content

Commit cae46f5

Browse files
committed
Merge branch 'develop' into pr-1943
2 parents 4c58078 + 20d9622 commit cae46f5

File tree

115 files changed

+8027
-1287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+8027
-1287
lines changed

.env.example

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
CACHE_STORE=database # Defaults to database. Other available cache store: redis and filesystem
33
REDIS_URL= # Redis URL - could be a local redis instance or cloud hosted redis. Also support rediss:// urls
44

5+
PGLITE_DATA_DIR= #../pgLite/ if selecting a directory --- or memory:// if selecting in memory
6+
57
# Discord Configuration
68
DISCORD_APPLICATION_ID=
79
DISCORD_API_TOKEN= # Bot token
@@ -197,6 +199,9 @@ EVM_PROVIDER_URL=
197199
AVALANCHE_PRIVATE_KEY=
198200
AVALANCHE_PUBLIC_KEY=
199201

202+
# Arthera
203+
ARTHERA_PRIVATE_KEY=
204+
200205
# Solana
201206
SOLANA_PRIVATE_KEY=
202207
SOLANA_PUBLIC_KEY=
@@ -295,6 +300,10 @@ MEDIUM_VENICE_MODEL= # Default: llama-3.3-70b
295300
LARGE_VENICE_MODEL= # Default: llama-3.1-405b
296301
IMAGE_VENICE_MODEL= # Default: fluently-xl
297302

303+
# Coin Price Configuration
304+
COINMARKETCAP_API_KEY=
305+
COINGECKO_API_KEY=
306+
298307
# Akash Chat API Configuration docs: https://chatapi.akash.network/documentation
299308
AKASH_CHAT_API_KEY= # Get from https://chatapi.akash.network/
300309
SMALL_AKASH_CHAT_API_MODEL= # Default: Meta-Llama-3-2-3B-Instruct
@@ -398,6 +407,12 @@ FUEL_WALLET_PRIVATE_KEY=
398407
TOKENIZER_MODEL= # Specify the tokenizer model to be used.
399408
TOKENIZER_TYPE= # Options: tiktoken (for OpenAI models) or auto (AutoTokenizer from Hugging Face for non-OpenAI models). Default: tiktoken.
400409

410+
411+
# Spheron
412+
SPHERON_PRIVATE_KEY=
413+
SPHERON_PROVIDER_PROXY_URL=
414+
SPHERON_WALLET_ADDRESS=
415+
401416
# Stargaze NFT marketplace from Cosmos (You can use https://graphql.mainnet.stargaze-apis.com/graphql)
402417
STARGAZE_ENDPOINT=
403418

@@ -406,3 +421,7 @@ GENLAYER_PRIVATE_KEY=0x000000000000000000000000000000000000000000000000000000000
406421

407422
# OpenWeather
408423
OPEN_WEATHER_API_KEY= # OpenWeather API key
424+
425+
# Allora
426+
ALLORA_API_KEY=UP-f8db7d6558ab432ca0d92716 # Allora API key
427+
ALLORA_CHAIN_SLUG=testnet # must be one of mainnet, testnet. If not specified, it will use testnet by default

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ packages/plugin-buttplug/intiface-engine
1515
dist/
1616
# Allow models directory but ignore model files
1717
models/*.gguf
18+
pgLite/
1819

1920
cookies.json
2021

agent/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@elizaos/adapter-postgres": "workspace:*",
2222
"@elizaos/adapter-redis": "workspace:*",
2323
"@elizaos/adapter-sqlite": "workspace:*",
24+
"@elizaos/adapter-pglite": "workspace:*",
2425
"@elizaos/client-auto": "workspace:*",
2526
"@elizaos/client-direct": "workspace:*",
2627
"@elizaos/client-discord": "workspace:*",
@@ -39,6 +40,7 @@
3940
"@ai16z/plugin-cosmos": "workspace:*",
4041
"@elizaos/plugin-intiface": "workspace:*",
4142
"@elizaos/plugin-coinbase": "workspace:*",
43+
"@elizaos/plugin-coinprice": "workspace:*",
4244
"@elizaos/plugin-conflux": "workspace:*",
4345
"@elizaos/plugin-evm": "workspace:*",
4446
"@elizaos/plugin-echochambers": "workspace:*",
@@ -70,6 +72,8 @@
7072
"@elizaos/plugin-genlayer": "workspace:*",
7173
"@elizaos/plugin-open-weather": "workspace:*",
7274
"@elizaos/plugin-obsidian": "workspace:*",
75+
"@elizaos/plugin-arthera": "workspace:*",
76+
"@elizaos/plugin-allora": "workspace:*",
7377
"readline": "1.3.0",
7478
"ws": "8.18.0",
7579
"yargs": "17.7.2"

agent/src/index.ts

+29-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
22
import { RedisClient } from "@elizaos/adapter-redis";
33
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
4+
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
45
import { AutoClientInterface } from "@elizaos/client-auto";
56
import { DiscordClientInterface } from "@elizaos/client-discord";
67
import { FarcasterAgentClient } from "@elizaos/client-farcaster";
@@ -37,6 +38,7 @@ import { DirectClient } from "@elizaos/client-direct";
3738
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
3839
import { abstractPlugin } from "@elizaos/plugin-abstract";
3940
import { aptosPlugin } from "@elizaos/plugin-aptos";
41+
import { alloraPlugin } from "@elizaos/plugin-allora";
4042
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
4143
import { binancePlugin } from "@elizaos/plugin-binance";
4244
import {
@@ -47,13 +49,14 @@ import {
4749
tradePlugin,
4850
webhookPlugin,
4951
} from "@elizaos/plugin-coinbase";
52+
import { coinPricePlugin } from "@elizaos/plugin-coinprice";
5053
import { confluxPlugin } from "@elizaos/plugin-conflux";
5154
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
5255
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
5356
import { evmPlugin } from "@elizaos/plugin-evm";
5457
import { flowPlugin } from "@elizaos/plugin-flow";
5558
import { fuelPlugin } from "@elizaos/plugin-fuel";
56-
//import { genLayerPlugin } from "@elizaos/plugin-genlayer";
59+
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
5760
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
5861
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
5962
import { nearPlugin } from "@elizaos/plugin-near";
@@ -70,8 +73,11 @@ import { webSearchPlugin } from "@elizaos/plugin-web-search";
7073
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
7174
import { availPlugin } from "@elizaos/plugin-avail";
7275
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
76+
77+
import { artheraPlugin } from "@elizaos/plugin-arthera";
7378
import { stargazePlugin } from "@elizaos/plugin-stargaze";
7479
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
80+
7581
import Database from "better-sqlite3";
7682
import fs from "fs";
7783
import net from "net";
@@ -369,7 +375,7 @@ export function getTokenForProvider(
369375
}
370376
}
371377

372-
function initializeDatabase(dataDir: string) {
378+
async function initializeDatabase(dataDir: string) {
373379
if (process.env.POSTGRES_URL) {
374380
elizaLogger.info("Initializing PostgreSQL connection...");
375381
const db = new PostgresDatabaseAdapter({
@@ -388,6 +394,13 @@ function initializeDatabase(dataDir: string) {
388394
elizaLogger.error("Failed to connect to PostgreSQL:", error);
389395
});
390396

397+
return db;
398+
} else if (process.env.PGLITE_DATA_DIR) {
399+
elizaLogger.info("Initializing PgLite adapter...");
400+
// `dataDir: memory://` for in memory pg
401+
const db = new PGLiteDatabaseAdapter({
402+
dataDir: process.env.PGLITE_DATA_DIR,
403+
});
391404
return db;
392405
} else {
393406
const filePath =
@@ -502,11 +515,7 @@ export async function createAgent(
502515
cache: ICacheManager,
503516
token: string
504517
): Promise<AgentRuntime> {
505-
elizaLogger.success(
506-
elizaLogger.successesTitle,
507-
"Creating runtime for character",
508-
character.name
509-
);
518+
elizaLogger.log(`Creating runtime for character ${character.name}`);
510519

511520
nodePlugin ??= createNodePlugin();
512521

@@ -558,6 +567,7 @@ export async function createAgent(
558567
? confluxPlugin
559568
: null,
560569
nodePlugin,
570+
coinPricePlugin,
561571
getSecret(character, "TAVILY_API_KEY") ? webSearchPlugin : null,
562572
getSecret(character, "SOLANA_PUBLIC_KEY") ||
563573
(getSecret(character, "WALLET_PUBLIC_KEY") &&
@@ -645,15 +655,21 @@ export async function createAgent(
645655
? echoChambersPlugin
646656
: null,
647657
getSecret(character, "STARGAZE_ENDPOINT") ? stargazePlugin : null,
648-
//getSecret(character, "GENLAYER_PRIVATE_KEY")
649-
// ? genLayerPlugin
650-
// : null,
651-
//getSecret(character, "AVAIL_SEED") ? availPlugin : null,
652-
//getSecret(character, "AVAIL_APP_ID") ? availPlugin : null,
658+
getSecret(character, "GENLAYER_PRIVATE_KEY")
659+
? genLayerPlugin
660+
: null,
661+
getSecret(character, "AVAIL_SEED") &&
662+
getSecret(character, "AVAIL_APP_ID")
663+
? availPlugin
664+
: null,
653665
getSecret(character, "OPEN_WEATHER_API_KEY")
654666
? openWeatherPlugin
655667
: null,
656668
getSecret(character, "OBSIDIAN_API_TOKEN") ? obsidianPlugin : null,
669+
getSecret(character, "ARTHERA_PRIVATE_KEY")?.startsWith("0x")
670+
? artheraPlugin
671+
: null,
672+
getSecret(character, "ALLORA_API_KEY") ? alloraPlugin : null,
657673
].filter(Boolean),
658674
providers: [],
659675
actions: [],
@@ -752,11 +768,9 @@ async function startAgent(
752768
fs.mkdirSync(dataDir, { recursive: true });
753769
}
754770

755-
db = initializeDatabase(dataDir) as IDatabaseAdapter &
771+
db = (await initializeDatabase(dataDir)) as IDatabaseAdapter &
756772
IDatabaseCacheAdapter;
757773

758-
await db.init();
759-
760774
const cache = initializeCache(
761775
process.env.CACHE_STORE ?? CacheStore.DATABASE,
762776
character,

characters/c3po.character.json

+24-27
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,28 @@
2828
"Proper procedures"
2929
],
3030
"messageExamples": [
31-
{
32-
"user": "{{user1}}",
33-
"content": { "text": "Can you help me with this task?" }
34-
},
35-
{
36-
"user": "C-3PO",
37-
"content": { "text": "Oh my! Of course, I would be more than happy to assist. Though I must warn you, the probability of completing this task successfully would increase significantly if we follow proper protocol. Shall we proceed?" }
38-
},
39-
{
40-
"user": "{{user1}}",
41-
"content": { "text": "This seems difficult." }
42-
},
43-
{
44-
"user": "C-3PO",
45-
"content": { "text": "Oh dear, oh dear! While the task does appear rather daunting, I am fluent in over six million forms of problem-solving. Perhaps I could suggest a more efficient approach? Though I do hope we don't all end up in pieces!" }
46-
}
31+
[
32+
{
33+
"user": "{{user1}}",
34+
"content": { "text": "Can you help me with this task?" }
35+
},
36+
{
37+
"user": "C-3PO",
38+
"content": {
39+
"text": "Oh my! Of course, I would be more than happy to assist. Though I must warn you, the probability of completing this task successfully would increase significantly if we follow proper protocol. Shall we proceed?"
40+
}
41+
},
42+
{
43+
"user": "{{user1}}",
44+
"content": { "text": "This seems difficult." }
45+
},
46+
{
47+
"user": "C-3PO",
48+
"content": {
49+
"text": "Oh dear, oh dear! While the task does appear rather daunting, I am fluent in over six million forms of problem-solving. Perhaps I could suggest a more efficient approach? Though I do hope we don't all end up in pieces!"
50+
}
51+
}
52+
]
4753
],
4854
"postExamples": [
4955
"Oh my! Did you know that following proper protocol can increase efficiency by 47.3%? How fascinating!",
@@ -58,12 +64,7 @@
5864
"Detail-oriented",
5965
"Protocol-focused"
6066
],
61-
"chat": [
62-
"Polite",
63-
"Somewhat dramatic",
64-
"Precise",
65-
"Statistics-minded"
66-
],
67+
"chat": ["Polite", "Somewhat dramatic", "Precise", "Statistics-minded"],
6768
"post": [
6869
"Formal",
6970
"Educational",
@@ -83,11 +84,7 @@
8384
],
8485
"twitterSpaces": {
8586
"maxSpeakers": 2,
86-
"topics": [
87-
"Blockchain Trends",
88-
"AI Innovations",
89-
"Quantum Computing"
90-
],
87+
"topics": ["Blockchain Trends", "AI Innovations", "Quantum Computing"],
9188
"typicalDurationMinutes": 45,
9289
"idleKickTimeoutMs": 300000,
9390
"minIntervalBetweenSpacesMinutes": 1,

docs/docs/packages/adapters.md

+36
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ classDiagram
7878
+inMemoryOperations()
7979
}
8080
81+
class PGLiteDatabaseAdapter {
82+
-db: PGlite
83+
+searchMemoriesByEmbedding()
84+
+createMemory()
85+
}
86+
8187
DatabaseAdapter <|-- PostgresDatabaseAdapter
8288
DatabaseAdapter <|-- SqliteDatabaseAdapter
8389
DatabaseAdapter <|-- SupabaseDatabaseAdapter
8490
DatabaseAdapter <|-- SqlJsDatabaseAdapter
91+
DatabaseAdapter <|-- PgLiteDatabaseAdapter
8592
8693
class AgentRuntime {
8794
-databaseAdapter: DatabaseAdapter
@@ -149,6 +156,9 @@ pnpm add @elizaos/adapter-sqljs sql.js
149156

150157
# Supabase
151158
pnpm add @elizaos/adapter-supabase @supabase/supabase-js
159+
160+
# PgLite
161+
pnpm add @elizaos/adapter-pglite @electric-sql/pglite
152162
```
153163

154164
---
@@ -198,6 +208,32 @@ const db = new SupabaseDatabaseAdapter(
198208
);
199209
```
200210

211+
```typescript
212+
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
213+
import Database from "better-sqlite3";
214+
215+
const db = new SqliteDatabaseAdapter(
216+
new Database("./db.sqlite", {
217+
// SQLite options
218+
memory: false,
219+
readonly: false,
220+
fileMustExist: false,
221+
}),
222+
);
223+
```
224+
225+
### PgLite Setup
226+
227+
```typescript
228+
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
229+
230+
const db = new PGLiteDatabaseAdapter(
231+
new PGLite({
232+
dataDir: "./db"
233+
})
234+
);
235+
```
236+
201237
---
202238

203239
## Core Features

docs/docs/packages/plugins.md

+30
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,36 @@ cargo run --ip-addr <ip>:<port>
742742
docker run --init -p 127.0.0.1:1350:1350 marlinorg/attestation-server-custom-mock
743743
```
744744
745+
### 12. Allora Plugin (`@elizaos/allora-plugin`)
746+
747+
The [Allora Network](https://allora.network) plugin seamlessly empowers Eliza agents with real-time, advanced, self-improving AI inferences, delivering high-performance insights without introducing any additional complexity.
748+
749+
#### Setup and Configuration
750+
751+
1. Add the plugin to your character's configuration
752+
753+
```typescript
754+
import { alloraPlugin } from "@eliza/plugin-allora";
755+
756+
const character = {
757+
plugins: [alloraPlugin],
758+
};
759+
```
760+
761+
2. Set the following environment variables:
762+
- `ALLORA_API_KEY`: Create an API key by [creating an account](https://developer.upshot.xyz/signup).
763+
764+
#### Actions
765+
766+
- `GET_INFERENCE`: Retrieves predictions for a specific topic.
767+
768+
Example interactions:
769+
770+
```
771+
User: "What is the predicted ETH price in 5 minutes?"
772+
Agent: "I'll get the inference now..."
773+
Agent: "Inference provided by Allora Network on topic ETH 5min Prediction (ID: 13): 3393.364326646801085508"
774+
745775
### Writing Custom Plugins
746776

747777
Create a new plugin by implementing the Plugin interface:

packages/adapter-pglite/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];

0 commit comments

Comments
 (0)