From 7da8f012bf2b331fe5db4847ba46d97f751563b8 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Jan 2025 14:49:54 +0800 Subject: [PATCH 01/12] adapter-qdrant --- packages/adapter-qdrant/.npmignore | 9 + packages/adapter-qdrant/config.toml | 159 +++++++++ packages/adapter-qdrant/eslint.config.mjs | 3 + packages/adapter-qdrant/package.json | 37 ++ packages/adapter-qdrant/src/index.ts | 407 ++++++++++++++++++++++ packages/adapter-qdrant/tsconfig.json | 10 + packages/adapter-qdrant/tsup.config.ts | 21 ++ 7 files changed, 646 insertions(+) create mode 100644 packages/adapter-qdrant/.npmignore create mode 100644 packages/adapter-qdrant/config.toml create mode 100644 packages/adapter-qdrant/eslint.config.mjs create mode 100644 packages/adapter-qdrant/package.json create mode 100644 packages/adapter-qdrant/src/index.ts create mode 100644 packages/adapter-qdrant/tsconfig.json create mode 100644 packages/adapter-qdrant/tsup.config.ts diff --git a/packages/adapter-qdrant/.npmignore b/packages/adapter-qdrant/.npmignore new file mode 100644 index 0000000000..eb4b3947ff --- /dev/null +++ b/packages/adapter-qdrant/.npmignore @@ -0,0 +1,9 @@ +* + +!dist/** +!package.json +!readme.md +!tsup.config.ts +!schema.sql +!seed.sql +!config.toml \ No newline at end of file diff --git a/packages/adapter-qdrant/config.toml b/packages/adapter-qdrant/config.toml new file mode 100644 index 0000000000..c1f016d4a4 --- /dev/null +++ b/packages/adapter-qdrant/config.toml @@ -0,0 +1,159 @@ +# A string used to distinguish different Supabase projects on the same host. Defaults to the +# working directory name when running `supabase init`. +project_id = "eliza" + +[api] +enabled = true +# Port to use for the API URL. +port = 54321 +# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API +# endpoints. public and storage are always included. +schemas = ["public", "storage", "graphql_public"] +# Extra schemas to add to the search_path of every request. public is always included. +extra_search_path = ["public", "extensions"] +# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size +# for accidental or malicious requests. +max_rows = 1000 + +[db] +# Port to use for the local database URL. +port = 54322 +# Port used by db diff command to initialize the shadow database. +shadow_port = 54320 +# The database major version to use. This has to be the same as your remote database's. Run `SHOW +# server_version;` on the remote database to check. +major_version = 15 + +[db.pooler] +enabled = false +# Port to use for the local connection pooler. +port = 54329 +# Specifies when a server connection can be reused by other clients. +# Configure one of the supported pooler modes: `transaction`, `session`. +pool_mode = "transaction" +# How many server connections to allow per user/database pair. +default_pool_size = 20 +# Maximum number of client connections allowed. +max_client_conn = 100 + +[realtime] +enabled = true +# Bind realtime via either IPv4 or IPv6. (default: IPv6) +# ip_version = "IPv6" +# The maximum length in bytes of HTTP request headers. (default: 4096) +# max_header_length = 4096 + +[studio] +enabled = true +# Port to use for Supabase Studio. +port = 54323 +# External URL of the API server that frontend connects to. +api_url = "http://127.0.0.1" + +# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they +# are monitored, and you can view the emails that would have been sent from the web interface. +[inbucket] +enabled = true +# Port to use for the email testing server web interface. +port = 54324 +# Uncomment to expose additional ports for testing user applications that send emails. +# smtp_port = 54325 +# pop3_port = 54326 + +[storage] +enabled = true +# The maximum file size allowed (e.g. "5MB", "500KB"). +file_size_limit = "50MiB" + +[auth] +enabled = true +# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used +# in emails. +site_url = "http://127.0.0.1:3000" +# A list of *exact* URLs that auth providers are permitted to redirect to post authentication. +additional_redirect_urls = ["https://127.0.0.1:3000"] +# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week). +jwt_expiry = 3600 +# If disabled, the refresh token will never expire. +enable_refresh_token_rotation = true +# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds. +# Requires enable_refresh_token_rotation = true. +refresh_token_reuse_interval = 10 +# Allow/disallow new user signups to your project. +enable_signup = true +# Allow/disallow testing manual linking of accounts +enable_manual_linking = false + +[auth.email] +# Allow/disallow new user signups via email to your project. +enable_signup = true +# If enabled, a user will be required to confirm any email change on both the old, and new email +# addresses. If disabled, only the new email is required to confirm. +double_confirm_changes = true +# If enabled, users need to confirm their email address before signing in. +enable_confirmations = false + +# Uncomment to customize email template +# [auth.email.template.invite] +# subject = "You have been invited" +# content_path = "./supabase/templates/invite.html" + +[auth.sms] +# Allow/disallow new user signups via SMS to your project. +enable_signup = true +# If enabled, users need to confirm their phone number before signing in. +enable_confirmations = false +# Template for sending OTP to users +template = "Your code is {{ .Code }} ." + +# Use pre-defined map of phone number to OTP for testing. +[auth.sms.test_otp] +# 4152127777 = "123456" + +# This hook runs before a token is issued and allows you to add additional claims based on the authentication method used. +[auth.hook.custom_access_token] +# enabled = true +# uri = "pg-functions:////" + + +# Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`. +[auth.sms.twilio] +enabled = false +account_sid = "" +message_service_sid = "" +# DO NOT commit your Twilio auth token to git. Use environment variable substitution instead: +auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)" + +# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, +# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`, +# `twitter`, `slack`, `spotify`, `workos`, `zoom`. +[auth.external.apple] +enabled = false +client_id = "" +# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead: +secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)" +# Overrides the default auth redirectUrl. +redirect_uri = "" +# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure, +# or any other third-party OIDC providers. +url = "" + +[analytics] +enabled = false +port = 54327 +vector_port = 54328 +# Configure one of the supported backends: `postgres`, `bigquery`. +backend = "postgres" + +# Experimental features may be deprecated any time +[experimental] +# Configures Postgres storage engine to use OrioleDB (S3) +orioledb_version = "" +# Configures S3 bucket URL, eg. .s3-.amazonaws.com +s3_host = "env(S3_HOST)" +# Configures S3 bucket region, eg. us-east-1 +s3_region = "env(S3_REGION)" +# Configures AWS_ACCESS_KEY_ID for S3 bucket +s3_access_key = "env(S3_ACCESS_KEY)" +# Configures AWS_SECRET_ACCESS_KEY for S3 bucket +s3_secret_key = "env(S3_SECRET_KEY)" diff --git a/packages/adapter-qdrant/eslint.config.mjs b/packages/adapter-qdrant/eslint.config.mjs new file mode 100644 index 0000000000..92fe5bbebe --- /dev/null +++ b/packages/adapter-qdrant/eslint.config.mjs @@ -0,0 +1,3 @@ +import eslintGlobalConfig from "../../eslint.config.mjs"; + +export default [...eslintGlobalConfig]; diff --git a/packages/adapter-qdrant/package.json b/packages/adapter-qdrant/package.json new file mode 100644 index 0000000000..0930e55738 --- /dev/null +++ b/packages/adapter-qdrant/package.json @@ -0,0 +1,37 @@ +{ + "name": "@elizaos/adapter-qdrant", + "version": "0.1.7", + "type": "module", + "main": "dist/index.js", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + "./package.json": "./package.json", + ".": { + "import": { + "@elizaos/source": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + } + }, + "files": [ + "dist", + "schema.sql", + "seed.sql" + ], + "dependencies": { + "@elizaos/core": "workspace:*", + "@qdrant/js-client-rest": "^1.12.0", + "@types/pg": "8.11.10", + "pg": "8.13.1" + }, + "devDependencies": { + "tsup": "8.3.5" + }, + "scripts": { + "build": "tsup --format esm --dts", + "dev": "tsup --format esm --dts --watch", + "lint": "eslint --fix --cache ." + } +} diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts new file mode 100644 index 0000000000..9f5f3d8882 --- /dev/null +++ b/packages/adapter-qdrant/src/index.ts @@ -0,0 +1,407 @@ +import { v4 } from "uuid"; +import { QdrantClient } from "@qdrant/js-client-rest"; +import { + Account, + Actor, + GoalStatus, + IDatabaseCacheAdapter, + UUID, + elizaLogger, + RAGKnowledgeItem, + DatabaseAdapter, + Participant, + type Memory, + type Goal, + type Relationship, +} from "@elizaos/core"; + + +export class QdrantDatabaseAdapter extends DatabaseAdapter implements IDatabaseCacheAdapter { + db: QdrantClient; + collectionName: string = 'collection'; + + + constructor() { + super(); + elizaLogger.info("new Qdrant client..."); + this.db = new QdrantClient({ + url: 'https://vectordb-alpha.bsquared.network', + port: 443, + }); + elizaLogger.info("new Qdrant client over..."); + } + + private preprocess(content: string): string { + elizaLogger.info("content preprocess..."); + if (!content || typeof content !== "string") { + elizaLogger.warn("Invalid input for preprocessing"); + return ""; + } + const c = content + .replace(/```[\s\S]*?```/g, "") + .replace(/`.*?`/g, "") + .replace(/#{1,6}\s*(.*)/g, "$1") + .replace(/!\[(.*?)\]\(.*?\)/g, "$1") + .replace(/\[(.*?)\]\(.*?\)/g, "$1") + .replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3") + .replace(/<@[!&]?\d+>/g, "") + .replace(/<[^>]*>/g, "") + .replace(/^\s*[-*_]{3,}\s*$/gm, "") + .replace(/\/\*[\s\S]*?\*\//g, "") + .replace(/\/\/.*/g, "") + .replace(/\s+/g, " ") + .replace(/\n{3,}/g, "\n\n") + .replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "") + .trim() + elizaLogger.info("content preprocess content:", c); + return c + } + + async init () { + elizaLogger.info("Initializing Qdrant..."); + const response = await this.db.getCollections(); + elizaLogger.info("Qdrant adapter getCollections..."); + const collectionNames = response.collections.map((collection) => collection.name); + + if (collectionNames.includes(this.collectionName)) {`` + await this.db.deleteCollection(this.collectionName); + } + + await this.db.createCollection(this.collectionName, { + vectors: { + size: 1536, + distance: 'Cosine', + }, + optimizers_config: { + default_segment_number: 2, + }, + replication_factor: 2, + }); + } + + async createKnowledge(knowledge: RAGKnowledgeItem): Promise { + const metadata = knowledge.content.metadata || {} + elizaLogger.info("Qdrant adapter createKnowledge..."); + elizaLogger.info("Knowledge: ", knowledge); + elizaLogger.info("Knowledge content: ", knowledge.content); + await this.db.upsert(this.collectionName, { + wait: true, + points: [ + { + id: knowledge.id.replace(/-chunk-\d+$/, ""), + vector: knowledge.embedding ? Array.from(knowledge.embedding) : [], + payload:{ + agentId: metadata.isShared ? null : knowledge.agentId, + content: { + text: knowledge.content.text, + metadata: metadata + }, + createdAt: knowledge.createdAt || Date.now(), + isMain: metadata.isMain || false, + originalId: metadata.originalId || null, + chunkIndex: metadata.chunkIndex || null, + isShared : metadata.isShared || false + } + } + ], + }) + // -------- Create payload indexes ------------- + // await this.db.createPayloadIndex(this.collectionName, { + // field_name: 'city', + // field_schema: 'keyword', + // wait: true, + // }) + // + // await this.db.createPayloadIndex(this.collectionName, { + // field_name: 'count', + // field_schema: 'integer', + // wait: true, + // }); + // + // await this.db.createPayloadIndex(this.collectionName, { + // field_name: 'coords', + // field_schema: 'geo', + // wait: true, + // }); + // + elizaLogger.info("Qdrant adapter createKnowledge over..."); + } + + async getKnowledge(params: { + query?: string; + id?: UUID; + conversationContext?: string; + limit?: number; + agentId?: UUID; + }): Promise { + elizaLogger.info("Qdrant adapter getKnowledge...", params.id); + const rows = await this.db.retrieve(this.collectionName, { + ids: params.id ? [params.id.toString()] : [], + }); + const results: RAGKnowledgeItem[] = rows.map((row) => { + const contentObj = typeof row.payload?.content === "string" + ? JSON.parse(row.payload.content) + : row.payload?.content; + return { + id: row.id.toString()+"-chunk-0" as UUID, + agentId: (row.payload?.agentId || "") as UUID, + content: { + text: String(contentObj.text || ""), + metadata: contentObj.metadata as { [key: string]: unknown } + }, + embedding: row.vector ? Float32Array.from(row.vector as number[]) : undefined, + createdAt: row.payload?.createdAt as number + }; + }); + // elizaLogger.info("Qdrant adapter getKnowledge results:", results); + return results; + } + + async processFile(file: { path: string; content: string; type: "pdf" | "md" | "txt"; isShared: boolean }): Promise { + return Promise.resolve(undefined); + } + + async removeKnowledge(id: UUID): Promise { + return Promise.resolve(undefined); + } + + async searchKnowledge(params: { + agentId: UUID; + embedding: Float32Array | number[]; + match_threshold?: number; + match_count?: number; + searchText?: string + }): Promise { + elizaLogger.info("Qdrant adapter searchKnowledge start...", Array.from(params.embedding)); + const rows = await this.db.search(this.collectionName, { + vector: Array.from(params.embedding), + limit: 3, + with_vector: true + }); + // elizaLogger.info("Qdrant adapter searchKnowledge rows:", rows); + + const results: RAGKnowledgeItem[] = rows.map((row) => { + const contentObj = typeof row.payload?.content === "string" + ? JSON.parse(row.payload.content) + : row.payload?.content; + //elizaLogger.info("Qdrant adapter searchKnowledge results.content:", contentObj); + return { + id: row.id.toString()+"-chunk-0" as UUID, + agentId: (row.payload?.agentId || "") as UUID, + content: { + text: String(contentObj.text || ""), + metadata: contentObj.metadata as { [key: string]: unknown } + }, + embedding: row.vector ? Float32Array.from(row.vector as number[]) : undefined, + createdAt: row.payload?.createdAt as number, + similarity: row.score || 0 + }; + }); + // elizaLogger.info("Qdrant adapter searchKnowledge results:", results); + return results; + } + + async addParticipant(userId: UUID, roomId: UUID): Promise { + return Promise.resolve(false); + } + + async clearKnowledge(agentId: UUID, shared?: boolean): Promise { + return Promise.resolve(undefined); + } + + async close(): Promise { + return Promise.resolve(undefined); + } + + async countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise { + return Promise.resolve(0); + } + + async createAccount(account: Account): Promise { + return Promise.resolve(false); + } + + async createGoal(goal: Goal): Promise { + return Promise.resolve(undefined); + } + + async createMemory(memory: Memory, tableName: string, unique?: boolean): Promise { + return Promise.resolve(undefined); + } + + async createRelationship(params: { userA: UUID; userB: UUID }): Promise { + return Promise.resolve(false); + } + + async createRoom(roomId?: UUID): Promise { + const newRoomId = roomId || v4(); + return newRoomId as UUID; + } + + async getAccountById(userId: UUID): Promise { + return null; + } + + async getActorDetails(params: { roomId: UUID }): Promise { + return Promise.resolve([]); + } + + async getCachedEmbeddings(params: { + query_table_name: string; + query_threshold: number; + query_input: string; + query_field_name: string; + query_field_sub_name: string; + query_match_count: number + }): Promise<{ embedding: number[]; levenshtein_score: number }[]> { + return Promise.resolve([]); + } + + async getGoals(params: { + agentId: UUID; + roomId: UUID; + userId?: UUID | null; + onlyInProgress?: boolean; + count?: number + }): Promise { + return Promise.resolve([]); + } + + async getMemories(params: { + roomId: UUID; + count?: number; + unique?: boolean; + tableName: string; + agentId: UUID; + start?: number; + end?: number + }): Promise { + return Promise.resolve([]); + } + + async getMemoriesByRoomIds(params: { tableName: string; agentId: UUID; roomIds: UUID[] }): Promise { + return Promise.resolve([]); + } + + async getMemoryById(id: UUID): Promise { + return null; + } + + async getParticipantUserState(roomId: UUID, userId: UUID): Promise<"FOLLOWED" | "MUTED" | null> { + return null; + } + + async getParticipantsForAccount(userId: UUID): Promise { + return Promise.resolve([]); + } + + async getParticipantsForRoom(roomId: UUID): Promise { + return Promise.resolve([]); + } + + async getRelationship(params: { userA: UUID; userB: UUID }): Promise { + return null; + } + + async getRelationships(params: { userId: UUID }): Promise { + return Promise.resolve([]); + } + + async getRoom(roomId: UUID): Promise { + return null; + } + + async getRoomsForParticipant(userId: UUID): Promise { + return Promise.resolve([]); + } + + async getRoomsForParticipants(userIds: UUID[]): Promise { + return Promise.resolve([]); + } + + async log(params: { body: { [p: string]: unknown }; userId: UUID; roomId: UUID; type: string }): Promise { + return Promise.resolve(undefined); + } + + async removeAllGoals(roomId: UUID): Promise { + return Promise.resolve(undefined); + } + + async removeAllMemories(roomId: UUID, tableName: string): Promise { + return Promise.resolve(undefined); + } + + async removeGoal(goalId: UUID): Promise { + return Promise.resolve(undefined); + } + + async removeMemory(memoryId: UUID, tableName: string): Promise { + return Promise.resolve(undefined); + } + + async removeParticipant(userId: UUID, roomId: UUID): Promise { + return Promise.resolve(false); + } + + async removeRoom(roomId: UUID): Promise { + return Promise.resolve(undefined); + } + + async searchMemories(params: { + tableName: string; + agentId: UUID; + roomId: UUID; + embedding: number[]; + match_threshold: number; + match_count: number; + unique: boolean + }): Promise { + return Promise.resolve([]); + } + + async searchMemoriesByEmbedding(embedding: number[], params: { + match_threshold?: number; + count?: number; + roomId?: UUID; + agentId?: UUID; + unique?: boolean; + tableName: string + }): Promise { + return Promise.resolve([]); + } + + async setParticipantUserState(roomId: UUID, userId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise { + return Promise.resolve(undefined); + } + + async updateGoal(goal: Goal): Promise { + return Promise.resolve(undefined); + } + + async updateGoalStatus(params: { goalId: UUID; status: GoalStatus }): Promise { + return Promise.resolve(undefined); + } + async getCache(params: { + key: string; + agentId: UUID; + }): Promise { + return Promise.resolve(undefined); + } + + async setCache(params: { + key: string; + agentId: UUID; + value: string; + }): Promise { + return false; + } + + async deleteCache(params: { + key: string; + agentId: UUID; + }): Promise { + return false + } +} + +export default QdrantDatabaseAdapter; diff --git a/packages/adapter-qdrant/tsconfig.json b/packages/adapter-qdrant/tsconfig.json new file mode 100644 index 0000000000..ea4e73360b --- /dev/null +++ b/packages/adapter-qdrant/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../core/tsconfig.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "strict": true + }, + "include": ["src/**/*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/adapter-qdrant/tsup.config.ts b/packages/adapter-qdrant/tsup.config.ts new file mode 100644 index 0000000000..9acebc5ba9 --- /dev/null +++ b/packages/adapter-qdrant/tsup.config.ts @@ -0,0 +1,21 @@ +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: ["src/index.ts"], + outDir: "dist", + sourcemap: true, + clean: true, + format: ["esm"], // Ensure you're targeting CommonJS + external: [ + "dotenv", // Externalize dotenv to prevent bundling + "fs", // Externalize fs to use Node.js built-in module + "path", // Externalize other built-ins if necessary + "@reflink/reflink", + "@node-llama-cpp", + "https", + "http", + "agentkeepalive", + "uuid", + // Add other modules you want to externalize + ], +}); From f7cd4e0610b68b5d1a795e0dd4bdc4f4589fbe67 Mon Sep 17 00:00:00 2001 From: "144757737+oxf71@users.noreply.github.com" Date: Tue, 14 Jan 2025 16:45:12 +0800 Subject: [PATCH 02/12] update --- agent/package.json | 1 + agent/src/index.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/package.json b/agent/package.json index b2950fd267..387e7b634c 100644 --- a/agent/package.json +++ b/agent/package.json @@ -22,6 +22,7 @@ "@elizaos/adapter-redis": "workspace:*", "@elizaos/adapter-sqlite": "workspace:*", "@elizaos/adapter-pglite": "workspace:*", + "@elizaos/adapter-qdrant": "workspace:*", "@elizaos/client-auto": "workspace:*", "@elizaos/client-direct": "workspace:*", "@elizaos/client-discord": "workspace:*", diff --git a/agent/src/index.ts b/agent/src/index.ts index 77c05037d2..c36059fe47 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -1,5 +1,6 @@ import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite"; import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres"; +import { QdrantDatabaseAdapter } from "@elizaos/adapter-qdrant"; import { RedisClient } from "@elizaos/adapter-redis"; import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite"; import { AutoClientInterface } from "@elizaos/client-auto"; @@ -415,7 +416,11 @@ function initializeDatabase(dataDir: string) { dataDir: process.env.PGLITE_DATA_DIR, }); return db; - } else { + } else if (process.env.QDRANT_URL) { + elizaLogger.info("Initializing Qdrant adapter..."); + const db = new QdrantDatabaseAdapter(); + return db; + }else { const filePath = process.env.SQLITE_FILE ?? path.resolve(dataDir, "db.sqlite"); // ":memory:"; From 34d36ef35b916458f6b2630be7fb8c6f9f8cf97a Mon Sep 17 00:00:00 2001 From: "144757737+oxf71@users.noreply.github.com" Date: Wed, 15 Jan 2025 17:19:25 +0800 Subject: [PATCH 03/12] chore: add cache && env conf --- .env.example | 6 + agent/src/index.ts | 7 +- packages/adapter-qdrant/config.toml | 159 --------------------------- packages/adapter-qdrant/package.json | 11 +- packages/adapter-qdrant/src/index.ts | 91 +++++++-------- 5 files changed, 52 insertions(+), 222 deletions(-) delete mode 100644 packages/adapter-qdrant/config.toml diff --git a/.env.example b/.env.example index f1a857c840..6aaad91eb4 100644 --- a/.env.example +++ b/.env.example @@ -452,3 +452,9 @@ TAVILY_API_KEY= # Verifiable Inference Configuration VERIFIABLE_INFERENCE_ENABLED=false # Set to false to disable verifiable inference VERIFIABLE_INFERENCE_PROVIDER=opacity # Options: opacity + +# Qdrant +QDRANT_URL= +QDRANT_KEY= +QDRANT_PORT=443 +QDRANT_VECTOR_SIZE=1536 \ No newline at end of file diff --git a/agent/src/index.ts b/agent/src/index.ts index c36059fe47..7921f07abe 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -418,7 +418,12 @@ function initializeDatabase(dataDir: string) { return db; } else if (process.env.QDRANT_URL) { elizaLogger.info("Initializing Qdrant adapter..."); - const db = new QdrantDatabaseAdapter(); + const db = new QdrantDatabaseAdapter( + process.env.QDRANT_URL, + process.env.QDRANT_KEY, + Number(process.env.QDRANT_PORT), + Number(process.env.QDRANT_VECTOR_SIZE) + ); return db; }else { const filePath = diff --git a/packages/adapter-qdrant/config.toml b/packages/adapter-qdrant/config.toml deleted file mode 100644 index c1f016d4a4..0000000000 --- a/packages/adapter-qdrant/config.toml +++ /dev/null @@ -1,159 +0,0 @@ -# A string used to distinguish different Supabase projects on the same host. Defaults to the -# working directory name when running `supabase init`. -project_id = "eliza" - -[api] -enabled = true -# Port to use for the API URL. -port = 54321 -# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API -# endpoints. public and storage are always included. -schemas = ["public", "storage", "graphql_public"] -# Extra schemas to add to the search_path of every request. public is always included. -extra_search_path = ["public", "extensions"] -# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size -# for accidental or malicious requests. -max_rows = 1000 - -[db] -# Port to use for the local database URL. -port = 54322 -# Port used by db diff command to initialize the shadow database. -shadow_port = 54320 -# The database major version to use. This has to be the same as your remote database's. Run `SHOW -# server_version;` on the remote database to check. -major_version = 15 - -[db.pooler] -enabled = false -# Port to use for the local connection pooler. -port = 54329 -# Specifies when a server connection can be reused by other clients. -# Configure one of the supported pooler modes: `transaction`, `session`. -pool_mode = "transaction" -# How many server connections to allow per user/database pair. -default_pool_size = 20 -# Maximum number of client connections allowed. -max_client_conn = 100 - -[realtime] -enabled = true -# Bind realtime via either IPv4 or IPv6. (default: IPv6) -# ip_version = "IPv6" -# The maximum length in bytes of HTTP request headers. (default: 4096) -# max_header_length = 4096 - -[studio] -enabled = true -# Port to use for Supabase Studio. -port = 54323 -# External URL of the API server that frontend connects to. -api_url = "http://127.0.0.1" - -# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they -# are monitored, and you can view the emails that would have been sent from the web interface. -[inbucket] -enabled = true -# Port to use for the email testing server web interface. -port = 54324 -# Uncomment to expose additional ports for testing user applications that send emails. -# smtp_port = 54325 -# pop3_port = 54326 - -[storage] -enabled = true -# The maximum file size allowed (e.g. "5MB", "500KB"). -file_size_limit = "50MiB" - -[auth] -enabled = true -# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used -# in emails. -site_url = "http://127.0.0.1:3000" -# A list of *exact* URLs that auth providers are permitted to redirect to post authentication. -additional_redirect_urls = ["https://127.0.0.1:3000"] -# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week). -jwt_expiry = 3600 -# If disabled, the refresh token will never expire. -enable_refresh_token_rotation = true -# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds. -# Requires enable_refresh_token_rotation = true. -refresh_token_reuse_interval = 10 -# Allow/disallow new user signups to your project. -enable_signup = true -# Allow/disallow testing manual linking of accounts -enable_manual_linking = false - -[auth.email] -# Allow/disallow new user signups via email to your project. -enable_signup = true -# If enabled, a user will be required to confirm any email change on both the old, and new email -# addresses. If disabled, only the new email is required to confirm. -double_confirm_changes = true -# If enabled, users need to confirm their email address before signing in. -enable_confirmations = false - -# Uncomment to customize email template -# [auth.email.template.invite] -# subject = "You have been invited" -# content_path = "./supabase/templates/invite.html" - -[auth.sms] -# Allow/disallow new user signups via SMS to your project. -enable_signup = true -# If enabled, users need to confirm their phone number before signing in. -enable_confirmations = false -# Template for sending OTP to users -template = "Your code is {{ .Code }} ." - -# Use pre-defined map of phone number to OTP for testing. -[auth.sms.test_otp] -# 4152127777 = "123456" - -# This hook runs before a token is issued and allows you to add additional claims based on the authentication method used. -[auth.hook.custom_access_token] -# enabled = true -# uri = "pg-functions:////" - - -# Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`. -[auth.sms.twilio] -enabled = false -account_sid = "" -message_service_sid = "" -# DO NOT commit your Twilio auth token to git. Use environment variable substitution instead: -auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)" - -# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, -# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`, -# `twitter`, `slack`, `spotify`, `workos`, `zoom`. -[auth.external.apple] -enabled = false -client_id = "" -# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead: -secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)" -# Overrides the default auth redirectUrl. -redirect_uri = "" -# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure, -# or any other third-party OIDC providers. -url = "" - -[analytics] -enabled = false -port = 54327 -vector_port = 54328 -# Configure one of the supported backends: `postgres`, `bigquery`. -backend = "postgres" - -# Experimental features may be deprecated any time -[experimental] -# Configures Postgres storage engine to use OrioleDB (S3) -orioledb_version = "" -# Configures S3 bucket URL, eg. .s3-.amazonaws.com -s3_host = "env(S3_HOST)" -# Configures S3 bucket region, eg. us-east-1 -s3_region = "env(S3_REGION)" -# Configures AWS_ACCESS_KEY_ID for S3 bucket -s3_access_key = "env(S3_ACCESS_KEY)" -# Configures AWS_SECRET_ACCESS_KEY for S3 bucket -s3_secret_key = "env(S3_SECRET_KEY)" diff --git a/packages/adapter-qdrant/package.json b/packages/adapter-qdrant/package.json index 0930e55738..52e94cb837 100644 --- a/packages/adapter-qdrant/package.json +++ b/packages/adapter-qdrant/package.json @@ -1,6 +1,6 @@ { "name": "@elizaos/adapter-qdrant", - "version": "0.1.7", + "version": "0.1.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", @@ -15,16 +15,9 @@ } } }, - "files": [ - "dist", - "schema.sql", - "seed.sql" - ], "dependencies": { "@elizaos/core": "workspace:*", - "@qdrant/js-client-rest": "^1.12.0", - "@types/pg": "8.11.10", - "pg": "8.13.1" + "@qdrant/js-client-rest": "^1.12.0" }, "devDependencies": { "tsup": "8.3.5" diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index 9f5f3d8882..c3de21f883 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -19,20 +19,20 @@ import { export class QdrantDatabaseAdapter extends DatabaseAdapter implements IDatabaseCacheAdapter { db: QdrantClient; collectionName: string = 'collection'; - - - constructor() { + cacheM: Map = new Map(); + vectorSize: number; + constructor(url: string, apiKey: string, port: number, vectorSize: number) { super(); elizaLogger.info("new Qdrant client..."); - this.db = new QdrantClient({ - url: 'https://vectordb-alpha.bsquared.network', - port: 443, - }); - elizaLogger.info("new Qdrant client over..."); + this.db = new QdrantClient({ + url: url, + apiKey:apiKey, + port: port, + }); + this.vectorSize = vectorSize; } private preprocess(content: string): string { - elizaLogger.info("content preprocess..."); if (!content || typeof content !== "string") { elizaLogger.warn("Invalid input for preprocessing"); return ""; @@ -53,37 +53,26 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple .replace(/\n{3,}/g, "\n\n") .replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "") .trim() - elizaLogger.info("content preprocess content:", c); return c } async init () { - elizaLogger.info("Initializing Qdrant..."); const response = await this.db.getCollections(); - elizaLogger.info("Qdrant adapter getCollections..."); const collectionNames = response.collections.map((collection) => collection.name); - - if (collectionNames.includes(this.collectionName)) {`` + if (collectionNames.includes(this.collectionName)) { await this.db.deleteCollection(this.collectionName); } - + elizaLogger.info("create collection..."); await this.db.createCollection(this.collectionName, { vectors: { - size: 1536, + size: this.vectorSize, distance: 'Cosine', }, - optimizers_config: { - default_segment_number: 2, - }, - replication_factor: 2, }); } async createKnowledge(knowledge: RAGKnowledgeItem): Promise { const metadata = knowledge.content.metadata || {} - elizaLogger.info("Qdrant adapter createKnowledge..."); - elizaLogger.info("Knowledge: ", knowledge); - elizaLogger.info("Knowledge content: ", knowledge.content); await this.db.upsert(this.collectionName, { wait: true, points: [ @@ -105,26 +94,6 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple } ], }) - // -------- Create payload indexes ------------- - // await this.db.createPayloadIndex(this.collectionName, { - // field_name: 'city', - // field_schema: 'keyword', - // wait: true, - // }) - // - // await this.db.createPayloadIndex(this.collectionName, { - // field_name: 'count', - // field_schema: 'integer', - // wait: true, - // }); - // - // await this.db.createPayloadIndex(this.collectionName, { - // field_name: 'coords', - // field_schema: 'geo', - // wait: true, - // }); - // - elizaLogger.info("Qdrant adapter createKnowledge over..."); } async getKnowledge(params: { @@ -143,7 +112,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple ? JSON.parse(row.payload.content) : row.payload?.content; return { - id: row.id.toString()+"-chunk-0" as UUID, + id: row.id.toString() as UUID, agentId: (row.payload?.agentId || "") as UUID, content: { text: String(contentObj.text || ""), @@ -153,7 +122,6 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple createdAt: row.payload?.createdAt as number }; }); - // elizaLogger.info("Qdrant adapter getKnowledge results:", results); return results; } @@ -172,21 +140,27 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple match_count?: number; searchText?: string }): Promise { - elizaLogger.info("Qdrant adapter searchKnowledge start...", Array.from(params.embedding)); + const cacheKey = `${params.agentId}`; + const cachedResult = await this.getCache({ + key: cacheKey, + agentId: params.agentId + }); + + if (cachedResult) { + return JSON.parse(cachedResult); + } const rows = await this.db.search(this.collectionName, { vector: Array.from(params.embedding), - limit: 3, + limit: 30, with_vector: true }); - // elizaLogger.info("Qdrant adapter searchKnowledge rows:", rows); const results: RAGKnowledgeItem[] = rows.map((row) => { const contentObj = typeof row.payload?.content === "string" ? JSON.parse(row.payload.content) : row.payload?.content; - //elizaLogger.info("Qdrant adapter searchKnowledge results.content:", contentObj); return { - id: row.id.toString()+"-chunk-0" as UUID, + id: row.id.toString() as UUID, agentId: (row.payload?.agentId || "") as UUID, content: { text: String(contentObj.text || ""), @@ -197,7 +171,11 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple similarity: row.score || 0 }; }); - // elizaLogger.info("Qdrant adapter searchKnowledge results:", results); + await this.setCache({ + key: cacheKey, + agentId: params.agentId, + value: JSON.stringify(results) + }); return results; } @@ -385,7 +363,9 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple key: string; agentId: UUID; }): Promise { - return Promise.resolve(undefined); + let key = this.buildKey(params.agentId, params.key); + let result = this.cacheM.get(key); + return result; } async setCache(params: { @@ -393,7 +373,8 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple agentId: UUID; value: string; }): Promise { - return false; + this.cacheM.set(this.buildKey(params.agentId, params.key),params.value) + return true; } async deleteCache(params: { @@ -402,6 +383,10 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple }): Promise { return false } + + private buildKey(agentId: UUID, key: string): string { + return `${agentId}:${key}`; + } } export default QdrantDatabaseAdapter; From ee5aee03cd7c0b384317ede54842d64c3bc04c6f Mon Sep 17 00:00:00 2001 From: "144757737+oxf71@users.noreply.github.com" Date: Thu, 16 Jan 2025 10:28:38 +0800 Subject: [PATCH 04/12] chore: remove search limit --- packages/adapter-qdrant/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index c3de21f883..79726db4a3 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -151,7 +151,6 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple } const rows = await this.db.search(this.collectionName, { vector: Array.from(params.embedding), - limit: 30, with_vector: true }); @@ -359,6 +358,11 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple async updateGoalStatus(params: { goalId: UUID; status: GoalStatus }): Promise { return Promise.resolve(undefined); } + + getMemoriesByIds(memoryIds: UUID[], tableName?: string): Promise { + throw new Error("Method not implemented."); + } + async getCache(params: { key: string; agentId: UUID; From 2f6beb815ba664a5b5cd4b5f99b44d2e8c1272ef Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:18:41 +0800 Subject: [PATCH 05/12] chore: delete cache --- packages/adapter-qdrant/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index 79726db4a3..63a009f1a2 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -385,7 +385,8 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple key: string; agentId: UUID; }): Promise { - return false + const key = this.buildKey(params.agentId, params.key); + return this.cacheM.delete(key); } private buildKey(agentId: UUID, key: string): string { From 95accf9caff562b3c770fe739ca483ed202cd64e Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:05:15 +0800 Subject: [PATCH 06/12] chore: add env check --- agent/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agent/src/index.ts b/agent/src/index.ts index 200714f024..b36e652363 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -566,7 +566,11 @@ function initializeDatabase(dataDir: string) { dataDir: process.env.PGLITE_DATA_DIR, }); return db; - } else if (process.env.QDRANT_URL) { + } else if (process.env.QDRANT_URL + && process.env.QDRANT_KEY + && process.env.QDRANT_PORT + && process.env.QDRANT_VECTOR_SIZE + ) { elizaLogger.info("Initializing Qdrant adapter..."); const db = new QdrantDatabaseAdapter( process.env.QDRANT_URL, From 654edf00b1f6c14a69ad047d628db883a2a181ce Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:16:15 +0800 Subject: [PATCH 07/12] chore: create collection --- packages/adapter-qdrant/src/index.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index 63a009f1a2..304e7d66d7 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -60,15 +60,16 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple const response = await this.db.getCollections(); const collectionNames = response.collections.map((collection) => collection.name); if (collectionNames.includes(this.collectionName)) { - await this.db.deleteCollection(this.collectionName); + elizaLogger.info("Collection already exists."); + } else { + elizaLogger.info("create collection..."); + await this.db.createCollection(this.collectionName, { + vectors: { + size: this.vectorSize, + distance: 'Cosine', + }, + }); } - elizaLogger.info("create collection..."); - await this.db.createCollection(this.collectionName, { - vectors: { - size: this.vectorSize, - distance: 'Cosine', - }, - }); } async createKnowledge(knowledge: RAGKnowledgeItem): Promise { From d4ee82cb37d1d0db853207c53e6ef98c0bc22ebe Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:21:49 +0800 Subject: [PATCH 08/12] chore: add env annotation --- .env.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.env.example b/.env.example index fb17d1688e..baf21e6a90 100644 --- a/.env.example +++ b/.env.example @@ -567,9 +567,13 @@ VERIFIABLE_INFERENCE_ENABLED=false # Set to false to disable verifiable infer VERIFIABLE_INFERENCE_PROVIDER=opacity # Options: opacity # Qdrant +# URL of your Qdrant instance (e.g., https://your-instance.qdrant.tech) QDRANT_URL= +# API key for authentication (optional for local instances) QDRANT_KEY= +# Qdrant service port (default: 443 for cloud, typically 6333 for local) QDRANT_PORT=443 +# Vector size matching your embedding model (default: 1536 for OpenAI embeddings) QDRANT_VECTOR_SIZE=1536 # Autonome Configuration From a157d45dfa50d70c8f7e4f591296bc7607bcce1f Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:07:27 +0800 Subject: [PATCH 09/12] refactor: process the qdrant id --- packages/adapter-qdrant/src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index 304e7d66d7..c50c65e196 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -1,4 +1,4 @@ -import { v4 } from "uuid"; +import { v4,v5 } from "uuid"; import { QdrantClient } from "@qdrant/js-client-rest"; import { Account, @@ -19,6 +19,7 @@ import { export class QdrantDatabaseAdapter extends DatabaseAdapter implements IDatabaseCacheAdapter { db: QdrantClient; collectionName: string = 'collection'; + qdrantV5UUIDNamespace: string = "00000000-0000-0000-0000-000000000000"; cacheM: Map = new Map(); vectorSize: number; constructor(url: string, apiKey: string, port: number, vectorSize: number) { @@ -78,7 +79,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple wait: true, points: [ { - id: knowledge.id.replace(/-chunk-\d+$/, ""), + id: this.buildQdrantID(knowledge.id), // the qdrant id must be a standard uuid vector: knowledge.embedding ? Array.from(knowledge.embedding) : [], payload:{ agentId: metadata.isShared ? null : knowledge.agentId, @@ -171,6 +172,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple similarity: row.score || 0 }; }); + elizaLogger.debug("Qdrant adapter searchKnowledge results:", results); await this.setCache({ key: cacheKey, agentId: params.agentId, @@ -393,6 +395,10 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple private buildKey(agentId: UUID, key: string): string { return `${agentId}:${key}`; } + + private buildQdrantID(id: string): string{ + return v5(id,this.qdrantV5UUIDNamespace); + } } export default QdrantDatabaseAdapter; From 667dbc853d24153861297f3c1c39777fb10e9357 Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:04:35 +0800 Subject: [PATCH 10/12] chore: modify cache key && add log --- packages/adapter-qdrant/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index c50c65e196..9b8acd99d2 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -75,6 +75,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple async createKnowledge(knowledge: RAGKnowledgeItem): Promise { const metadata = knowledge.content.metadata || {} + elizaLogger.info("Qdrant adapter createKnowledge id:", knowledge.id); await this.db.upsert(this.collectionName, { wait: true, points: [ @@ -142,7 +143,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple match_count?: number; searchText?: string }): Promise { - const cacheKey = `${params.agentId}`; + const cacheKey = `${params.agentId}:${params.embedding.toString()}`; const cachedResult = await this.getCache({ key: cacheKey, agentId: params.agentId @@ -160,6 +161,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple const contentObj = typeof row.payload?.content === "string" ? JSON.parse(row.payload.content) : row.payload?.content; + elizaLogger.info("Qdrant adapter searchKnowledge id:", row.id.toString() as UUID); return { id: row.id.toString() as UUID, agentId: (row.payload?.agentId || "") as UUID, From 844bc3bf1615e1fb79dc9b4abfc774568bfde67c Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:10:37 +0800 Subject: [PATCH 11/12] chore: format --- agent/package.json | 238 ++++++++++++++++++++++----------------------- 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/agent/package.json b/agent/package.json index a046e13113..1d3fb9a5ad 100644 --- a/agent/package.json +++ b/agent/package.json @@ -1,121 +1,121 @@ { - "name": "@elizaos/agent", - "version": "0.1.9-alpha.1", - "main": "src/index.ts", - "type": "module", - "scripts": { - "start": "node --loader ts-node/esm src/index.ts", - "dev": "node --loader ts-node/esm src/index.ts", - "check-types": "tsc --noEmit", - "test": "jest" - }, - "nodemonConfig": { - "watch": [ - "src", - "../core/dist" - ], - "ext": "ts,json", - "exec": "node --enable-source-maps --loader ts-node/esm src/index.ts" - }, - "dependencies": { - "@elizaos/adapter-supabase": "workspace:*", - "@elizaos/adapter-postgres": "workspace:*", - "@elizaos/adapter-redis": "workspace:*", - "@elizaos/adapter-sqlite": "workspace:*", - "@elizaos/adapter-pglite": "workspace:*", - "@elizaos/adapter-qdrant": "workspace:*", - "@elizaos/client-auto": "workspace:*", - "@elizaos/client-direct": "workspace:*", - "@elizaos/client-discord": "workspace:*", - "@elizaos/client-farcaster": "workspace:*", - "@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:*", - "@elizaos/plugin-abstract": "workspace:*", - "@elizaos/plugin-agentkit": "workspace:*", - "@elizaos/plugin-aptos": "workspace:*", - "@elizaos/plugin-birdeye": "workspace:*", - "@elizaos/plugin-coingecko": "workspace:*", - "@elizaos/plugin-coinmarketcap": "workspace:*", - "@elizaos/plugin-binance": "workspace:*", - "@elizaos/plugin-avail": "workspace:*", - "@elizaos/plugin-bootstrap": "workspace:*", - "@elizaos/plugin-di": "workspace:*", - "@elizaos/plugin-cosmos": "workspace:*", - "@elizaos/plugin-intiface": "workspace:*", - "@elizaos/plugin-coinbase": "workspace:*", - "@elizaos/plugin-conflux": "workspace:*", - "@elizaos/plugin-evm": "workspace:*", - "@elizaos/plugin-echochambers": "workspace:*", - "@elizaos/plugin-flow": "workspace:*", - "@elizaos/plugin-gitbook": "workspace:*", - "@elizaos/plugin-story": "workspace:*", - "@elizaos/plugin-gitcoin-passport": "workspace:*", - "@elizaos/plugin-goat": "workspace:*", - "@elizaos/plugin-lensNetwork": "workspace:*", - "@elizaos/plugin-icp": "workspace:*", - "@elizaos/plugin-image-generation": "workspace:*", - "@elizaos/plugin-movement": "workspace:*", - "@elizaos/plugin-massa": "workspace:*", - "@elizaos/plugin-nft-generation": "workspace:*", - "@elizaos/plugin-node": "workspace:*", - "@elizaos/plugin-solana": "workspace:*", - "@elizaos/plugin-injective": "workspace:*", - "@elizaos/plugin-solana-agent-kit": "workspace:*", - "@elizaos/plugin-squid-router": "workspace:*", - "@elizaos/plugin-autonome": "workspace:*", - "@elizaos/plugin-starknet": "workspace:*", - "@elizaos/plugin-stargaze": "workspace:*", - "@elizaos/plugin-giphy": "workspace:*", - "@elizaos/plugin-ton": "workspace:*", - "@elizaos/plugin-sui": "workspace:*", - "@elizaos/plugin-sgx": "workspace:*", - "@elizaos/plugin-iq6900": "workspace:*", - "@elizaos/plugin-tee": "workspace:*", - "@elizaos/plugin-tee-log": "workspace:*", - "@elizaos/plugin-tee-marlin": "workspace:*", - "@elizaos/plugin-multiversx": "workspace:*", - "@elizaos/plugin-near": "workspace:*", - "@elizaos/plugin-zksync-era": "workspace:*", - "@elizaos/plugin-twitter": "workspace:*", - "@elizaos/plugin-primus": "workspace:*", - "@elizaos/plugin-cronoszkevm": "workspace:*", - "@elizaos/plugin-3d-generation": "workspace:*", - "@elizaos/plugin-fuel": "workspace:*", - "@elizaos/plugin-avalanche": "workspace:*", - "@elizaos/plugin-video-generation": "workspace:*", - "@elizaos/plugin-web-search": "workspace:*", - "@elizaos/plugin-dexscreener": "workspace:*", - "@elizaos/plugin-letzai": "workspace:*", - "@elizaos/plugin-thirdweb": "workspace:*", - "@elizaos/plugin-genlayer": "workspace:*", - "@elizaos/plugin-tee-verifiable-log": "workspace:*", - "@elizaos/plugin-depin": "workspace:*", - "@elizaos/plugin-open-weather": "workspace:*", - "@elizaos/plugin-obsidian": "workspace:*", - "@elizaos/plugin-arthera": "workspace:*", - "@elizaos/plugin-allora": "workspace:*", - "@elizaos/plugin-opacity": "workspace:*", - "@elizaos/plugin-hyperliquid": "workspace:*", - "@elizaos/plugin-akash": "workspace:*", - "@elizaos/plugin-quai": "workspace:*", - "@elizaos/plugin-b2": "workspace:*", - "@elizaos/plugin-nft-collections": "workspace:*", - "@elizaos/plugin-pyth-data": "workspace:*", - "@elizaos/plugin-openai": "workspace:*", - "readline": "1.3.0", - "ws": "8.18.0", - "yargs": "17.7.2" - }, - "devDependencies": { - "@types/jest": "^29.5.14", - "jest": "^29.7.0", - "ts-jest": "^29.2.5", - "ts-node": "10.9.2", - "tsup": "8.3.5" - } + "name": "@elizaos/agent", + "version": "0.1.9-alpha.1", + "main": "src/index.ts", + "type": "module", + "scripts": { + "start": "node --loader ts-node/esm src/index.ts", + "dev": "node --loader ts-node/esm src/index.ts", + "check-types": "tsc --noEmit", + "test": "jest" + }, + "nodemonConfig": { + "watch": [ + "src", + "../core/dist" + ], + "ext": "ts,json", + "exec": "node --enable-source-maps --loader ts-node/esm src/index.ts" + }, + "dependencies": { + "@elizaos/adapter-supabase": "workspace:*", + "@elizaos/adapter-postgres": "workspace:*", + "@elizaos/adapter-redis": "workspace:*", + "@elizaos/adapter-sqlite": "workspace:*", + "@elizaos/adapter-pglite": "workspace:*", + "@elizaos/adapter-qdrant": "workspace:*", + "@elizaos/client-auto": "workspace:*", + "@elizaos/client-direct": "workspace:*", + "@elizaos/client-discord": "workspace:*", + "@elizaos/client-farcaster": "workspace:*", + "@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:*", + "@elizaos/plugin-abstract": "workspace:*", + "@elizaos/plugin-agentkit": "workspace:*", + "@elizaos/plugin-aptos": "workspace:*", + "@elizaos/plugin-birdeye": "workspace:*", + "@elizaos/plugin-coingecko": "workspace:*", + "@elizaos/plugin-coinmarketcap": "workspace:*", + "@elizaos/plugin-binance": "workspace:*", + "@elizaos/plugin-avail": "workspace:*", + "@elizaos/plugin-bootstrap": "workspace:*", + "@elizaos/plugin-di": "workspace:*", + "@elizaos/plugin-cosmos": "workspace:*", + "@elizaos/plugin-intiface": "workspace:*", + "@elizaos/plugin-coinbase": "workspace:*", + "@elizaos/plugin-conflux": "workspace:*", + "@elizaos/plugin-evm": "workspace:*", + "@elizaos/plugin-echochambers": "workspace:*", + "@elizaos/plugin-flow": "workspace:*", + "@elizaos/plugin-gitbook": "workspace:*", + "@elizaos/plugin-story": "workspace:*", + "@elizaos/plugin-gitcoin-passport": "workspace:*", + "@elizaos/plugin-goat": "workspace:*", + "@elizaos/plugin-lensNetwork": "workspace:*", + "@elizaos/plugin-icp": "workspace:*", + "@elizaos/plugin-image-generation": "workspace:*", + "@elizaos/plugin-movement": "workspace:*", + "@elizaos/plugin-massa": "workspace:*", + "@elizaos/plugin-nft-generation": "workspace:*", + "@elizaos/plugin-node": "workspace:*", + "@elizaos/plugin-solana": "workspace:*", + "@elizaos/plugin-injective": "workspace:*", + "@elizaos/plugin-solana-agent-kit": "workspace:*", + "@elizaos/plugin-squid-router": "workspace:*", + "@elizaos/plugin-autonome": "workspace:*", + "@elizaos/plugin-starknet": "workspace:*", + "@elizaos/plugin-stargaze": "workspace:*", + "@elizaos/plugin-giphy": "workspace:*", + "@elizaos/plugin-ton": "workspace:*", + "@elizaos/plugin-sui": "workspace:*", + "@elizaos/plugin-sgx": "workspace:*", + "@elizaos/plugin-iq6900": "workspace:*", + "@elizaos/plugin-tee": "workspace:*", + "@elizaos/plugin-tee-log": "workspace:*", + "@elizaos/plugin-tee-marlin": "workspace:*", + "@elizaos/plugin-multiversx": "workspace:*", + "@elizaos/plugin-near": "workspace:*", + "@elizaos/plugin-zksync-era": "workspace:*", + "@elizaos/plugin-twitter": "workspace:*", + "@elizaos/plugin-primus": "workspace:*", + "@elizaos/plugin-cronoszkevm": "workspace:*", + "@elizaos/plugin-3d-generation": "workspace:*", + "@elizaos/plugin-fuel": "workspace:*", + "@elizaos/plugin-avalanche": "workspace:*", + "@elizaos/plugin-video-generation": "workspace:*", + "@elizaos/plugin-web-search": "workspace:*", + "@elizaos/plugin-dexscreener": "workspace:*", + "@elizaos/plugin-letzai": "workspace:*", + "@elizaos/plugin-thirdweb": "workspace:*", + "@elizaos/plugin-genlayer": "workspace:*", + "@elizaos/plugin-tee-verifiable-log": "workspace:*", + "@elizaos/plugin-depin": "workspace:*", + "@elizaos/plugin-open-weather": "workspace:*", + "@elizaos/plugin-obsidian": "workspace:*", + "@elizaos/plugin-arthera": "workspace:*", + "@elizaos/plugin-allora": "workspace:*", + "@elizaos/plugin-opacity": "workspace:*", + "@elizaos/plugin-hyperliquid": "workspace:*", + "@elizaos/plugin-akash": "workspace:*", + "@elizaos/plugin-quai": "workspace:*", + "@elizaos/plugin-b2": "workspace:*", + "@elizaos/plugin-nft-collections": "workspace:*", + "@elizaos/plugin-pyth-data": "workspace:*", + "@elizaos/plugin-openai": "workspace:*", + "readline": "1.3.0", + "ws": "8.18.0", + "yargs": "17.7.2" + }, + "devDependencies": { + "@types/jest": "^29.5.14", + "jest": "^29.7.0", + "ts-jest": "^29.2.5", + "ts-node": "10.9.2", + "tsup": "8.3.5" + } } From f8bef0ca6302fd93fc232c799eed66591020c906 Mon Sep 17 00:00:00 2001 From: oxf71 <144757737+oxf71@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:48:41 +0800 Subject: [PATCH 12/12] chore: rename var name --- packages/adapter-qdrant/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/adapter-qdrant/src/index.ts b/packages/adapter-qdrant/src/index.ts index 9b8acd99d2..0233a3fb8a 100644 --- a/packages/adapter-qdrant/src/index.ts +++ b/packages/adapter-qdrant/src/index.ts @@ -38,7 +38,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple elizaLogger.warn("Invalid input for preprocessing"); return ""; } - const c = content + const processedContent = content .replace(/```[\s\S]*?```/g, "") .replace(/`.*?`/g, "") .replace(/#{1,6}\s*(.*)/g, "$1") @@ -54,7 +54,7 @@ export class QdrantDatabaseAdapter extends DatabaseAdapter imple .replace(/\n{3,}/g, "\n\n") .replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "") .trim() - return c + return processedContent } async init () {