-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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: plugin for OriginTrail Decentralized Knowledge Graph #2380
Conversation
Add OriginTrail DKG plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @brkagithub! 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!
@brkagithub can you please make this a draft pr since it's not ready. thanks |
apologies @JoeyKhd, it's ready now also some notes:
|
Thanks so much for adding this plugin - been waiting for elizaOS to have a DKG integration let me review rn :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really crushed it! Thank you SO much for integrating with elizaOS! We are so stoked to use it! I understand it is a WIP PR but wanted to share feedback to make it easier for you to iterate! Thanks so much for this honestly gamechanging addition to eliza! Appreciate you and your hard work here!
Thanks for the nice words, I'm glad you know about the DKG :D Also thanks a lot for the suggestions, still getting used to the repo and the style, happy to implement these and improve the code readability and make it more useful with types Just for clarification, we have some // TODO comments which I would like to leave in the code so the contributors know where they can contribute potentially, and also for devs from our side so that's it's obvious from the code which could be the future improvements. The PR itself is not WIP, will implement these improvements tho Our long term plan for Eliza is to be a KG adapter - however atm this seems like a bunch of work so we wanted to go for a plugin first and iterate, also since the V2 will be releasing soon we thought it might be better to wait for it before we go for such a big push, would be amazing if we could get early access also (would love to discuss it outside of the PR convo :D) Anyways PR is ready for review again, and if it's all good I'm excited to get it merged! Also let me know if I should be constantly merging with the elizaOS remote or wait until you're done reviewing so I don't have to merge all the time, since new changes are always added to the develop branch, causing conflicts |
@coderabbitai review |
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request introduces the OriginTrail Decentralized Knowledge Graph (DKG) plugin for ElizaOS, expanding the agent's capabilities to interact with decentralized knowledge networks. The changes include configuration updates, a new plugin package, and supporting infrastructure for storing and retrieving knowledge assets across different blockchain environments. Changes
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (10)
packages/plugin-dkg/src/actions/dkgInsert.ts (2)
81-86
: Simplify conditional checks with optional chainingYou can use optional chaining to simplify the condition when checking
match[1]
.Apply this diff:
- if (match && match[1]) { + if (match?.[1]) {🧰 Tools
🪛 Biome (1.9.4)
[error] 81-81: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
92-97
: Simplify conditional checks with optional chainingSimilarly, simplify the condition for
match[1]
using optional chaining.Apply this diff:
- if (match && match[1]) { + if (match?.[1]) {🧰 Tools
🪛 Biome (1.9.4)
[error] 92-92: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/plugin-dkg/src/providers/graphSearch.ts (1)
200-201
: Correct the error log messageThe error message mentions "wallet provider" instead of "graphSearch provider".
Apply this diff:
- elizaLogger.error("Error in wallet provider:", error); + elizaLogger.error("Error in graphSearch provider:", error);packages/plugin-dkg/tsup.config.ts (1)
8-8
: Fix misleading comment.The comment suggests CommonJS but the configuration is set to ESM format.
- format: ["esm"], // Ensure you're targeting CommonJS + format: ["esm"],packages/plugin-dkg/src/types.ts (2)
25-27
: Strengthen SPARQL query validation.The current validation only checks if the query starts with "SELECT". Consider adding more comprehensive validation for SPARQL syntax.
- query: z.string().startsWith("SELECT"), + query: z.string() + .regex(/^SELECT\s+(?:DISTINCT\s+)?[?]\w+(?:\s+[?]\w+)*\s+WHERE\s*{[\s\S]*}\s*(?:LIMIT\s+\d+\s*)?$/i, + "Invalid SPARQL SELECT query format"),
32-34
: Improve type guard parameter types.Replace
any
withunknown
for better type safety.-export const isDKGMemoryContent = (object: any): object is DKGMemoryContent => { +export const isDKGMemoryContent = (object: unknown): object is DKGMemoryContent => { -export const isDKGSelectQuery = (object: any): object is DKGSelectQuery => { +export const isDKGSelectQuery = (object: unknown): object is DKGSelectQuery => {Also applies to: 36-38
packages/plugin-dkg/src/constants.ts (2)
1-1
: Track TODO comment.The TODO comment about connecting Knowledge Assets should be tracked in the issue system.
Would you like me to create a GitHub issue to track this enhancement for connecting Knowledge Assets?
93-96
: Parameterize example values in SPARQL queries.Replace hardcoded example values with template parameters for better reusability.
- CONTAINS(LCASE(?headline), "example_keyword") || + CONTAINS(LCASE(?headline), ${keyword}) ||Also applies to: 119-122, 133-134, 147-148, 161-162
packages/plugin-dkg/README.md (1)
70-72
: Fix list indentation.Adjust the indentation to use 2 spaces for nested lists to comply with markdown standards:
- Node information. - LLM key. - Twitter credentials. + - Node information. + - LLM key. + - Twitter credentials.🧰 Tools
🪛 Markdownlint (0.37.0)
70-70: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
71-71: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
72-72: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
.env.example (1)
639-647
: Consider adding validation hints for DKG configuration.The environment variables are well-documented, but consider adding:
- Example values for DKG_HOSTNAME
- Format requirements for DKG_PUBLIC_KEY and DKG_PRIVATE_KEY
- Default value for DKG_ENVIRONMENT
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
.env.example
(1 hunks)agent/package.json
(1 hunks)agent/src/index.ts
(6 hunks)packages/plugin-dkg/.npmignore
(1 hunks)packages/plugin-dkg/README.md
(1 hunks)packages/plugin-dkg/eslint.config.mjs
(1 hunks)packages/plugin-dkg/package.json
(1 hunks)packages/plugin-dkg/src/actions/dkgInsert.ts
(1 hunks)packages/plugin-dkg/src/actions/index.ts
(1 hunks)packages/plugin-dkg/src/constants.ts
(1 hunks)packages/plugin-dkg/src/index.ts
(1 hunks)packages/plugin-dkg/src/providers/graphSearch.ts
(1 hunks)packages/plugin-dkg/src/providers/index.ts
(1 hunks)packages/plugin-dkg/src/templates.ts
(1 hunks)packages/plugin-dkg/src/types.ts
(1 hunks)packages/plugin-dkg/tsconfig.json
(1 hunks)packages/plugin-dkg/tsup.config.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (6)
- packages/plugin-dkg/src/actions/index.ts
- packages/plugin-dkg/src/providers/index.ts
- packages/plugin-dkg/.npmignore
- packages/plugin-dkg/eslint.config.mjs
- packages/plugin-dkg/tsconfig.json
- packages/plugin-dkg/package.json
🧰 Additional context used
🪛 Markdownlint (0.37.0)
packages/plugin-dkg/README.md
70-70: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
71-71: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
72-72: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
🪛 Biome (1.9.4)
packages/plugin-dkg/src/actions/dkgInsert.ts
[error] 81-81: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 92-92: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (5)
packages/plugin-dkg/src/index.ts (1)
1-16
: LGTM!The plugin is correctly defined and exports are appropriately handled.
packages/plugin-dkg/src/templates.ts (1)
17-17
: Clarify UUID format requirements.The instruction mentions using UUIDs but doesn't specify the format (v4, v5, etc.) or how to generate them consistently.
agent/src/index.ts (1)
98-98
: LGTM! DKG plugin integration follows established patterns.The plugin is properly imported and conditionally initialized based on the presence of required environment variables.
Also applies to: 816-819, 960-960
packages/plugin-dkg/README.md (1)
77-77
: Verify the file path reference.The path
plugin-dkg/constants.ts
might be incorrect. Consider using the full package name@elizaos/plugin-dkg/src/constants.ts
or providing the relative path from the project root.agent/package.json (1)
102-102
: LGTM! Dependency correctly added.The DKG plugin is properly added as a workspace dependency.
can you fix conflicts @brkagithub and also give access to push changes |
Conflicts are resolved @wtfsayo, hopefully there will be no more pushes to elizaOS/develop until you see it :D Giving you write access |
is there a problem @wtfsayo? Would be great to merge if you're happy with the PR, since every time something new gets pushed to develop, we get more conflicts |
i will take care tomorrow |
Relates to
N/A - New plugin contribution
Risks
Low:
Background
What does this PR do?
Adds support for a plugin which provides additional context to the agent by querying the OriginTrail DKG, as well as creating each memory on the OriginTrail DKG.
What kind of change is this?
Features (non-breaking change which adds functionality)
Documentation changes needed?
My changes do not require a change to the project documentation. A README has been added for this plugin as a guideline for any users.
Testing
Where should a reviewer start?
src/actions/dkgInsert (action that inserts a memory to the DKG)
src/providers/graphSearch (provider that searches the graph and provides additional context)
Detailed testing steps
Add your DKG Node and wallet details to the .env (description of each variable is either obvious or explained in the .env.example). You can DM me on Discord (@Brka) and I can provide a testnet node, as well as testnet funds in case you don't have one on one of the supported networks (Base, Gnosis, NeuroWeb)
Initiate a conversation with the agent, the provider should run and provide additional info to the context, which you can confirm by checking whether new logs are being printed (that the graph is being queried). After that, the action should run and a Knowledge Asset should succesfully be created on the DKG, which should also be logged
Screenshots
None needed
Deploy Notes
N/A