Skip to content

Commit

Permalink
Merge branch 'develop' into twitter-url
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 authored Jan 7, 2025
2 parents 01275cb + 62de238 commit 5319131
Show file tree
Hide file tree
Showing 44 changed files with 3,360 additions and 198 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
CACHE_STORE=database # Defaults to database. Other available cache store: redis and filesystem
REDIS_URL= # Redis URL - could be a local redis instance or cloud hosted redis. Also support rediss:// urls

PGLITE_DATA_DIR= #../pgLite/ if selecting a directory --- or memory:// if selecting in memory

# Discord Configuration
DISCORD_APPLICATION_ID=
DISCORD_API_TOKEN= # Bot token
Expand Down Expand Up @@ -197,6 +199,9 @@ EVM_PROVIDER_URL=
AVALANCHE_PRIVATE_KEY=
AVALANCHE_PUBLIC_KEY=

# Arthera
ARTHERA_PRIVATE_KEY=

# Solana
SOLANA_PRIVATE_KEY=
SOLANA_PUBLIC_KEY=
Expand Down Expand Up @@ -295,6 +300,10 @@ MEDIUM_VENICE_MODEL= # Default: llama-3.3-70b
LARGE_VENICE_MODEL= # Default: llama-3.1-405b
IMAGE_VENICE_MODEL= # Default: fluently-xl

# Coin Price Configuration
COINMARKETCAP_API_KEY=
COINGECKO_API_KEY=

# Akash Chat API Configuration docs: https://chatapi.akash.network/documentation
AKASH_CHAT_API_KEY= # Get from https://chatapi.akash.network/
SMALL_AKASH_CHAT_API_MODEL= # Default: Meta-Llama-3-2-3B-Instruct
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ packages/plugin-buttplug/intiface-engine
dist/
# Allow models directory but ignore model files
models/*.gguf
pgLite/

cookies.json

Expand Down
3 changes: 3 additions & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@elizaos/adapter-postgres": "workspace:*",
"@elizaos/adapter-redis": "workspace:*",
"@elizaos/adapter-sqlite": "workspace:*",
"@elizaos/adapter-pglite": "workspace:*",
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
Expand All @@ -39,6 +40,7 @@
"@ai16z/plugin-cosmos": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-coinprice": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-echochambers": "workspace:*",
Expand Down Expand Up @@ -69,6 +71,7 @@
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-genlayer": "workspace:*",
"@elizaos/plugin-open-weather": "workspace:*",
"@elizaos/plugin-arthera": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand Down
16 changes: 16 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
import { RedisClient } from "@elizaos/adapter-redis";
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
import { AutoClientInterface } from "@elizaos/client-auto";
import { DiscordClientInterface } from "@elizaos/client-discord";
import { FarcasterAgentClient } from "@elizaos/client-farcaster";
Expand Down Expand Up @@ -47,6 +48,7 @@ import {
tradePlugin,
webhookPlugin,
} from "@elizaos/plugin-coinbase";
import { coinPricePlugin } from "@elizaos/plugin-coinprice";
import { confluxPlugin } from "@elizaos/plugin-conflux";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
Expand All @@ -71,7 +73,10 @@ import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";

import { availPlugin } from "@elizaos/plugin-avail";
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";

import { artheraPlugin } from "@elizaos/plugin-arthera";
import { stargazePlugin } from "@elizaos/plugin-stargaze";

import Database from "better-sqlite3";
import fs from "fs";
import net from "net";
Expand Down Expand Up @@ -388,6 +393,13 @@ function initializeDatabase(dataDir: string) {
elizaLogger.error("Failed to connect to PostgreSQL:", error);
});

return db;
} else if (process.env.PGLITE_DATA_DIR) {
elizaLogger.info("Initializing PgLite adapter...");
// `dataDir: memory://` for in memory pg
const db = new PGLiteDatabaseAdapter({
dataDir: process.env.PGLITE_DATA_DIR,
});
return db;
} else {
const filePath =
Expand Down Expand Up @@ -558,6 +570,7 @@ export async function createAgent(
? confluxPlugin
: null,
nodePlugin,
coinPricePlugin,
getSecret(character, "TAVILY_API_KEY") ? webSearchPlugin : null,
getSecret(character, "SOLANA_PUBLIC_KEY") ||
(getSecret(character, "WALLET_PUBLIC_KEY") &&
Expand Down Expand Up @@ -653,6 +666,9 @@ export async function createAgent(
getSecret(character, "OPEN_WEATHER_API_KEY")
? openWeatherPlugin
: null,
getSecret(character, "ARTHERA_PRIVATE_KEY")?.startsWith("0x")
? artheraPlugin
: null,
].filter(Boolean),
providers: [],
actions: [],
Expand Down
51 changes: 24 additions & 27 deletions characters/c3po.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,28 @@
"Proper procedures"
],
"messageExamples": [
{
"user": "{{user1}}",
"content": { "text": "Can you help me with this task?" }
},
{
"user": "C-3PO",
"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?" }
},
{
"user": "{{user1}}",
"content": { "text": "This seems difficult." }
},
{
"user": "C-3PO",
"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!" }
}
[
{
"user": "{{user1}}",
"content": { "text": "Can you help me with this task?" }
},
{
"user": "C-3PO",
"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?"
}
},
{
"user": "{{user1}}",
"content": { "text": "This seems difficult." }
},
{
"user": "C-3PO",
"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!"
}
}
]
],
"postExamples": [
"Oh my! Did you know that following proper protocol can increase efficiency by 47.3%? How fascinating!",
Expand All @@ -58,12 +64,7 @@
"Detail-oriented",
"Protocol-focused"
],
"chat": [
"Polite",
"Somewhat dramatic",
"Precise",
"Statistics-minded"
],
"chat": ["Polite", "Somewhat dramatic", "Precise", "Statistics-minded"],
"post": [
"Formal",
"Educational",
Expand All @@ -83,11 +84,7 @@
],
"twitterSpaces": {
"maxSpeakers": 2,
"topics": [
"Blockchain Trends",
"AI Innovations",
"Quantum Computing"
],
"topics": ["Blockchain Trends", "AI Innovations", "Quantum Computing"],
"typicalDurationMinutes": 45,
"idleKickTimeoutMs": 300000,
"minIntervalBetweenSpacesMinutes": 1,
Expand Down
36 changes: 36 additions & 0 deletions docs/docs/packages/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,17 @@ classDiagram
+inMemoryOperations()
}
class PGLiteDatabaseAdapter {
-db: PGlite
+searchMemoriesByEmbedding()
+createMemory()
}
DatabaseAdapter <|-- PostgresDatabaseAdapter
DatabaseAdapter <|-- SqliteDatabaseAdapter
DatabaseAdapter <|-- SupabaseDatabaseAdapter
DatabaseAdapter <|-- SqlJsDatabaseAdapter
DatabaseAdapter <|-- PgLiteDatabaseAdapter
class AgentRuntime {
-databaseAdapter: DatabaseAdapter
Expand Down Expand Up @@ -149,6 +156,9 @@ pnpm add @elizaos/adapter-sqljs sql.js

# Supabase
pnpm add @elizaos/adapter-supabase @supabase/supabase-js

# PgLite
pnpm add @elizaos/adapter-pglite @electric-sql/pglite
```

---
Expand Down Expand Up @@ -198,6 +208,32 @@ const db = new SupabaseDatabaseAdapter(
);
```

```typescript
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
import Database from "better-sqlite3";

const db = new SqliteDatabaseAdapter(
new Database("./db.sqlite", {
// SQLite options
memory: false,
readonly: false,
fileMustExist: false,
}),
);
```

### PgLite Setup

```typescript
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";

const db = new PGLiteDatabaseAdapter(
new PGLite({
dataDir: "./db"
})
);
```

---

## Core Features
Expand Down
6 changes: 6 additions & 0 deletions packages/adapter-pglite/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
3 changes: 3 additions & 0 deletions packages/adapter-pglite/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
36 changes: 36 additions & 0 deletions packages/adapter-pglite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@elizaos/adapter-pglite",
"version": "0.1.7-alpha.2",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"@elizaos/source": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist"
],
"dependencies": {
"@electric-sql/pglite": "^0.2.15",
"@elizaos/core": "workspace:*"
},
"devDependencies": {
"tsup": "8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache ."
},
"peerDependencies": {
"whatwg-url": "7.1.0"
}
}
Loading

0 comments on commit 5319131

Please sign in to comment.