Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from main #29

Merged
merged 102 commits into from
Nov 18, 2024
Merged
Changes from 11 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
380400c
Tests setup for starters
mladcepes Nov 15, 2024
c761368
Adding readme tests file for test documentation
mladcepes Nov 15, 2024
f98392c
Adding readme tests file for test documentation - Fixing README-TESTS
mladcepes Nov 15, 2024
5a70cf9
Removing date check, should think of a better way for generating date
mladcepes Nov 16, 2024
26028e4
openrouter 70b don't support 128000, changed to 405b in model.ts
denizekiz Nov 16, 2024
d0b0c08
add actions
ponderingdemocritus Nov 16, 2024
9570011
Adding tests for relationships, with mocker Users and relationships
mladcepes Nov 16, 2024
a88ad31
actions
ponderingdemocritus Nov 16, 2024
dd15e20
Adding tests for providers.test.ts, with mocking providers and checki…
mladcepes Nov 16, 2024
5542f76
Adding messages tests
mladcepes Nov 16, 2024
8587414
Merge branch 'main' into feature/tests
mladcepes Nov 16, 2024
a3c0e28
token provider
ponderingdemocritus Nov 16, 2024
004c7ae
Runtime file
mladcepes Nov 16, 2024
9eb5715
removing files to sync with main branch
mladcepes Nov 16, 2024
5014a2c
Mocking env file
mladcepes Nov 16, 2024
f0a3276
Merge pull request #1 from ai16z-demirix/feature/tests
ai16z-demirix Nov 16, 2024
9dfbc9e
Adding not required label to env variables in test documentation
mladcepes Nov 16, 2024
39855a5
remove cache
ponderingdemocritus Nov 17, 2024
e631775
work
ponderingdemocritus Nov 17, 2024
3839f33
starknet
ponderingdemocritus Nov 17, 2024
3cd78ae
instal clients from plugin
ponderingdemocritus Nov 17, 2024
d5f479f
token provider
ponderingdemocritus Nov 17, 2024
24d7f5e
feat: starknet token transfer
enitrat Nov 17, 2024
236ad0c
Merge branch 'main' of https://github.com/ai16z/eliza into starknet-work
ponderingdemocritus Nov 17, 2024
648800d
Merge pull request #373 from enitrat/feat/transfer-token
ponderingdemocritus Nov 17, 2024
ca24ba1
transfer and cleanup
ponderingdemocritus Nov 17, 2024
4c28418
fix: ca for btc was fake
thearyanag Nov 17, 2024
3fd327d
fix transfer
ponderingdemocritus Nov 17, 2024
00eb3ef
update Heurist image gen settings
tsubasakong Nov 17, 2024
8b1015c
docs: add Turkish README translation (TR)
oguzserdar Nov 17, 2024
fc61bc1
docs: add Turkish (TR) README
oguzserdar Nov 17, 2024
4c005ca
Update README_FR.md
xclicx Nov 17, 2024
0d433d1
Create README_FR.md
xclicx Nov 17, 2024
f3d5e12
nix
ponderingdemocritus Nov 17, 2024
5a464b1
[docs] add translation README_RU.md
whonion Nov 17, 2024
1c2c315
add Groq to getTokenForProvider
bmgalego Nov 17, 2024
4f3fd20
client
ponderingdemocritus Nov 17, 2024
860afe2
attempt browser
ponderingdemocritus Nov 17, 2024
9fff714
contextual tweet threads and making agents less spammy
ropresearch Nov 17, 2024
0d135d4
work
ponderingdemocritus Nov 17, 2024
232c164
fixs client and default character
ponderingdemocritus Nov 18, 2024
acdadf5
Merge pull request #367 from ai16z-demirix/main
ponderingdemocritus Nov 18, 2024
0403540
Merge pull request #375 from tsubasakong/main
ponderingdemocritus Nov 18, 2024
4d5a25f
Merge pull request #371 from ai16z/client-plugin
ponderingdemocritus Nov 18, 2024
bca5b42
Merge pull request #356 from denizekiz/bugfix/openrouter
ponderingdemocritus Nov 18, 2024
aa536f7
improve readme
ponderingdemocritus Nov 18, 2024
7cd0d52
Merge branch 'ai16z:main' into main
whonion Nov 18, 2024
e0444cb
Merge branch 'main' into add-client
twilwa Nov 18, 2024
a2e0954
Merge pull request #382 from ai16z/add-client
twilwa Nov 18, 2024
7a2e394
Fix tweet truncation issue by truncating at complete sentences
SkrillCTO Nov 18, 2024
b0925cb
plugin fixes
ponderingdemocritus Nov 18, 2024
67b8bd0
revert
ponderingdemocritus Nov 18, 2024
ca60d37
pnpm
ponderingdemocritus Nov 18, 2024
d42eea7
merge
ponderingdemocritus Nov 18, 2024
782db49
nix works
ponderingdemocritus Nov 18, 2024
53f5bd3
Merge pull request #355 from ai16z/starknet-work
ponderingdemocritus Nov 18, 2024
42a850b
client null
ponderingdemocritus Nov 18, 2024
7b55988
Revert
ponderingdemocritus Nov 18, 2024
1ba0951
Merge branch 'main' of https://github.com/ai16z/eliza
ponderingdemocritus Nov 18, 2024
5869ac2
Merge pull request #390 from ai16z/fix-client-null
ponderingdemocritus Nov 18, 2024
64d612f
Merge branch 'main' of https://github.com/ai16z/eliza
ponderingdemocritus Nov 18, 2024
fce4078
Merge branch 'main' into ropresearch/contextual-threads
ropresearch Nov 18, 2024
1dde740
Merge pull request #374 from thearyanag/fix/ca
lalalune Nov 18, 2024
a86d6c2
Merge branch 'main' into fix-tweet-truncation
boyaloxer Nov 18, 2024
2b21f8a
logging
ponderingdemocritus Nov 18, 2024
3d7bd77
revert character
ponderingdemocritus Nov 18, 2024
b3cd819
Register memory managers if passed to runtime
martincik Nov 18, 2024
7a36648
Merge pull request #393 from ai16z/logging-improvements
ponderingdemocritus Nov 18, 2024
3ec7e74
unruggable
ponderingdemocritus Nov 18, 2024
d8f4d07
Create README_ES.md
metadiver Nov 18, 2024
f1f65ad
Merge pull request #388 from boyaloxer/fix-tweet-truncation
lalalune Nov 18, 2024
fe90cb9
Merge pull request #400 from metadiver/main
lalalune Nov 18, 2024
c0feed5
Merge pull request #396 from martincik/fix/register-memory-managers-o…
lalalune Nov 18, 2024
3919a1e
correct relative paths DTS Build error #401
Nov 18, 2024
8c8886a
improve logging
ponderingdemocritus Nov 18, 2024
442e14e
Merge branch 'main' of https://github.com/ai16z/eliza into unruggable
ponderingdemocritus Nov 18, 2024
fccaad0
Merge pull request #402 from ai16z/fix/tsup-build
leomercier Nov 18, 2024
1ff8708
formatting
ponderingdemocritus Nov 18, 2024
6e8b457
contain
ponderingdemocritus Nov 18, 2024
dcb68e3
Merge pull request #380 from whonion/main
lalalune Nov 18, 2024
58d4485
Merge pull request #377 from xclicx/main
lalalune Nov 18, 2024
f107e38
Merge pull request #376 from oguzserdar/oguzserdar-patch-1
lalalune Nov 18, 2024
7978d5b
pnpm
ponderingdemocritus Nov 18, 2024
aa5416f
imports
ponderingdemocritus Nov 18, 2024
578a42a
lock
ponderingdemocritus Nov 18, 2024
290d7fb
Merge pull request #383 from ai16z/ropresearch/contextual-threads
ponderingdemocritus Nov 18, 2024
3be59dd
Merge branch 'main' of https://github.com/ai16z/eliza
ponderingdemocritus Nov 18, 2024
1a8f44c
lint
ponderingdemocritus Nov 18, 2024
7930f77
Merge pull request #404 from ai16z/lint
ponderingdemocritus Nov 18, 2024
d83814d
console
ponderingdemocritus Nov 18, 2024
e8353b1
Merge pull request #381 from bmgalego/agent-groq
lalalune Nov 18, 2024
1e5dc87
blobert
ponderingdemocritus Nov 18, 2024
2eec9de
unruggable
ponderingdemocritus Nov 18, 2024
80a1b0c
Merge pull request #405 from ai16z/twitter-client
lalalune Nov 18, 2024
9770b42
pnpm
ponderingdemocritus Nov 18, 2024
3caef3e
Merge pull request #398 from ai16z/unruggable
ponderingdemocritus Nov 18, 2024
72030ce
update readme
lalalune Nov 18, 2024
b4e0131
Merge branch 'main' of https://github.com/ai16z/eliza into HEAD
lalalune Nov 18, 2024
fcbc8e0
fixes bugs
ponderingdemocritus Nov 18, 2024
2c9de0f
blobert
ponderingdemocritus Nov 18, 2024
afb04b5
fixe
ponderingdemocritus Nov 18, 2024
c96e838
Merge pull request #407 from ai16z/fixes
ponderingdemocritus Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions README_ES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# Eliza

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

## Funcionalidades

- 🛠 Conectores completos para Discord, Twitter y Telegram
- 👥 Soporte para múltiples agentes y salas
- 📚 Ingestión e interacción sencilla con documentos
- 💾 Memoria recuperable y almacenamiento de documentos
- 🚀 Altamente extensible - cree sus propias acciones y clientes para expandir capacidades
- ☁️ Soporta múltiples modelos, incluyendo Llama local, OpenAI, Anthropic, Groq y más
- 📦 Funciona perfectamente

## Usos

- 🤖 Chatbots
- 🕵️ Agentes autónomos
- 📈 Gestión de procesos empresariales
- 🎮 NPCs en videojuegos

# Primeros Pasos

**Requisitos (OBLIGATORIOS):**

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

### Edite el archivo .env

- Copie .env.example a .env y complete los valores apropiados
- Edite las variables de ambiente de TWITTER para agregar nombre de usuario y contraseña del bot

### Edite el archivo de personaje

- Revise el archivo `src/core/defaultCharacter.ts` - puede modificarlo
- También puede cargar personajes con el comando `pnpm start --characters="path/to/your/character.json"` y ejecutar múltiples bots simultáneamente.

Después de configurar el archivo .env y el archivo de personaje, puede iniciar el bot con:

```
pnpm i
pnpm start
```

# Personalizando a Eliza

### Agregando acciones personalizadas

Para evitar conflictos en el directorio central, se recomienda agregar acciones personalizadas a un directorio `custom_actions` y luego agregarlas al archivo `elizaConfig.yaml`. Consulte el archivo `elizaConfig.example.yaml` para un ejemplo.

## Ejecución con Diferentes Modelos

### Ejecutar con Llama

Puede ejecutar modelos Llama 70B o 405B configurando la variable de ambiente `XAI_MODEL` en `meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo` o `meta-llama/Meta-Llama-3.1-405B-Instruct`

### Ejecutar con Grok

Puede ejecutar modelos Grok configurando la variable de ambiente `XAI_MODEL` en `grok-beta`

### Ejecutar con OpenAI

Puede ejecutar modelos OpenAI configurando la variable de ambiente `XAI_MODEL` en `gpt-4o-mini` o `gpt-4o`

## Requisitos Adicionales

Puede ser necesario instalar Sharp. Si encuentra un error al iniciar, intente instalarlo con:

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

# Configuración del Entorno

Deberá agregar variables de ambiente a su archivo .env para conectarse a varias plataformas:

```
# Variables de ambiente obligatorias
DISCORD_APPLICATION_ID=
DISCORD_API_TOKEN= # Token del bot
OPENAI_API_KEY=sk-* # Clave API de OpenAI, comenzando con sk-
ELEVENLABS_XI_API_KEY= # Clave API de ElevenLabs
GOOGLE_GENERATIVE_AI_API_KEY= # Clave API de Gemini

# CONFIGURACIONES DE ELEVENLABS
ELEVENLABS_MODEL_ID=eleven_multilingual_v2
ELEVENLABS_VOICE_ID=21m00Tcm4TlvDq8ikWAM
ELEVENLABS_VOICE_STABILITY=0.5
ELEVENLABS_VOICE_SIMILARITY_BOOST=0.9
ELEVENLABS_VOICE_STYLE=0.66
ELEVENLABS_VOICE_USE_SPEAKER_BOOST=false
ELEVENLABS_OPTIMIZE_STREAMING_LATENCY=4
ELEVENLABS_OUTPUT_FORMAT=pcm_16000

TWITTER_DRY_RUN=false
TWITTER_USERNAME= # Nombre de usuario de la cuenta
TWITTER_PASSWORD= # Contraseña de la cuenta
TWITTER_EMAIL= # Correo electrónico de la cuenta
TWITTER_COOKIES= # Cookies de la cuenta

X_SERVER_URL=
XAI_API_KEY=
XAI_MODEL=

# Para consultar a Claude
ANTHROPIC_API_KEY=

WALLET_PRIVATE_KEY=EXAMPLE_WALLET_PRIVATE_KEY
WALLET_PUBLIC_KEY=EXAMPLE_WALLET_PUBLIC_KEY

BIRDEYE_API_KEY=

SOL_ADDRESS=So11111111111111111111111111111111111111112
SLIPPAGE=1
RPC_URL=https://api.mainnet-beta.solana.com
HELIUS_API_KEY=

## Telegram
TELEGRAM_BOT_TOKEN=

TOGETHER_API_KEY=
```

# Configuración de Inferencia Local

### Configuración CUDA

Si tiene una GPU NVIDIA, puede instalar CUDA para acelerar significativamente la inferencia local.

```
pnpm install
npx --no node-llama-cpp source download --gpu cuda
```

Asegúrese de tener instalado el CUDA Toolkit, incluyendo cuDNN y cuBLAS.

### Ejecución local

Agregue XAI_MODEL y configúrelo con una de las opciones de [Ejecutar con Llama](#ejecutar-con-llama) - puede dejar X_SERVER_URL y XAI_API_KEY en blanco, descargará el modelo de HuggingFace y realizará consultas localmente

# Clientes

## Bot de Discord

Para ayuda con la configuración de su Bot de Discord, consulte: https://discordjs.guide/preparations/setting-up-a-bot-application.html

# Desarrollo

## Pruebas

Para ejecutar la suite de pruebas:

```bash
pnpm test # Ejecutar pruebas una vez
pnpm test:watch # Ejecutar pruebas en modo observación
```

Para pruebas específicas de base de datos:

```bash
pnpm test:sqlite # Ejecutar pruebas con SQLite
pnpm test:sqljs # Ejecutar pruebas con SQL.js
```

Las pruebas están escritas con Jest y se pueden encontrar en archivos `src/**/*.test.ts`. El entorno de pruebas está configurado para:

- Cargar variables de ambiente desde `.env.test`
- Usar un límite de 2 minutos para pruebas de larga duración
- Soportar módulos ESM
- Ejecutar pruebas en secuencia (--runInBand)

Para crear nuevas pruebas, agregue un archivo `.test.ts` junto al código que está probando.
64 changes: 37 additions & 27 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Tweet } from "agent-twitter-client";
import fs from "fs";
import { composeContext } from "@ai16z/eliza";
import { generateText } from "@ai16z/eliza";
import { embeddingZeroVector } from "@ai16z/eliza";
import { IAgentRuntime, ModelClass } from "@ai16z/eliza";
import { stringToUuid } from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateText } from "@ai16z/eliza/src/generation.ts";
import { embeddingZeroVector } from "@ai16z/eliza/src/memory.ts";
import { IAgentRuntime, ModelClass } from "@ai16z/eliza/src/types.ts";
import { stringToUuid } from "@ai16z/eliza/src/uuid.ts";
import { ClientBase } from "./base.ts";

const twitterPostTemplate = `{{timeline}}
@@ -24,9 +24,35 @@ About {{agentName}} (@{{twitterUserName}}):
{{characterPostExamples}}

# Task: Generate a post in the voice and style of {{agentName}}, aka @{{twitterUserName}}
Write a single sentence post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Try to write something totally different than previous posts. Do not add commentary or ackwowledge this request, just write the post.
Write a single sentence post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Try to write something totally different than previous posts. Do not add commentary or acknowledge this request, just write the post.
Your response should not contain any questions. Brief, concise statements only. No emojis. Use \\n\\n (double spaces) between statements.`;

const MAX_TWEET_LENGTH = 280;

/**
* Truncate text to fit within the Twitter character limit, ensuring it ends at a complete sentence.
*/
function truncateToCompleteSentence(text: string): string {
if (text.length <= MAX_TWEET_LENGTH) {
return text;
}

// Attempt to truncate at the last period within the limit
const truncatedAtPeriod = text.slice(0, text.lastIndexOf(".", MAX_TWEET_LENGTH) + 1);
if (truncatedAtPeriod.trim().length > 0) {
return truncatedAtPeriod.trim();
}

// If no period is found, truncate to the nearest whitespace
const truncatedAtSpace = text.slice(0, text.lastIndexOf(" ", MAX_TWEET_LENGTH));
if (truncatedAtSpace.trim().length > 0) {
return truncatedAtSpace.trim() + "...";
}

// Fallback: Hard truncate and add ellipsis
return text.slice(0, MAX_TWEET_LENGTH - 3).trim() + "...";
}

export class TwitterPostClient extends ClientBase {
onReady(postImmediately: boolean = true) {
const generateNewTweetLoop = () => {
@@ -54,7 +80,6 @@ export class TwitterPostClient extends ClientBase {
}

constructor(runtime: IAgentRuntime) {
// Initialize the client and pass an optional callback to be called when the client is ready
super({
runtime,
});
@@ -73,7 +98,6 @@ export class TwitterPostClient extends ClientBase {
let homeTimeline = [];

if (!fs.existsSync("tweetcache")) fs.mkdirSync("tweetcache");
// read the file if it exists
if (fs.existsSync("tweetcache/home_timeline.json")) {
homeTimeline = JSON.parse(
fs.readFileSync("tweetcache/home_timeline.json", "utf-8")
@@ -107,7 +131,7 @@ export class TwitterPostClient extends ClientBase {
timeline: formattedHomeTimeline,
}
);
// Generate new tweet

const context = composeContext({
state,
template:
@@ -121,29 +145,16 @@ export class TwitterPostClient extends ClientBase {
modelClass: ModelClass.SMALL,
});

const slice = newTweetContent.replaceAll(/\\n/g, "\n").trim();
// Replace \n with proper line breaks and trim excess spaces
const formattedTweet = newTweetContent.replaceAll(/\\n/g, "\n").trim();

const contentLength = 240;
// Use the helper function to truncate to complete sentence
const content = truncateToCompleteSentence(formattedTweet);

let content = slice.slice(0, contentLength);
// if its bigger than 280, delete the last line
if (content.length > 280) {
content = content.slice(0, content.lastIndexOf("\n"));
}
if (content.length > contentLength) {
// slice at the last period
content = content.slice(0, content.lastIndexOf("."));
}

// if it's still too long, get the period before the last period
if (content.length > contentLength) {
content = content.slice(0, content.lastIndexOf("."));
}
try {
const result = await this.requestQueue.add(
async () => await this.twitterClient.sendTweet(content)
);
// read the body of the response
const body = await result.json();
const tweetResult = body.data.create_tweet.tweet_results.result;

@@ -169,7 +180,6 @@ export class TwitterPostClient extends ClientBase {
tweet.conversationId + "-" + this.runtime.agentId;
const roomId = stringToUuid(conversationId);

// make sure the agent is in the room
await this.runtime.ensureRoomExists(roomId);
await this.runtime.ensureParticipantInRoom(
this.runtime.agentId,
4 changes: 4 additions & 0 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -250,6 +250,10 @@ export class AgentRuntime implements IAgentRuntime {
tableName: "fragments",
});

(opts.managers ?? []).forEach((manager: IMemoryManager) => {
this.registerMemoryManager(manager);
});

(opts.services ?? []).forEach((service: Service) => {
this.registerService(service);
});
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/providers/wallet.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const PROVIDER_CONFIG = {
DEFAULT_RPC: "https://api.mainnet-beta.solana.com",
TOKEN_ADDRESSES: {
SOL: "So11111111111111111111111111111111111111112",
BTC: "qfnqNqs3nCAHjnyCgLRDbBtq4p2MtHZxw8YjSyYhPoL",
BTC: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh",
ETH: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs",
},
};