Skip to content

Commit 4c8fcd5

Browse files
authored
Merge branch 'develop' into feature/plugin-hyperliquid
2 parents 478be43 + 49793e2 commit 4c8fcd5

File tree

14 files changed

+2080
-380
lines changed

14 files changed

+2080
-380
lines changed

.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ FLOW_ENDPOINT_URL= # Default: https://mainnet.onflow.org
363363
INTERNET_COMPUTER_PRIVATE_KEY=
364364
INTERNET_COMPUTER_ADDRESS=
365365

366+
367+
#Cloudflare AI Gateway
368+
CLOUDFLARE_GW_ENABLED= # Set to true to enable Cloudflare AI Gateway
369+
CLOUDFLARE_AI_ACCOUNT_ID= # Cloudflare AI Account ID - found in the Cloudflare Dashboard under AI Gateway
370+
CLOUDFLARE_AI_GATEWAY_ID= # Cloudflare AI Gateway ID - found in the Cloudflare Dashboard under AI Gateway
371+
366372
# Aptos
367373
APTOS_PRIVATE_KEY= # Aptos private key
368374
APTOS_NETWORK= # Must be one of mainnet, testnet

agent/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
8181
import { tonPlugin } from "@elizaos/plugin-ton";
8282
import { webSearchPlugin } from "@elizaos/plugin-web-search";
8383

84-
import { coingeckoPlugin } from "@elizaos/plugin-coingecko";
8584
import { giphyPlugin } from "@elizaos/plugin-giphy";
8685
import { letzAIPlugin } from "@elizaos/plugin-letzai";
8786
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";

docs/docs/guides/configuration.md

+53
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,59 @@ HEURIST_API_KEY=
7171
# Livepeer Settings
7272
LIVEPEER_GATEWAY_URL=
7373
```
74+
75+
### Cloudflare AI Gateway Integration
76+
77+
Eliza supports routing API calls through [Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/), which provides several benefits:
78+
79+
- Detailed analytics and monitoring of message traffic and response times
80+
- Cost optimization through request caching and usage tracking across providers
81+
- Improved latency through Cloudflare's global network
82+
- Comprehensive visibility into message content and token usage
83+
- Cost analysis and comparison between different AI providers
84+
- Usage patterns and trends visualization
85+
- Request/response logging for debugging and optimization
86+
87+
To enable Cloudflare AI Gateway:
88+
89+
```bash
90+
# Cloudflare AI Gateway Settings
91+
CLOUDFLARE_GW_ENABLED=true
92+
CLOUDFLARE_AI_ACCOUNT_ID=your-account-id
93+
CLOUDFLARE_AI_GATEWAY_ID=your-gateway-id
94+
```
95+
96+
Supported providers through Cloudflare AI Gateway:
97+
- OpenAI
98+
- Anthropic
99+
- Groq
100+
101+
When enabled, Eliza will automatically route requests through your Cloudflare AI Gateway endpoint. The gateway URL is constructed in the format:
102+
```
103+
https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/${provider}
104+
```
105+
106+
If the gateway configuration is incomplete or disabled, Eliza will fall back to direct API calls.
107+
108+
```bash
109+
# Cloudflare AI Gateway Settings
110+
CLOUDFLARE_GW_ENABLED=true
111+
CLOUDFLARE_AI_ACCOUNT_ID=your-account-id
112+
CLOUDFLARE_AI_GATEWAY_ID=your-gateway-id
113+
```
114+
115+
Supported providers through Cloudflare AI Gateway:
116+
- OpenAI
117+
- Anthropic
118+
- Groq
119+
120+
When enabled, Eliza will automatically route requests through your Cloudflare AI Gateway endpoint. The gateway URL is constructed in the format:
121+
```
122+
https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/${provider}
123+
```
124+
125+
If the gateway configuration is incomplete or disabled, Eliza will fall back to direct API calls.
126+
74127
### Image Generation
75128

76129
Configure image generation in your character file:

packages/adapter-postgres/src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export class PostgresDatabaseAdapter
329329
roomIds: UUID[];
330330
agentId?: UUID;
331331
tableName: string;
332+
limit?: number;
332333
}): Promise<Memory[]> {
333334
return this.withDatabase(async () => {
334335
if (params.roomIds.length === 0) return [];
@@ -344,6 +345,13 @@ export class PostgresDatabaseAdapter
344345
queryParams = [...queryParams, params.agentId];
345346
}
346347

348+
// Add sorting, and conditionally add LIMIT if provided
349+
query += ` ORDER BY "createdAt" DESC`;
350+
if (params.limit) {
351+
query += ` LIMIT $${queryParams.length + 1}`;
352+
queryParams.push(params.limit.toString());
353+
}
354+
347355
const { rows } = await this.pool.query(query, queryParams);
348356
return rows.map((row) => ({
349357
...row,

packages/adapter-supabase/seed.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
INSERT INTO public.accounts (id, name, email, avatarUrl, details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}');
2-
INSERT INTO public.rooms (id) VALUES ('00000000-0000-0000-0000-000000000000');
3-
INSERT INTO public.participants (userId, roomId) VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000');
1+
INSERT INTO public.accounts (id, name, email, "avatarUrl", details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}');
2+
INSERT INTO public.rooms (id, "createdAt") VALUES ('00000000-0000-0000-0000-000000000000', NOW());
3+
INSERT INTO public.participants (id, "createdAt", "userId", "roomId", "userState", last_messsage_read) VALUES ('00000000-0000-0000-0000-000000000000', NOW(), 'Default Agent', '00000000-0000-0000-0000-000000000000', NULL, NULL);

packages/adapter-supabase/src/index.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
2020
.from("rooms")
2121
.select("id")
2222
.eq("id", roomId)
23-
.single();
23+
.maybeSingle();
2424

2525
if (error) {
26-
throw new Error(`Error getting room: ${error.message}`);
26+
elizaLogger.error(`Error getting room: ${error.message}`);
27+
return null;
2728
}
28-
2929
return data ? (data.id as UUID) : null;
3030
}
3131

@@ -56,7 +56,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
5656
.single();
5757

5858
if (error) {
59-
console.error("Error getting participant user state:", error);
59+
elizaLogger.error("Error getting participant user state:", error);
6060
return null;
6161
}
6262

@@ -75,7 +75,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
7575
.eq("userId", userId);
7676

7777
if (error) {
78-
console.error("Error setting participant user state:", error);
78+
elizaLogger.error("Error setting participant user state:", error);
7979
throw new Error("Failed to set participant user state");
8080
}
8181
}
@@ -127,7 +127,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
127127
const { data, error } = await query;
128128

129129
if (error) {
130-
console.error("Error retrieving memories by room IDs:", error);
130+
elizaLogger.error("Error retrieving memories by room IDs:", error);
131131
return [];
132132
}
133133

@@ -155,7 +155,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
155155
.from("accounts")
156156
.upsert([account]);
157157
if (error) {
158-
console.error(error.message);
158+
elizaLogger.error(error.message);
159159
return false;
160160
}
161161
return true;
@@ -175,7 +175,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
175175
.eq("id", params.roomId);
176176

177177
if (response.error) {
178-
console.error("Error!" + response.error);
178+
elizaLogger.error("Error!" + response.error);
179179
return [];
180180
}
181181
const { data } = response;
@@ -194,7 +194,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
194194
)
195195
.flat();
196196
} catch (error) {
197-
console.error("error", error);
197+
elizaLogger.error("error", error);
198198
throw error;
199199
}
200200
}
@@ -267,7 +267,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
267267
});
268268

269269
if (error) {
270-
console.error("Error inserting log:", error);
270+
elizaLogger.error("Error inserting log:", error);
271271
throw new Error(error.message);
272272
}
273273
}
@@ -357,7 +357,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
357357
.single();
358358

359359
if (error) {
360-
console.error("Error retrieving memory by ID:", error);
360+
elizaLogger.error("Error retrieving memory by ID:", error);
361361
return null;
362362
}
363363

@@ -571,7 +571,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
571571
.insert({ userId: userId, roomId: roomId });
572572

573573
if (error) {
574-
console.error(`Error adding participant: ${error.message}`);
574+
elizaLogger.error(`Error adding participant: ${error.message}`);
575575
return false;
576576
}
577577
return true;
@@ -585,7 +585,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
585585
.eq("roomId", roomId);
586586

587587
if (error) {
588-
console.error(`Error removing participant: ${error.message}`);
588+
elizaLogger.error(`Error removing participant: ${error.message}`);
589589
return false;
590590
}
591591
return true;
@@ -695,7 +695,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
695695
.single();
696696

697697
if (error) {
698-
console.error('Error fetching cache:', error);
698+
elizaLogger.error('Error fetching cache:', error);
699699
return undefined;
700700
}
701701

@@ -717,7 +717,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
717717
});
718718

719719
if (error) {
720-
console.error('Error setting cache:', error);
720+
elizaLogger.error('Error setting cache:', error);
721721
return false;
722722
}
723723

packages/client-direct/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ export class DirectClient {
571571
memory,
572572
[responseMessage],
573573
state,
574-
async (newMessages) => {
574+
async (_newMessages) => {
575575
// FIXME: this is supposed override what the LLM said/decided
576576
// but the promise doesn't make this possible
577577
//message = newMessages;

packages/core/src/database.ts

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
9595
agentId: UUID;
9696
roomIds: UUID[];
9797
tableName: string;
98+
limit?: number;
9899
}): Promise<Memory[]>;
99100

100101
abstract getMemoryById(id: UUID): Promise<Memory | null>;

0 commit comments

Comments
 (0)