Skip to content

Commit

Permalink
Merge pull request #31 from ai16z/main
Browse files Browse the repository at this point in the history
merge from main
  • Loading branch information
MarcoMandar authored Nov 20, 2024
2 parents ee1ea34 + 17215f0 commit a2cfc4d
Show file tree
Hide file tree
Showing 56 changed files with 1,390 additions and 470 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v23.1.0
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
</div>

## 🌍 README Translations
[中文说明](./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)

[中文说明](./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)

## ✨ Features

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

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

Expand Down
92 changes: 92 additions & 0 deletions README_IT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Eliza 🤖

<div align="center">
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
</div>

## ✨ Caratteristiche

- 🛠️ Connettori completi per Discord, Twitter e Telegram
- 🔗 Supporto per tutti i modelli (Llama, Grok, OpenAI, Anthropic, ecc.)
- 👥 Supporto multi-agente e per stanze
- 📚 Acquisisci ed interagisci facilmente con i tuoi documenti
- 💾 Memoria recuperabile e archivio documenti
- 🚀 Altamente estensibile - crea le tue azioni e clients personalizzati
- ☁️ Supporto di numerosi modelli (Llama locale, OpenAI, Anthropic, Groq, ecc.)
- 📦 Funziona e basta!

## 🎯 Casi d'Uso

- 🤖 Chatbot
- 🕵️ Agenti Autonomi
- 📈 Gestione Processi Aziendali
- 🎮 NPC per Videogiochi
- 🧠 Trading

## 🚀 Avvio Rapido

### Prerequisiti

- [Python 2.7+](https://www.python.org/downloads/)
- [Node.js 22+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- [pnpm](https://pnpm.io/installation)

> **Nota per gli utenti Windows:** È richiesto WSL
### Modifica il file .env

Copia .env.example in .env e inserisci i valori appropriati

```
cp .env.example .env
```

### Avvia Eliza Automaticamente

Questo script eseguirà tutti i comandi necessari per configurare il progetto e avviare il bot con il personaggio predefinito.

```bash
sh scripts/start.sh
```

### Modifica il file del personaggio

1. Apri `packages/agent/src/character.ts` per modificare il personaggio predefinito. Decommentare e modificare.

2. Per caricare personaggi personalizzati:
- Usa `pnpm start --characters="percorso/del/tuo/personaggio.json"`
- È possibile caricare più file di personaggi contemporaneamente

### Avvia Eliza Manualmente

```bash
pnpm i
pnpm build
pnpm start

# Il progetto evolve rapidamente; a volte è necessario pulire il progetto se si ritorna sul progetto dopo un po' di tempo
pnpm clean
```

#### Requisiti Aggiuntivi

Potrebbe essere necessario installare Sharp. Se vedi un errore all'avvio, prova a installarlo con il seguente comando:

```
pnpm install --include=optional sharp
```

### Community e contatti

- [GitHub Issues](https://github.com/ai16z/eliza/issues). Ideale per: bug riscontrati utilizzando Eliza e proposte di funzionalità.
- [Discord](https://discord.gg/ai16z). Ideale per: condividere le tue applicazioni e interagire con la community.

## Contributori

<a href="https://github.com/ai16z/eliza/graphs/contributors">
<img src="https://contrib.rocks/image?repo=ai16z/eliza" />
</a>

## Cronologia Stelle

[![Grafico Cronologia Stelle](https://api.star-history.com/svg?repos=ai16z/eliza&type=Date)](https://star-history.com/#ai16z/eliza&Date)
43 changes: 42 additions & 1 deletion docs/docs/packages/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,42 @@ async searchMemories(params: {
### PostgreSQL Schema

```sql
-- migrations/20240318103238_remote_schema.sql
CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE IF NOT EXISTS accounts (
id UUID PRIMARY KEY,
"createdAt" DEFAULT CURRENT_TIMESTAMP,
"name" TEXT,
"username" TEXT,
"email" TEXT NOT NULL,
"avatarUrl" TEXT,
"details" JSONB DEFAULT '{}'::"jsonb",
"is_agent" BOOLEAN DEFAULT false NOT NULL,
"location" TEXT,
"profile_line" TEXT,
"signed_tos" BOOLEAN DEFAULT false NOT NULL
);

ALTER TABLE ONLY accounts ADD CONSTRAINT users_email_key UNIQUE (email);

CREATE TABLE IF NOT EXISTS participants (
"id" UUID PRIMARY KEY,
"createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
"userId" UUID REFERENCES accounts(id),
"roomId" UUID REFERENCES rooms(id),
"userState" TEXT, -- For MUTED, NULL, or FOLLOWED states
"last_message_read" UUID
);

ALTER TABLE ONLY participants ADD CONSTRAINT participants_id_key UNIQUE (id);
ALTER TABLE ONLY participants ADD CONSTRAINT participants_roomId_fkey FOREIGN KEY ("roomId") REFERENCES rooms(id);
ALTER TABLE ONLY participants ADD CONSTRAINT participants_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id);

CREATE TABLE rooms (
id UUID PRIMARY KEY,
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE memories (
id UUID PRIMARY KEY,
type TEXT NOT NULL,
Expand All @@ -440,6 +473,9 @@ CREATE TABLE memories (
"createdAt" TIMESTAMP NOT NULL
);

ALTER TABLE ONLY memories ADD CONSTRAINT memories_roomId_fkey FOREIGN KEY ("roomId") REFERENCES rooms(id);
ALTER TABLE ONLY memories ADD CONSTRAINT memories_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id);

CREATE INDEX memory_embedding_idx ON
memories USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100);
Expand All @@ -452,6 +488,11 @@ CREATE TABLE relationships (
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

ALTER TABLE ONLY relationships ADD CONSTRAINT friendships_id_key UNIQUE (id);
ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userA_fkey FOREIGN KEY ("userA") REFERENCES accounts(id);
ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userB_fkey FOREIGN KEY ("userB") REFERENCES accounts(id);
ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id);

CREATE TABLE goals (
id UUID PRIMARY KEY,
"roomId" UUID NOT NULL,
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"docker:run": "bash ./scripts/docker.sh run",
"docker:bash": "bash ./scripts/docker.sh bash",
"docker:start": "bash ./scripts/docker.sh start",
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash"
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash",
"test": "pnpm --dir packages/core test"
},
"devDependencies": {
"concurrently": "^9.1.0",
Expand All @@ -27,7 +28,9 @@
"only-allow": "^1.2.1",
"prettier": "^3.3.3",
"typedoc": "^0.26.11",
"typescript": "5.6.3"
"typescript": "5.6.3",
"vite": "^5.4.11",
"vitest": "^2.1.5"
},
"pnpm": {
"overrides": {
Expand Down
20 changes: 12 additions & 8 deletions packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { DiscordClientInterface } from "@ai16z/client-discord";
import { AutoClientInterface } from "@ai16z/client-auto";
import { TelegramClientInterface } from "@ai16z/client-telegram";
import { TwitterClientInterface } from "@ai16z/client-twitter";
import { defaultCharacter } from "@ai16z/eliza";
import { AgentRuntime } from "@ai16z/eliza";
import { settings } from "@ai16z/eliza";
import {
defaultCharacter,
AgentRuntime,
settings,
Character,
IAgentRuntime,
IDatabaseAdapter,
ModelProviderName,
elizaLogger,
} from "@ai16z/eliza";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
import { solanaPlugin } from "@ai16z/plugin-solana";
Expand Down Expand Up @@ -219,7 +219,11 @@ export async function createAgent(
db: any,
token: string
) {
console.log("Creating runtime for character", character.name);
elizaLogger.success(
elizaLogger.successesTitle,
"Creating runtime for character",
character.name
);
return new AgentRuntime({
databaseAdapter: db,
token,
Expand Down Expand Up @@ -279,7 +283,7 @@ const startAgents = async () => {
await startAgent(character, directClient);
}
} catch (error) {
console.error("Error starting agents:", error);
elizaLogger.error("Error starting agents:", error);
}

function chat() {
Expand All @@ -292,12 +296,12 @@ const startAgents = async () => {
});
}

console.log("Chat started. Type 'exit' to quit.");
elizaLogger.log("Chat started. Type 'exit' to quit.");
chat();
};

startAgents().catch((error) => {
console.error("Unhandled error in startAgents:", error);
elizaLogger.error("Unhandled error in startAgents:", error);
process.exit(1); // Exit the process after logging
});

Expand Down
2 changes: 1 addition & 1 deletion packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class DirectClient {
private agents: Map<string, AgentRuntime>;

constructor() {
console.log("DirectClient constructor");
elizaLogger.log("DirectClient constructor");
this.app = express();
this.app.use(cors());
this.agents = new Map();
Expand Down
4 changes: 2 additions & 2 deletions packages/client-discord/src/actions/download_media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export default {
callback: HandlerCallback
) => {
const videoService = runtime
.getService(ServiceType.VIDEO)
.getInstance<IVideoService>();
.getService<IVideoService>(ServiceType.VIDEO)
.getInstance();
if (!state) {
state = (await runtime.composeState(message)) as State;
}
Expand Down
45 changes: 25 additions & 20 deletions packages/client-discord/src/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ export class AttachmentManager {
} else if (
attachment.contentType?.startsWith("video/") ||
this.runtime
.getService(ServiceType.VIDEO)
.getInstance<IVideoService>()
.getService<IVideoService>(ServiceType.VIDEO)
.isVideoUrl(attachment.url)
) {
media = await this.processVideoAttachment(attachment);
Expand Down Expand Up @@ -137,10 +136,16 @@ export class AttachmentManager {
throw new Error("Unsupported audio/video format");
}

const transcription = await this.runtime
.getService(ServiceType.TRANSCRIPTION)
.getInstance<ITranscriptionService>()
.transcribeAttachment(audioBuffer);
const transcriptionService =
this.runtime.getService<ITranscriptionService>(
ServiceType.TRANSCRIPTION
);
if (!transcriptionService) {
throw new Error("Transcription service not found");
}

const transcription =
await transcriptionService.transcribeAttachment(audioBuffer);
const { title, description } = await generateSummary(
this.runtime,
transcription
Expand Down Expand Up @@ -220,8 +225,7 @@ export class AttachmentManager {
const response = await fetch(attachment.url);
const pdfBuffer = await response.arrayBuffer();
const text = await this.runtime
.getService(ServiceType.PDF)
.getInstance<IPdfService>()
.getService<IPdfService>(ServiceType.PDF)
.convertPdfToText(Buffer.from(pdfBuffer));
const { title, description } = await generateSummary(
this.runtime,
Expand Down Expand Up @@ -289,8 +293,9 @@ export class AttachmentManager {
): Promise<Media> {
try {
const { description, title } = await this.runtime
.getService(ServiceType.IMAGE_DESCRIPTION)
.getInstance<IImageDescriptionService>()
.getService<IImageDescriptionService>(
ServiceType.IMAGE_DESCRIPTION
)
.describeImage(attachment.url);
return {
id: attachment.id,
Expand Down Expand Up @@ -322,16 +327,16 @@ export class AttachmentManager {
private async processVideoAttachment(
attachment: Attachment
): Promise<Media> {
if (
this.runtime
.getService(ServiceType.VIDEO)
.getInstance<IVideoService>()
.isVideoUrl(attachment.url)
) {
const videoInfo = await this.runtime
.getService(ServiceType.VIDEO)
.getInstance<IVideoService>()
.processVideo(attachment.url);
const videoService = this.runtime.getService<IVideoService>(
ServiceType.VIDEO
);

if (!videoService) {
throw new Error("Video service not found");
}

if (videoService.isVideoUrl(attachment.url)) {
const videoInfo = await videoService.processVideo(attachment.url);
return {
id: attachment.id,
url: attachment.url,
Expand Down
6 changes: 3 additions & 3 deletions packages/client-discord/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { VoiceManager } from "./voice.ts";

export class DiscordClient extends EventEmitter {
apiToken: string;
private client: Client;
private runtime: IAgentRuntime;
client: Client;
runtime: IAgentRuntime;
character: Character;
private messageManager: MessageManager;
private voiceManager: VoiceManager;
Expand Down Expand Up @@ -193,7 +193,7 @@ export class DiscordClient extends EventEmitter {
}

async handleReactionRemove(reaction: MessageReaction, user: User) {
console.log("Reaction removed");
elizaLogger.log("Reaction removed");
// if (user.bot) return;

let emoji = reaction.emoji.name;
Expand Down
Loading

0 comments on commit a2cfc4d

Please sign in to comment.