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

feat: add adapter-qdrant #2322

Merged
merged 23 commits into from
Jan 23, 2025
Merged

Conversation

oxf71
Copy link
Contributor

@oxf71 oxf71 commented Jan 15, 2025

Relates to

Add qdrant adapter into Eliza system.

Risks

Low

Main implementation risk is that the Adapter doesn't work correctly.

Background

What does this PR do?

Add a new adapter for qdrant.

What kind of change is this?

Features (non-breaking change which adds functionality).

Documentation changes needed?

Testing

Where should a reviewer start?

Detailed testing steps

  • Configure the env value below
QDRANT_URL=
QDRANT_KEY=
QDRANT_PORT=443
QDRANT_VECTOR_SIZE=1536
  • field settings->ragKnowledge set true
  • set knowledge field

Discord username

  • j0771x
  • misasky

Summary by CodeRabbit

  • New Features

    • Added Qdrant database adapter support
    • Introduced new configuration parameters for Qdrant service
    • Enhanced database initialization with Qdrant integration
  • Dependencies

    • Added @elizaos/adapter-qdrant package
    • Added @qdrant/js-client-rest dependency
  • Configuration

    • Updated environment variables for Qdrant connection
    • Added new package configuration for Qdrant adapter

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oxf71! Welcome to the elizaOS community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now an elizaOS contributor!

@oxf71 oxf71 marked this pull request as ready for review January 16, 2025 03:01
@wtfsayo
Copy link
Member

wtfsayo commented Jan 16, 2025

@coderabbitai review

@wtfsayo wtfsayo enabled auto-merge (squash) January 16, 2025 10:00
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces a new Qdrant database adapter for the project, expanding the database integration capabilities. Changes include adding configuration parameters for Qdrant in the .env.example file, creating a new @elizaos/adapter-qdrant package, and modifying the agent's database initialization logic to support Qdrant as a database option. The implementation provides a comprehensive set of methods for managing various data types like knowledge, memories, goals, and participants.

Changes

File Change Summary
.env.example Added Qdrant configuration variables: QDRANT_URL, QDRANT_KEY, QDRANT_PORT, QDRANT_VECTOR_SIZE
agent/package.json Added @elizaos/adapter-qdrant dependency
agent/src/index.ts Imported QdrantDatabaseAdapter and updated database initialization logic
packages/adapter-qdrant/.npmignore Added .npmignore to specify files to ignore when publishing
packages/adapter-qdrant/eslint.config.mjs Introduced ESLint configuration file extending global config
packages/adapter-qdrant/package.json Created package configuration with name, version, dependencies, and scripts
packages/adapter-qdrant/src/index.ts Added QdrantDatabaseAdapter class with methods for database operations
packages/adapter-qdrant/tsconfig.json Added TypeScript configuration extending base config
packages/adapter-qdrant/tsup.config.ts Introduced tsup configuration for building the package

Possibly related PRs

Suggested labels

Needs Testing, Plugin_new


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (2)
packages/adapter-qdrant/src/index.ts (1)

143-179: Enhance caching strategy with invalidation and size limits.

An in-memory cache without eviction policy can lead to uncontrolled memory growth. Consider implementing cache invalidation and setting size limits.

.env.example (1)

554-559: Add documentation comments for Qdrant configuration.

While the variables and default values are appropriate, adding brief documentation comments would help users understand:

  • The expected format for QDRANT_URL
  • Whether QDRANT_KEY is optional
  • Why these specific default values were chosen
 # Qdrant
-QDRANT_URL=
-QDRANT_KEY=
-QDRANT_PORT=443
-QDRANT_VECTOR_SIZE=1536
+# 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
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30b1c69 and 2b65c93.

📒 Files selected for processing (9)
  • .env.example (1 hunks)
  • agent/package.json (1 hunks)
  • agent/src/index.ts (2 hunks)
  • packages/adapter-qdrant/.npmignore (1 hunks)
  • packages/adapter-qdrant/eslint.config.mjs (1 hunks)
  • packages/adapter-qdrant/package.json (1 hunks)
  • packages/adapter-qdrant/src/index.ts (1 hunks)
  • packages/adapter-qdrant/tsconfig.json (1 hunks)
  • packages/adapter-qdrant/tsup.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • packages/adapter-qdrant/tsconfig.json
  • packages/adapter-qdrant/.npmignore
  • packages/adapter-qdrant/tsup.config.ts
  • packages/adapter-qdrant/eslint.config.mjs
🔇 Additional comments (2)
packages/adapter-qdrant/package.json (1)

1-30: LGTM!

The package.json is correctly configured with appropriate dependencies and scripts.

agent/package.json (1)

26-26: LGTM! Qdrant adapter dependency added correctly.

The dependency is properly added using workspace syntax and maintains alphabetical ordering.

packages/adapter-qdrant/src/index.ts Show resolved Hide resolved
packages/adapter-qdrant/src/index.ts Outdated Show resolved Hide resolved
packages/adapter-qdrant/src/index.ts Outdated Show resolved Hide resolved
packages/adapter-qdrant/src/index.ts Outdated Show resolved Hide resolved
agent/src/index.ts Outdated Show resolved Hide resolved
auto-merge was automatically disabled January 17, 2025 01:22

Head branch was pushed to by a user without write access

@wtfsayo
Copy link
Member

wtfsayo commented Jan 19, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

@wtfsayo i'll review the changes in this pr that adds a new qdrant adapter.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@wtfsayo
Copy link
Member

wtfsayo commented Jan 19, 2025

@oxf71 can you share demo if possible;

Also please allow us to push updates to PR

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/adapter-qdrant/src/index.ts (1)

41-58: Use descriptive variable name in preprocess method

Renaming the variable c to processedContent enhances code readability and clarity.

Apply this diff:

-        const c =  content
+        const processedContent = content
...
-        return c
+        return processedContent
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b65c93 and 048931f.

📒 Files selected for processing (4)
  • .env.example (1 hunks)
  • agent/package.json (1 hunks)
  • agent/src/index.ts (2 hunks)
  • packages/adapter-qdrant/src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • agent/package.json
  • .env.example
🔇 Additional comments (2)
agent/src/index.ts (2)

3-3: Import statement is correct

The import of QdrantDatabaseAdapter is properly added.


574-587: Database initialization logic for Qdrant is accurate

The added conditional check for environment variables and initialization of QdrantDatabaseAdapter are correctly implemented.

packages/adapter-qdrant/src/index.ts Outdated Show resolved Hide resolved
@wtfsayo wtfsayo enabled auto-merge (squash) January 20, 2025 06:42
@oxf71
Copy link
Contributor Author

oxf71 commented Jan 20, 2025

@oxf71 can you share demo if possible;

Also please allow us to push updates to PR

We are using the "trump character". The "knowledge" field needs to be changed to a path format. After testing, we found that there is a difference: the implemented knowledge method is only invoked when it is set to the path format.

pnpm run dev --characters="characters/trump.character.json"
"knowledge": [
    {
      "path": "trump.txt"
    }
  ],

auto-merge was automatically disabled January 20, 2025 06:48

Head branch was pushed to by a user without write access

@wtfsayo
Copy link
Member

wtfsayo commented Jan 22, 2025

hey @oxf71 can you share a demo of it working? Personally superexcited for this

@wtfsayo
Copy link
Member

wtfsayo commented Jan 22, 2025

also can't resolve conflict or/and push change to this branch myself

@wtfsayo wtfsayo enabled auto-merge January 23, 2025 05:41
@wtfsayo wtfsayo self-requested a review January 23, 2025 05:41
@wtfsayo wtfsayo added this pull request to the merge queue Jan 23, 2025
@wtfsayo wtfsayo merged commit 805fc50 into elizaOS:develop Jan 23, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants