Skip to content

Commit

Permalink
Merge branch 'develop' into feat-adapter-qdrant
Browse files Browse the repository at this point in the history
  • Loading branch information
oxf71 authored Jan 16, 2025
2 parents 3a7f800 + 30b1c69 commit 2b65c93
Show file tree
Hide file tree
Showing 33 changed files with 2,412 additions and 139 deletions.
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PGLITE_DATA_DIR= #../pgLite/ if selecting a directory --- or memory:// if

# Eliza Port Config
SERVER_PORT=3000
VITE_SERVER_PORT=${SERVER_PORT}

# Supabase Configuration
SUPABASE_URL=
Expand Down Expand Up @@ -608,3 +609,16 @@ AKASH_MANIFEST_VALIDATION_LEVEL=strict
# Quai Network Ecosystem
QUAI_PRIVATE_KEY=
QUAI_RPC_URL=https://rpc.quai.network

# Instagram Configuration
INSTAGRAM_DRY_RUN=false
INSTAGRAM_USERNAME= # Account username
INSTAGRAM_PASSWORD= # Account password
INSTAGRAM_APP_ID= # Instagram App ID is required
INSTAGRAM_APP_SECRET= # Instagram App Secret is required
INSTAGRAM_BUSINESS_ACCOUNT_ID= # Optional Business Account ID for additional features
INSTAGRAM_POST_INTERVAL_MIN=60 # Default: 60 minutes
INSTAGRAM_POST_INTERVAL_MAX=120 # Default: 120 minutes
INSTAGRAM_ENABLE_ACTION_PROCESSING=false # Enable/disable action processing
INSTAGRAM_ACTION_INTERVAL=5 # Interval between actions in minutes
INSTAGRAM_MAX_ACTIONS=1 # Maximum number of actions to process at once
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ pnpm clean

### Interact via Browser

```
Once the agent is running, you should see the message to run "pnpm start:client" at the end.
Open another terminal and move to same directory and then run below command and follow the URL to chat to your agent.

Open another terminal, move to same directory, run the command below, then follow the URL to chat with your agent.

```bash
pnpm start:client
Expand Down
2 changes: 1 addition & 1 deletion README_TR.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- [Node.js 23+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- [pnpm](https://pnpm.io/installation)

> **Windows Kullanıcıları İçin Not:** WSL gereklidir
> **Windows Kullanıcıları İçin Not:** [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/install-manual) gereklidir
### .env Dosyasını Düzenleyin

Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@elizaos/client-lens": "workspace:*",
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-instagram": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
Expand Down
14 changes: 11 additions & 3 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
import { SupabaseDatabaseAdapter } from "@elizaos/adapter-supabase";
import { AutoClientInterface } from "@elizaos/client-auto";
import { DiscordClientInterface } from "@elizaos/client-discord";
import { FarcasterClientInterface } from "@elizaos/client-farcaster";
import { InstagramClientInterface } from "@elizaos/client-instagram";
import { LensAgentClient } from "@elizaos/client-lens";
import { SlackClientInterface } from "@elizaos/client-slack";
import { TelegramClientInterface } from "@elizaos/client-telegram";
import { TwitterClientInterface } from "@elizaos/client-twitter";
import { FarcasterClientInterface } from "@elizaos/client-farcaster";
// import { ReclaimAdapter } from "@elizaos/plugin-reclaim";
import { PrimusAdapter } from "@elizaos/plugin-primus";

Expand All @@ -30,10 +31,10 @@ import {
IDatabaseAdapter,
IDatabaseCacheAdapter,
ModelProviderName,
parseBooleanFromText,
settings,
stringToUuid,
validateCharacterConfig,
parseBooleanFromText,
} from "@elizaos/core";
import { zgPlugin } from "@elizaos/plugin-0g";

Expand Down Expand Up @@ -88,6 +89,7 @@ import { quaiPlugin } from "@elizaos/plugin-quai";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { solanaPlugin } from "@elizaos/plugin-solana";
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
import { squidRouterPlugin } from "@elizaos/plugin-squid-router";
import { stargazePlugin } from "@elizaos/plugin-stargaze";
import { storyPlugin } from "@elizaos/plugin-story";
import { suiPlugin } from "@elizaos/plugin-sui";
Expand All @@ -97,7 +99,6 @@ import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
import { verifiableLogPlugin } from "@elizaos/plugin-tee-verifiable-log";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { tonPlugin } from "@elizaos/plugin-ton";
import { squidRouterPlugin } from "@elizaos/plugin-squid-router";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";
Expand Down Expand Up @@ -622,6 +623,13 @@ export async function initializeClients(
}
}

if (clientTypes.includes(Clients.INSTAGRAM)) {
const instagramClient = await InstagramClientInterface.start(runtime);
if (instagramClient) {
clients.instagram = instagramClient;
}
}

if (clientTypes.includes(Clients.FARCASTER)) {
const farcasterClient = await FarcasterClientInterface.start(runtime);
if (farcasterClient) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type UUID, type Character } from "@elizaos/core";

const BASE_URL = "http://localhost:3000";
const BASE_URL = `http://localhost:${import.meta.env.VITE_SERVER_PORT}`;

const fetcher = async ({
url,
Expand Down
2 changes: 2 additions & 0 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import viteCompression from "vite-plugin-compression";
import path from "path";

// https://vite.dev/config/
export default defineConfig({
Expand All @@ -13,6 +14,7 @@ export default defineConfig({
}),
],
clearScreen: false,
envDir: path.resolve(__dirname, ".."),
build: {
outDir: "dist",
minify: true,
Expand Down
18 changes: 9 additions & 9 deletions docs/README_FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _Utilisée dans [@DegenSpartanAI](https://x.com/degenspartanai) et [@MarcAIndree
- Ajout de multiples personnages avec [characterfile](https://github.com/lalalune/characterfile/)
- Support des fonctionnalités et connecteurs Discord/ Twitter / Telegram, avec salons vocaux sur Discord
- Accès aux données en mémoire et aux documents stockés
- Peut ouvrir et lire des documents PDF, retranscire des fichiers son et vidéo, résumer des conversations, etc.
- Peut ouvrir et lire des documents PDF, retranscrire des fichiers son et vidéo, résumer des conversations, etc.
- Supporte les modèles open source et locaux (configuré par défaut avec Nous Hermes Llama 3.1B)
- Supporte OpenAI pour une utilisation sur le cloud depuis une machine peu performante
- Mode "Ask Claude" pour l'utilisation de Claude sur des modèles complexes
Expand All @@ -22,10 +22,10 @@ _Utilisée dans [@DegenSpartanAI](https://x.com/degenspartanai) et [@MarcAIndree
- [Node.js 22+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- [pnpm](https://pnpm.io/installation)

### Edit the .env file
### Éditer le fichier .env

- Copy .env.example to .env and fill in the appropriate values
- Edit the TWITTER environment variables to add your bot's username and password
- Copiez le fichier .env.example, renommez-le en .env et remplissez les valeurs appropriées.
- Modifiez les variables d'environnement TWITTER pour ajouter le nom d'utilisateur et le mot de passe de votre bot.

### Modifier les fichiers personnage

Expand All @@ -50,7 +50,7 @@ pnpm clean

# Personnaliser Eliza

### Ajouter un des actions personnalisées
### Ajouter une des actions personnalisées

Pour éviter les conflits Git dans le répertoire core, nous vous recommandons d’ajouter les actions personnalisées dans un répertoire `custom_actions` et de les configurer dans le fichier `elizaConfig.yaml` . Vous pouvez consulter l’exemple dans le fichier `elizaConfig.example.yaml`.

Expand Down Expand Up @@ -82,13 +82,13 @@ pnpm install --include=optional sharp
Vous devez ajouter certaines variables à votre fichier .env pour vous connecter aux différentes plates-formes:

```
# Variables d'environement Discord (nécessaires)
# Variables d'environnement Discord (nécessaires)
DISCORD_APPLICATION_ID=
DISCORD_API_TOKEN= # Bot token
OPENAI_API_KEY=sk-* # OpenAI API key, starting with sk-
ELEVENLABS_XI_API_KEY= # API key from elevenlabs
# Parmètres ELEVENLABS
# Paramètres ELEVENLABS
ELEVENLABS_MODEL_ID=eleven_multilingual_v2
ELEVENLABS_VOICE_ID=21m00Tcm4TlvDq8ikWAM
ELEVENLABS_VOICE_STABILITY=0.5
Expand Down Expand Up @@ -144,7 +144,7 @@ Assurez-vous d’avoir le kit complet CUDA installé, y compris cuDNN et cuBLAS.
### Exécution locale

Ajoutez XAI_MODEL et définissez-le à l’une des options ci-dessus [Run with
Llama](#run-with-llama) - Vous pouvez laisser les valeurs X_SERVER_URL et XAI_API_KEY vides, le modèle est sera téléchargé depuis huggingface et sera modifié en local
Llama](#run-with-llama) - Vous pouvez laisser les valeurs X_SERVER_URL et XAI_API_KEY vides, le modèle sera téléchargé depuis huggingface et sera modifié en local

# Clients

Expand Down Expand Up @@ -173,7 +173,7 @@ pnpm test:sqljs # Lance les tests avec SQL.js
Les tests sont écrits en Jest et se trouvent ici : `src/**/*.test.ts`. L’environnement de test est configuré pour :

- Charger les variables d’environnement depuis `.env.test`
- Ajouter d'un délai d'attente de 2 minutes pour les tests de longue durée
- Ajouter un délai d'attente de 2 minutes pour les tests de longue durée
- Supporter les modules ESM
- Lancer les tests de façon séquentielle (--runInBand)

Expand Down
103 changes: 101 additions & 2 deletions packages/adapter-sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type Relationship,
type UUID,
RAGKnowledgeItem,
type ChunkRow,
} from "@elizaos/core";
import { Database } from "better-sqlite3";
import { v4 } from "uuid";
Expand Down Expand Up @@ -966,8 +967,106 @@ export class SqliteDatabaseAdapter
}

async removeKnowledge(id: UUID): Promise<void> {
const sql = `DELETE FROM knowledge WHERE id = ?`;
this.db.prepare(sql).run(id);
if (typeof id !== "string") {
throw new Error("Knowledge ID must be a string");
}

try {
// Execute the transaction and ensure it's called with ()
await this.db.transaction(() => {
if (id.includes("*")) {
const pattern = id.replace("*", "%");
const sql = "DELETE FROM knowledge WHERE id LIKE ?";
elizaLogger.debug(
`[Knowledge Remove] Executing SQL: ${sql} with pattern: ${pattern}`
);
const stmt = this.db.prepare(sql);
const result = stmt.run(pattern);
elizaLogger.debug(
`[Knowledge Remove] Pattern deletion affected ${result.changes} rows`
);
return result.changes; // Return changes for logging
} else {
// Log queries before execution
const selectSql = "SELECT id FROM knowledge WHERE id = ?";
const chunkSql =
"SELECT id FROM knowledge WHERE json_extract(content, '$.metadata.originalId') = ?";
elizaLogger.debug(`[Knowledge Remove] Checking existence with:
Main: ${selectSql} [${id}]
Chunks: ${chunkSql} [${id}]`);

const mainEntry = this.db.prepare(selectSql).get(id) as
| ChunkRow
| undefined;
const chunks = this.db
.prepare(chunkSql)
.all(id) as ChunkRow[];

elizaLogger.debug(`[Knowledge Remove] Found:`, {
mainEntryExists: !!mainEntry?.id,
chunkCount: chunks.length,
chunkIds: chunks.map((c) => c.id),
});

// Execute and log chunk deletion
const chunkDeleteSql =
"DELETE FROM knowledge WHERE json_extract(content, '$.metadata.originalId') = ?";
elizaLogger.debug(
`[Knowledge Remove] Executing chunk deletion: ${chunkDeleteSql} [${id}]`
);
const chunkResult = this.db.prepare(chunkDeleteSql).run(id);
elizaLogger.debug(
`[Knowledge Remove] Chunk deletion affected ${chunkResult.changes} rows`
);

// Execute and log main entry deletion
const mainDeleteSql = "DELETE FROM knowledge WHERE id = ?";
elizaLogger.debug(
`[Knowledge Remove] Executing main deletion: ${mainDeleteSql} [${id}]`
);
const mainResult = this.db.prepare(mainDeleteSql).run(id);
elizaLogger.debug(
`[Knowledge Remove] Main deletion affected ${mainResult.changes} rows`
);

const totalChanges =
chunkResult.changes + mainResult.changes;
elizaLogger.debug(
`[Knowledge Remove] Total rows affected: ${totalChanges}`
);

// Verify deletion
const verifyMain = this.db.prepare(selectSql).get(id);
const verifyChunks = this.db.prepare(chunkSql).all(id);
elizaLogger.debug(
`[Knowledge Remove] Post-deletion check:`,
{
mainStillExists: !!verifyMain,
remainingChunks: verifyChunks.length,
}
);

return totalChanges; // Return changes for logging
}
})(); // Important: Call the transaction function

elizaLogger.debug(
`[Knowledge Remove] Transaction completed for id: ${id}`
);
} catch (error) {
elizaLogger.error("[Knowledge Remove] Error:", {
id,
error:
error instanceof Error
? {
message: error.message,
stack: error.stack,
name: error.name,
}
: error,
});
throw error;
}
}

async clearKnowledge(agentId: UUID, shared?: boolean): Promise<void> {
Expand Down
5 changes: 0 additions & 5 deletions packages/client-github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const client = await GitHubClientInterface.start(runtime);
// Convert repository files to agent memories
await client.createMemoriesFromFiles();

typescript
// Convert repository files to agent memories
await client.createMemoriesFromFiles();
```
Expand All @@ -67,8 +66,6 @@ await client.createPullRequest(
"Implements new functionality with tests"
);


typescript
await client.createPullRequest(
"Feature: Add new functionality",
"feature/new-feature",
Expand All @@ -94,8 +91,6 @@ await client.createCommit(
}
]
);


```

## API Reference
Expand Down
Loading

0 comments on commit 2b65c93

Please sign in to comment.