Skip to content

Commit

Permalink
Merge branch 'develop' into samuv/env-tee
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime authored Dec 30, 2024
2 parents 5821769 + ebfc871 commit 73e9c2f
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

[中文说明](./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) | [ไทย](./README_TH.md) | [Deutsch](./README_DE.md) | [Tiếng Việt](./README_VI.md) | [עִברִית](https://github.com/elizaos/Elisa/blob/main/README_HE.md) | [Tagalog](./README_TG.md) | [Polski](./README_PL.md)

## 🚩 Overview

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

## ✨ Features

- 🛠️ Full-featured Discord, Twitter and Telegram connectors
Expand Down
Binary file added docs/static/img/eliza_diagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/adapter-postgres/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ BEGIN
-- Then check for Ollama
ELSIF current_setting('app.use_ollama_embedding', TRUE) = 'true' THEN
RETURN 1024; -- Ollama mxbai-embed-large dimension
-- Then check for GAIANET
ELSIF current_setting('app.use_gaianet_embedding', TRUE) = 'true' THEN
RETURN 768; -- Gaianet nomic-embed dimension
ELSE
RETURN 384; -- BGE/Other embedding dimension
END IF;
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-postgres/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,19 @@ export class PostgresDatabaseAdapter
if (embeddingConfig.provider === EmbeddingProvider.OpenAI) {
await client.query("SET app.use_openai_embedding = 'true'");
await client.query("SET app.use_ollama_embedding = 'false'");
await client.query("SET app.use_gaianet_embedding = 'false'");
} else if (embeddingConfig.provider === EmbeddingProvider.Ollama) {
await client.query("SET app.use_openai_embedding = 'false'");
await client.query("SET app.use_ollama_embedding = 'true'");
await client.query("SET app.use_gaianet_embedding = 'false'");
} else if (embeddingConfig.provider === EmbeddingProvider.GaiaNet){
await client.query("SET app.use_openai_embedding = 'false'");
await client.query("SET app.use_ollama_embedding = 'false'");
await client.query("SET app.use_gaianet_embedding = 'true'");
} else {
await client.query("SET app.use_openai_embedding = 'false'");
await client.query("SET app.use_ollama_embedding = 'false'");
await client.query("SET app.use_gaianet_embedding = 'false'");
}

// Check if schema already exists (check for a core table)
Expand Down
19 changes: 19 additions & 0 deletions packages/adapter-supabase/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ CREATE TABLE memories_1024 (
CONSTRAINT fk_agent FOREIGN KEY ("agentId") REFERENCES accounts("id") ON DELETE CASCADE
);

CREATE TABLE memories_768 (
"id" UUID PRIMARY KEY,
"type" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
"content" JSONB NOT NULL,
"embedding" vector(768), -- Gaianet nomic-embed
"userId" UUID REFERENCES accounts("id"),
"agentId" UUID REFERENCES accounts("id"),
"roomId" UUID REFERENCES rooms("id"),
"unique" BOOLEAN DEFAULT true NOT NULL,
CONSTRAINT fk_room FOREIGN KEY ("roomId") REFERENCES rooms("id") ON DELETE CASCADE,
CONSTRAINT fk_user FOREIGN KEY ("userId") REFERENCES accounts("id") ON DELETE CASCADE,
CONSTRAINT fk_agent FOREIGN KEY ("agentId") REFERENCES accounts("id") ON DELETE CASCADE
);

CREATE TABLE memories_384 (
"id" UUID PRIMARY KEY,
"type" TEXT NOT NULL,
Expand All @@ -82,6 +97,8 @@ CREATE VIEW memories AS
UNION ALL
SELECT * FROM memories_1024
UNION ALL
SELECT * FROM memories_768;
UNION ALL
SELECT * FROM memories_384;


Expand Down Expand Up @@ -136,6 +153,8 @@ CREATE TABLE relationships (
-- Add index for Ollama table
CREATE INDEX idx_memories_1024_embedding ON memories_1024 USING hnsw ("embedding" vector_cosine_ops);
CREATE INDEX idx_memories_1024_type_room ON memories_1024("type", "roomId");
CREATE INDEX idx_memories_768_embedding ON memories_768 USING hnsw ("embedding" vector_cosine_ops);
CREATE INDEX idx_memories_768_type_room ON memories_768("type", "roomId");
CREATE INDEX idx_memories_1536_embedding ON memories_1536 USING hnsw ("embedding" vector_cosine_ops);
CREATE INDEX idx_memories_384_embedding ON memories_384 USING hnsw ("embedding" vector_cosine_ops);
CREATE INDEX idx_memories_1536_type_room ON memories_1536("type", "roomId");
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export function getEmbeddingZeroVector(): number[] {
embeddingDimension = 1536; // OpenAI dimension
} else if (settings.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true") {
embeddingDimension = 1024; // Ollama mxbai-embed-large dimension
} else if (settings.USE_GAIANET_EMBEDDING?.toLowerCase() === "true") {
embeddingDimension = 768; // GaiaNet dimension
}

return Array(embeddingDimension).fill(0);
Expand Down
51 changes: 43 additions & 8 deletions scripts/update-versions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const { execSync } = require('child_process');

const packagesDir = path.join(__dirname, '../packages');
const externalDirs = ['../agent', '../client', '../docs'];
const lernaPath = path.join(__dirname, '../lerna.json');

// Simple Logger
function log(level, message) {
const timestamp = new Date().toISOString().split('T').join(' ').slice(0, 19);
console.log(`${timestamp} [${level.toUpperCase()}]: ${message}`);
}

// Helper to simplify file path for logs
function simplifyPath(filePath) {
const relativePath = path.relative(path.join(__dirname, '..'), filePath);
return `/${relativePath.replace(/\\/g, '/')}`;
}

// Prompt for version input
const rl = readline.createInterface({
input: process.stdin,
Expand All @@ -21,9 +34,21 @@ function askVersion() {
});
}

function runPrettier(filePaths) {
try {
execSync(`npx prettier --write ${filePaths.join(' ')}`, { stdio: 'ignore' });
log('info', `Formatted ${filePaths.length} files with Prettier.`);
} catch (error) {
log('error', `Failed to format files with Prettier: ${error.message}`);
}
}

// Update versions in all package.json files
async function updateVersions() {
const NEW_VERSION = await askVersion();
log('info', `Starting version update process to ${NEW_VERSION}.`);

const updatedFiles = [];

const updateDirectory = (dirPath) => {
const packagePath = path.join(dirPath, 'package.json');
Expand All @@ -35,12 +60,13 @@ async function updateVersions() {
if (oldVersion) {
packageJson.version = NEW_VERSION;
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + '\n');
console.log(`Updated ${dirPath}: ${oldVersion} -> ${packageJson.version}`);
log('info', `Updated ${simplifyPath(packagePath)}: ${oldVersion} -> ${packageJson.version}`);
updatedFiles.push(packagePath);
} else {
console.warn(`Version not found in ${dirPath}/package.json`);
log('warn', `Version not found in ${simplifyPath(packagePath)}`);
}
} else {
console.warn(`No package.json found in ${dirPath}`);
log('warn', `No package.json found in ${simplifyPath(packagePath)}`);
}
};

Expand All @@ -49,7 +75,7 @@ async function updateVersions() {
const packageDirs = fs.readdirSync(packagesDir);
packageDirs.forEach((dir) => updateDirectory(path.join(packagesDir, dir)));
} else {
console.warn(`Packages directory not found at ${packagesDir}`);
log('warn', `Packages directory not found at ${packagesDir}`);
}

// Update external folders
Expand All @@ -58,7 +84,7 @@ async function updateVersions() {
if (fs.existsSync(fullPath)) {
updateDirectory(fullPath);
} else {
console.warn(`External directory not found: ${fullPath}`);
log('warn', `External directory not found: ${simplifyPath(fullPath)}`);
}
});

Expand All @@ -70,13 +96,22 @@ async function updateVersions() {
if (oldVersion) {
lernaJson.version = NEW_VERSION;
fs.writeFileSync(lernaPath, JSON.stringify(lernaJson, null, 2) + '\n');
console.log(`Updated lerna.json: ${oldVersion} -> ${lernaJson.version}`);
log('info', `Updated ${simplifyPath(lernaPath)}: ${oldVersion} -> ${lernaJson.version}`);
updatedFiles.push(lernaPath);
} else {
console.warn(`Version not found in lerna.json`);
log('warn', `Version not found in ${simplifyPath(lernaPath)}`);
}
} else {
console.warn(`lerna.json not found at ${lernaPath}`);
log('warn', `lerna.json not found at ${lernaPath}`);
}

if (updatedFiles.length > 0) {
runPrettier(updatedFiles);
} else {
log('info', 'No files updated, skipping Prettier formatting.');
}

log('info', 'Version update process completed.');
}

updateVersions();

0 comments on commit 73e9c2f

Please sign in to comment.