Skip to content

Commit a2cfc4d

Browse files
authored
Merge pull request #31 from ai16z/main
merge from main
2 parents ee1ea34 + 17215f0 commit a2cfc4d

Some content is hidden

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

56 files changed

+1390
-470
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v23.1.0

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
</div>
1212

1313
## 🌍 README Translations
14-
[中文说明](./README_CN.md) | [日本語の説明](./README_JA.md) | [한국어 설명](./README_KOR.md) | [Français](./README_FR.md) | [Português](./README_PTBR.md) | [Türkçe](./README_TR.md) | [Русский](./README_RU.md) | [Español](./README_ES.md)
14+
15+
[中文说明](./README_CN.md) | [日本語の説明](./README_JA.md) | [한국어 설명](./README_KOR.md) | [Français](./README_FR.md) | [Português](./README_PTBR.md) | [Türkçe](./README_TR.md) | [Русский](./README_RU.md) | [Español](./README_ES.md) | [Italiano](./README_IT.md)
1516

1617
## ✨ Features
1718

@@ -40,7 +41,7 @@
4041
- [Node.js 22+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
4142
- [pnpm](https://pnpm.io/installation)
4243

43-
> **Note for Windows Users:** WSL is required
44+
> **Note for Windows Users:** [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/install-manual) is required.
4445
4546
### Edit the .env file
4647

README_IT.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Eliza 🤖
2+
3+
<div align="center">
4+
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
5+
</div>
6+
7+
## ✨ Caratteristiche
8+
9+
- 🛠️ Connettori completi per Discord, Twitter e Telegram
10+
- 🔗 Supporto per tutti i modelli (Llama, Grok, OpenAI, Anthropic, ecc.)
11+
- 👥 Supporto multi-agente e per stanze
12+
- 📚 Acquisisci ed interagisci facilmente con i tuoi documenti
13+
- 💾 Memoria recuperabile e archivio documenti
14+
- 🚀 Altamente estensibile - crea le tue azioni e clients personalizzati
15+
- ☁️ Supporto di numerosi modelli (Llama locale, OpenAI, Anthropic, Groq, ecc.)
16+
- 📦 Funziona e basta!
17+
18+
## 🎯 Casi d'Uso
19+
20+
- 🤖 Chatbot
21+
- 🕵️ Agenti Autonomi
22+
- 📈 Gestione Processi Aziendali
23+
- 🎮 NPC per Videogiochi
24+
- 🧠 Trading
25+
26+
## 🚀 Avvio Rapido
27+
28+
### Prerequisiti
29+
30+
- [Python 2.7+](https://www.python.org/downloads/)
31+
- [Node.js 22+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
32+
- [pnpm](https://pnpm.io/installation)
33+
34+
> **Nota per gli utenti Windows:** È richiesto WSL
35+
36+
### Modifica il file .env
37+
38+
Copia .env.example in .env e inserisci i valori appropriati
39+
40+
```
41+
cp .env.example .env
42+
```
43+
44+
### Avvia Eliza Automaticamente
45+
46+
Questo script eseguirà tutti i comandi necessari per configurare il progetto e avviare il bot con il personaggio predefinito.
47+
48+
```bash
49+
sh scripts/start.sh
50+
```
51+
52+
### Modifica il file del personaggio
53+
54+
1. Apri `packages/agent/src/character.ts` per modificare il personaggio predefinito. Decommentare e modificare.
55+
56+
2. Per caricare personaggi personalizzati:
57+
- Usa `pnpm start --characters="percorso/del/tuo/personaggio.json"`
58+
- È possibile caricare più file di personaggi contemporaneamente
59+
60+
### Avvia Eliza Manualmente
61+
62+
```bash
63+
pnpm i
64+
pnpm build
65+
pnpm start
66+
67+
# Il progetto evolve rapidamente; a volte è necessario pulire il progetto se si ritorna sul progetto dopo un po' di tempo
68+
pnpm clean
69+
```
70+
71+
#### Requisiti Aggiuntivi
72+
73+
Potrebbe essere necessario installare Sharp. Se vedi un errore all'avvio, prova a installarlo con il seguente comando:
74+
75+
```
76+
pnpm install --include=optional sharp
77+
```
78+
79+
### Community e contatti
80+
81+
- [GitHub Issues](https://github.com/ai16z/eliza/issues). Ideale per: bug riscontrati utilizzando Eliza e proposte di funzionalità.
82+
- [Discord](https://discord.gg/ai16z). Ideale per: condividere le tue applicazioni e interagire con la community.
83+
84+
## Contributori
85+
86+
<a href="https://github.com/ai16z/eliza/graphs/contributors">
87+
<img src="https://contrib.rocks/image?repo=ai16z/eliza" />
88+
</a>
89+
90+
## Cronologia Stelle
91+
92+
[![Grafico Cronologia Stelle](https://api.star-history.com/svg?repos=ai16z/eliza&type=Date)](https://star-history.com/#ai16z/eliza&Date)

docs/docs/packages/adapters.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,42 @@ async searchMemories(params: {
425425
### PostgreSQL Schema
426426

427427
```sql
428-
-- migrations/20240318103238_remote_schema.sql
429428
CREATE EXTENSION IF NOT EXISTS vector;
430429

430+
CREATE TABLE IF NOT EXISTS accounts (
431+
id UUID PRIMARY KEY,
432+
"createdAt" DEFAULT CURRENT_TIMESTAMP,
433+
"name" TEXT,
434+
"username" TEXT,
435+
"email" TEXT NOT NULL,
436+
"avatarUrl" TEXT,
437+
"details" JSONB DEFAULT '{}'::"jsonb",
438+
"is_agent" BOOLEAN DEFAULT false NOT NULL,
439+
"location" TEXT,
440+
"profile_line" TEXT,
441+
"signed_tos" BOOLEAN DEFAULT false NOT NULL
442+
);
443+
444+
ALTER TABLE ONLY accounts ADD CONSTRAINT users_email_key UNIQUE (email);
445+
446+
CREATE TABLE IF NOT EXISTS participants (
447+
"id" UUID PRIMARY KEY,
448+
"createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
449+
"userId" UUID REFERENCES accounts(id),
450+
"roomId" UUID REFERENCES rooms(id),
451+
"userState" TEXT, -- For MUTED, NULL, or FOLLOWED states
452+
"last_message_read" UUID
453+
);
454+
455+
ALTER TABLE ONLY participants ADD CONSTRAINT participants_id_key UNIQUE (id);
456+
ALTER TABLE ONLY participants ADD CONSTRAINT participants_roomId_fkey FOREIGN KEY ("roomId") REFERENCES rooms(id);
457+
ALTER TABLE ONLY participants ADD CONSTRAINT participants_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id);
458+
459+
CREATE TABLE rooms (
460+
id UUID PRIMARY KEY,
461+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
462+
);
463+
431464
CREATE TABLE memories (
432465
id UUID PRIMARY KEY,
433466
type TEXT NOT NULL,
@@ -440,6 +473,9 @@ CREATE TABLE memories (
440473
"createdAt" TIMESTAMP NOT NULL
441474
);
442475

476+
ALTER TABLE ONLY memories ADD CONSTRAINT memories_roomId_fkey FOREIGN KEY ("roomId") REFERENCES rooms(id);
477+
ALTER TABLE ONLY memories ADD CONSTRAINT memories_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id);
478+
443479
CREATE INDEX memory_embedding_idx ON
444480
memories USING ivfflat (embedding vector_cosine_ops)
445481
WITH (lists = 100);
@@ -452,6 +488,11 @@ CREATE TABLE relationships (
452488
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
453489
);
454490

491+
ALTER TABLE ONLY relationships ADD CONSTRAINT friendships_id_key UNIQUE (id);
492+
ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userA_fkey FOREIGN KEY ("userA") REFERENCES accounts(id);
493+
ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userB_fkey FOREIGN KEY ("userB") REFERENCES accounts(id);
494+
ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id);
495+
455496
CREATE TABLE goals (
456497
id UUID PRIMARY KEY,
457498
"roomId" UUID NOT NULL,

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"docker:run": "bash ./scripts/docker.sh run",
1919
"docker:bash": "bash ./scripts/docker.sh bash",
2020
"docker:start": "bash ./scripts/docker.sh start",
21-
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash"
21+
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash",
22+
"test": "pnpm --dir packages/core test"
2223
},
2324
"devDependencies": {
2425
"concurrently": "^9.1.0",
@@ -27,7 +28,9 @@
2728
"only-allow": "^1.2.1",
2829
"prettier": "^3.3.3",
2930
"typedoc": "^0.26.11",
30-
"typescript": "5.6.3"
31+
"typescript": "5.6.3",
32+
"vite": "^5.4.11",
33+
"vitest": "^2.1.5"
3134
},
3235
"pnpm": {
3336
"overrides": {

packages/agent/src/index.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { DiscordClientInterface } from "@ai16z/client-discord";
55
import { AutoClientInterface } from "@ai16z/client-auto";
66
import { TelegramClientInterface } from "@ai16z/client-telegram";
77
import { TwitterClientInterface } from "@ai16z/client-twitter";
8-
import { defaultCharacter } from "@ai16z/eliza";
9-
import { AgentRuntime } from "@ai16z/eliza";
10-
import { settings } from "@ai16z/eliza";
118
import {
9+
defaultCharacter,
10+
AgentRuntime,
11+
settings,
1212
Character,
1313
IAgentRuntime,
14-
IDatabaseAdapter,
1514
ModelProviderName,
15+
elizaLogger,
1616
} from "@ai16z/eliza";
1717
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
1818
import { solanaPlugin } from "@ai16z/plugin-solana";
@@ -219,7 +219,11 @@ export async function createAgent(
219219
db: any,
220220
token: string
221221
) {
222-
console.log("Creating runtime for character", character.name);
222+
elizaLogger.success(
223+
elizaLogger.successesTitle,
224+
"Creating runtime for character",
225+
character.name
226+
);
223227
return new AgentRuntime({
224228
databaseAdapter: db,
225229
token,
@@ -279,7 +283,7 @@ const startAgents = async () => {
279283
await startAgent(character, directClient);
280284
}
281285
} catch (error) {
282-
console.error("Error starting agents:", error);
286+
elizaLogger.error("Error starting agents:", error);
283287
}
284288

285289
function chat() {
@@ -292,12 +296,12 @@ const startAgents = async () => {
292296
});
293297
}
294298

295-
console.log("Chat started. Type 'exit' to quit.");
299+
elizaLogger.log("Chat started. Type 'exit' to quit.");
296300
chat();
297301
};
298302

299303
startAgents().catch((error) => {
300-
console.error("Unhandled error in startAgents:", error);
304+
elizaLogger.error("Unhandled error in startAgents:", error);
301305
process.exit(1); // Exit the process after logging
302306
});
303307

packages/client-direct/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class DirectClient {
6161
private agents: Map<string, AgentRuntime>;
6262

6363
constructor() {
64-
console.log("DirectClient constructor");
64+
elizaLogger.log("DirectClient constructor");
6565
this.app = express();
6666
this.app.use(cors());
6767
this.agents = new Map();

packages/client-discord/src/actions/download_media.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export default {
8686
callback: HandlerCallback
8787
) => {
8888
const videoService = runtime
89-
.getService(ServiceType.VIDEO)
90-
.getInstance<IVideoService>();
89+
.getService<IVideoService>(ServiceType.VIDEO)
90+
.getInstance();
9191
if (!state) {
9292
state = (await runtime.composeState(message)) as State;
9393
}

packages/client-discord/src/attachments.ts

+25-20
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ export class AttachmentManager {
104104
} else if (
105105
attachment.contentType?.startsWith("video/") ||
106106
this.runtime
107-
.getService(ServiceType.VIDEO)
108-
.getInstance<IVideoService>()
107+
.getService<IVideoService>(ServiceType.VIDEO)
109108
.isVideoUrl(attachment.url)
110109
) {
111110
media = await this.processVideoAttachment(attachment);
@@ -137,10 +136,16 @@ export class AttachmentManager {
137136
throw new Error("Unsupported audio/video format");
138137
}
139138

140-
const transcription = await this.runtime
141-
.getService(ServiceType.TRANSCRIPTION)
142-
.getInstance<ITranscriptionService>()
143-
.transcribeAttachment(audioBuffer);
139+
const transcriptionService =
140+
this.runtime.getService<ITranscriptionService>(
141+
ServiceType.TRANSCRIPTION
142+
);
143+
if (!transcriptionService) {
144+
throw new Error("Transcription service not found");
145+
}
146+
147+
const transcription =
148+
await transcriptionService.transcribeAttachment(audioBuffer);
144149
const { title, description } = await generateSummary(
145150
this.runtime,
146151
transcription
@@ -220,8 +225,7 @@ export class AttachmentManager {
220225
const response = await fetch(attachment.url);
221226
const pdfBuffer = await response.arrayBuffer();
222227
const text = await this.runtime
223-
.getService(ServiceType.PDF)
224-
.getInstance<IPdfService>()
228+
.getService<IPdfService>(ServiceType.PDF)
225229
.convertPdfToText(Buffer.from(pdfBuffer));
226230
const { title, description } = await generateSummary(
227231
this.runtime,
@@ -289,8 +293,9 @@ export class AttachmentManager {
289293
): Promise<Media> {
290294
try {
291295
const { description, title } = await this.runtime
292-
.getService(ServiceType.IMAGE_DESCRIPTION)
293-
.getInstance<IImageDescriptionService>()
296+
.getService<IImageDescriptionService>(
297+
ServiceType.IMAGE_DESCRIPTION
298+
)
294299
.describeImage(attachment.url);
295300
return {
296301
id: attachment.id,
@@ -322,16 +327,16 @@ export class AttachmentManager {
322327
private async processVideoAttachment(
323328
attachment: Attachment
324329
): Promise<Media> {
325-
if (
326-
this.runtime
327-
.getService(ServiceType.VIDEO)
328-
.getInstance<IVideoService>()
329-
.isVideoUrl(attachment.url)
330-
) {
331-
const videoInfo = await this.runtime
332-
.getService(ServiceType.VIDEO)
333-
.getInstance<IVideoService>()
334-
.processVideo(attachment.url);
330+
const videoService = this.runtime.getService<IVideoService>(
331+
ServiceType.VIDEO
332+
);
333+
334+
if (!videoService) {
335+
throw new Error("Video service not found");
336+
}
337+
338+
if (videoService.isVideoUrl(attachment.url)) {
339+
const videoInfo = await videoService.processVideo(attachment.url);
335340
return {
336341
id: attachment.id,
337342
url: attachment.url,

packages/client-discord/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { VoiceManager } from "./voice.ts";
2525

2626
export class DiscordClient extends EventEmitter {
2727
apiToken: string;
28-
private client: Client;
29-
private runtime: IAgentRuntime;
28+
client: Client;
29+
runtime: IAgentRuntime;
3030
character: Character;
3131
private messageManager: MessageManager;
3232
private voiceManager: VoiceManager;
@@ -193,7 +193,7 @@ export class DiscordClient extends EventEmitter {
193193
}
194194

195195
async handleReactionRemove(reaction: MessageReaction, user: User) {
196-
console.log("Reaction removed");
196+
elizaLogger.log("Reaction removed");
197197
// if (user.bot) return;
198198

199199
let emoji = reaction.emoji.name;

0 commit comments

Comments
 (0)