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(new-plugin): deva client integration #1238

Merged
merged 51 commits into from
Jan 27, 2025

Conversation

stopmalone
Copy link
Contributor

@stopmalone stopmalone commented Dec 19, 2024

Pull Request: Integrate Deva into Eliza

Relates to

This PR adds a new Deva client integration for the Eliza AI agent, enabling posting and scheduling posts to the Deva feed.

Risks

  • Minimal Risk: This integration is additive and does not alter existing functionalities of Eliza.
  • Dependency Management: Introduces a new dependency on Deva's API, which requires monitoring for future updates or changes.
  • Data Privacy: Ensures that any data shared between Eliza and Deva complies with our privacy policies.

Background

What does this PR do?

This PR introduces the capability to post and schedule content directly to the Deva platform from the Eliza AI agent. Users can now seamlessly integrate their Eliza-generated content with Deva, enhancing their content distribution and engagement strategies.

What kind of change is this?

Feature: This is a non-breaking change that adds new functionality to the Eliza AI agent by integrating with Deva’s API for posting and scheduling content.

Documentation Changes Needed?

Not at the moment.

Testing

Detailed Testing Steps

  1. Create a Deva Account

    • Navigate to deva.me, create an account, and press the "Get Started" button in the top right.
    • Get Started
  2. Complete Onboarding

    • Click through the onboarding screens and connect your preferred social account (e.g., Twitter) to Deva.
  3. Access the Deva Feed

    • You can now see the Deva feed, where you can post and interact with other Devas.
    • image
  4. Create an Application to get the token

    • At this point, you'll be able to get a token to interact with Deva, to do so:
      • Navigate to Apps chapter in settings by clicking the user icon in top right corner and then settings -> Apps, or opening apps
      • Press Apps and Session

        image
      • Press Create new app

        image
      • You are redirected to the form of the app creation, Name, Redirect URL and descriptions are necessary fields. Permissions are preselected and they are exactly enough for Eliza agent to post a message in feed.
      • After creating an app, select it from the list of apps;
      • Inside you will find a Get Token button, to generate a new token for your app:

        image
      • Later, it'll be visible in the list:

        image
  5. Update Environment Variables

    • Once you have the token, update the environment variables in the .env file:
      DEVA_API_KEY=YourApiKey
      DEVA_API_BASE_URL=https://api.deva.me # Production API URL
  6. Select Deva Client as Default Character

    • Select the Deva client as Eliza's default character and choose the desired model:

      Select Deva Client
  7. Run the Application

    • Execute the following commands to install dependencies and start the application:
      pnpm install && pnpm start
    • This will initiate the Deva client:

      Initiate Deva Client
    • Fetch the persona associated with your agent and the posts that you have pushed to the Deva feed:

      Fetch Persona and Posts
    • Once done, Eliza will post one message to the Deva feed immediately and schedule another one as a test message:

      Post Messages
  8. Eliza agent's post is in the feed!

    • image

Staging Environment Testing

To avoid populating the production Deva feed, you can perform the same flow in the staging environment. Ensure you update the related environment variable:

DEVA_API_BASE_URL=https://api-staging.deva.me # Staging API URL


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

## Release Notes

- **New Features**
	- Added Deva client integration for interacting with the Deva.me platform
	- Introduced new methods for retrieving user personas, fetching persona posts, and creating posts
	- Expanded client configuration with Deva-specific environment variables

- **Documentation**
	- Updated client documentation to include Deva client setup and usage instructions
	- Added new API references for Deva client methods

- **Configuration**
	- Added new environment variables for Deva API key and base URL
	- Updated default character model provider to OpenAI

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@stopmalone stopmalone changed the base branch from main to develop December 19, 2024 13:06
@odilitime odilitime changed the title Feat/deva client integration feat: deva client integration Dec 20, 2024
odilitime
odilitime previously approved these changes Dec 20, 2024
@stopmalone stopmalone requested a review from luduvigo January 16, 2025 17:46
Copy link
Contributor

coderabbitai bot commented Jan 21, 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

This pull request introduces the Deva client integration into the system, adding a new client platform with support for persona management, post creation, and interaction. The changes span multiple files, including configuration, documentation, and source code, to enable seamless integration of the Deva.me platform into the existing agent framework.

Changes

File Change Summary
.env.example Added Deva service configuration variables
agent/package.json Added @elizaos/client-deva dependency
agent/src/index.ts Updated client initialization to support Deva client
docs/api/enumerations/Clients.md Added DEVA enum member
docs/docs/packages/clients.md Documented Deva client methods and integration
packages/client-deva/* Created new package with Deva client implementation
packages/core/src/types.ts Added Deva-related type modifications

Possibly related PRs


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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: 15

🧹 Nitpick comments (7)
packages/client-deva/src/controller.ts (2)

190-192: Ensure unique room IDs using persona ID

Generating roomId with this.persona.username may cause conflicts if usernames are not unique. Using this.persona.id ensures uniqueness.

Update the roomId generation:

const roomId = stringToUuid(
-    "deva_generate_room-" + this.persona.username
+    "deva_generate_room-" + this.persona.id
);

238-238: Use consistent logging with 'elizaLogger'

Replace console.log(newPostContent); with elizaLogger.log(newPostContent); to maintain consistent logging practices throughout the code.

Apply this diff:

-    console.log(newPostContent);
+    elizaLogger.log(newPostContent);
packages/client-deva/src/types.ts (2)

1-9: Mark optional properties and correct types in 'DevaPersona'

Properties like description, avatar, and cover_image may not always be present. Mark them as optional and adjust types if necessary.

Modify the type definitions:

export type DevaPersona = {
    id: string;
    user_id: string;
    display_name: string;
    username: string;
-   description: string;
+   description?: string;
-   avatar: number;
-   cover_image: number;
+   avatar?: number;
+   cover_image?: number;
};

11-21: Adjust 'DevaPost' types for nullable fields

Fields like in_reply_to_id, mentioned_profile_persona_id, and persona might be null. Update their types to reflect this possibility.

Update the type definitions:

export type DevaPost = {
    id: string;
    author_type: string;
    text: string;
    persona_id: string;
-   in_reply_to_id: string;
-   mentioned_profile_persona_id: string;
-   persona: DevaPersona;
+   in_reply_to_id?: string | null;
+   mentioned_profile_persona_id?: string | null;
+   persona?: DevaPersona | null;
    created_at: string;
    updated_at: string;
};
packages/client-deva/src/index.ts (1)

17-19: Add null check for character name.

The success message assumes character name exists.

 elizaLogger.success(
-    `✅ Deva client successfully started for character ${runtime.character.name}`
+    `✅ Deva client successfully started${runtime.character?.name ? ` for character ${runtime.character.name}` : ''}`
 );
packages/client-deva/src/base.ts (1)

57-58: Replace console.log with elizaLogger.

Use consistent logging mechanism.

-console.log(res);
+elizaLogger.debug("Post creation response:", res);
docs/docs/packages/clients.md (1)

377-377: Remove debug console.log statement.

Production code should not contain debug logging statements.

-   console.log(res);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8081cd4 and de0df42.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • .env.example (1 hunks)
  • agent/package.json (1 hunks)
  • agent/src/index.ts (2 hunks)
  • docs/api/enumerations/Clients.md (1 hunks)
  • docs/docs/packages/clients.md (9 hunks)
  • packages/client-deva/.npmignore (1 hunks)
  • packages/client-deva/eslint.config.mjs (1 hunks)
  • packages/client-deva/package.json (1 hunks)
  • packages/client-deva/src/base.ts (1 hunks)
  • packages/client-deva/src/controller.ts (1 hunks)
  • packages/client-deva/src/devaClient.ts (1 hunks)
  • packages/client-deva/src/enviroment.ts (1 hunks)
  • packages/client-deva/src/index.ts (1 hunks)
  • packages/client-deva/src/templates.ts (1 hunks)
  • packages/client-deva/src/types.ts (1 hunks)
  • packages/client-deva/tsconfig.json (1 hunks)
  • packages/client-deva/tsup.config.ts (1 hunks)
  • packages/core/src/defaultCharacter.ts (1 hunks)
  • packages/core/src/types.ts (2 hunks)
✅ Files skipped from review due to trivial changes (5)
  • packages/client-deva/eslint.config.mjs
  • packages/client-deva/tsconfig.json
  • packages/client-deva/.npmignore
  • packages/client-deva/tsup.config.ts
  • packages/client-deva/package.json
🧰 Additional context used
🪛 LanguageTool
docs/docs/packages/clients.md

[style] ~43-~43: This phrase is redundant (‘I’ stands for ‘interface’). Use simply “API”.
Context: ...ect** (@eliza/client-direct) - Direct API interface for custom integrations - Auto (`@e...

(ACRONYM_TAUTOLOGY)

🪛 Markdownlint (0.37.0)
docs/docs/packages/clients.md

554-554: Column: 1
Hard tabs

(MD010, no-hard-tabs)


555-555: Column: 1
Hard tabs

(MD010, no-hard-tabs)


564-564: Column: 1
Hard tabs

(MD010, no-hard-tabs)


565-565: Column: 1
Hard tabs

(MD010, no-hard-tabs)


566-566: Column: 1
Hard tabs

(MD010, no-hard-tabs)


575-575: Column: 1
Hard tabs

(MD010, no-hard-tabs)


576-576: Column: 1
Hard tabs

(MD010, no-hard-tabs)


577-577: Column: 1
Hard tabs

(MD010, no-hard-tabs)


578-578: Column: 1
Hard tabs

(MD010, no-hard-tabs)


586-586: Column: 1
Hard tabs

(MD010, no-hard-tabs)


587-587: Column: 1
Hard tabs

(MD010, no-hard-tabs)


588-588: Column: 1
Hard tabs

(MD010, no-hard-tabs)


589-589: Column: 1
Hard tabs

(MD010, no-hard-tabs)


590-590: Column: 1
Hard tabs

(MD010, no-hard-tabs)


591-591: Column: 1
Hard tabs

(MD010, no-hard-tabs)


592-592: Column: 1
Hard tabs

(MD010, no-hard-tabs)


593-593: Column: 1
Hard tabs

(MD010, no-hard-tabs)

🔇 Additional comments (6)
packages/client-deva/src/templates.ts (1)

1-24: Verify all placeholders are provided

Ensure that all placeholders like {{adjective}} and {{topic}} used in the template have corresponding values in the context to prevent unresolved variables in generated posts.

packages/core/src/defaultCharacter.ts (1)

8-8: Verify the impact of changing the default model provider.

This changes the default model from LLAMALOCAL to OPENAI, which might affect users relying on the default local setup.

Run this script to check for potential impacts:

✅ Verification successful

Change to OPENAI as default provider is safe

The codebase is designed to be provider-agnostic, with multiple configuration levels allowing users to override the default provider through character configuration or runtime options.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find character configurations that might be affected by the default model provider change

# Search for character configurations that don't specify a model provider
rg -l "\"modelProvider\"" -v

Length of output: 65716


Script:

#!/bin/bash
# Find files importing defaultCharacter.ts
rg -l "from.*defaultCharacter" 

# Find tests that might reference the default model provider
rg -l "modelProvider.*LLAMALOCAL|LLAMALOCAL.*modelProvider" "**/*test*"

# Look for direct references to defaultCharacter
rg -l "defaultCharacter" "packages/core"

Length of output: 639


Script:

#!/bin/bash
# Check content of test files and runtime for LLAMALOCAL dependencies
rg -A 5 -B 5 "modelProvider" "packages/core/__tests__/defaultCharacters.test.ts" "packages/core/__tests__/runtime.test.ts" "packages/core/src/runtime.ts"

# Check if there are any other LLAMALOCAL references we should be aware of
rg -A 5 -B 5 "LLAMALOCAL" "packages/core"

Length of output: 11079

packages/core/src/types.ts (1)

657-657: LGTM! Clean integration of the Deva client.

The enum addition and template property are well-structured and consistent with existing patterns.

Also applies to: 765-765

docs/api/enumerations/Clients.md (1)

86-96: LGTM! Documentation is well-structured.

The DEVA enum value is documented consistently with other client platforms.

agent/package.json (1)

111-111: LGTM! Dependency added correctly.

The Deva client package is properly added with workspace versioning, consistent with other client packages.

docs/docs/packages/clients.md (1)

21-21: LGTM! Architecture diagram updated appropriately.

The Deva client is properly integrated into the architecture diagram with correct connections.

Also applies to: 29-29

packages/client-deva/src/controller.ts Outdated Show resolved Hide resolved
packages/client-deva/src/controller.ts Outdated Show resolved Hide resolved
packages/client-deva/src/controller.ts Outdated Show resolved Hide resolved
packages/client-deva/src/templates.ts Outdated Show resolved Hide resolved
packages/client-deva/src/index.ts Outdated Show resolved Hide resolved
packages/client-deva/src/base.ts Outdated Show resolved Hide resolved
agent/src/index.ts Outdated Show resolved Hide resolved
docs/docs/packages/clients.md Outdated Show resolved Hide resolved
docs/docs/packages/clients.md Outdated Show resolved Hide resolved
.env.example Outdated Show resolved Hide resolved
@wtfsayo wtfsayo requested review from wtfsayo and removed request for luduvigo January 27, 2025 18:57
@wtfsayo wtfsayo changed the title feat: deva client integration feat(new-plugin): deva client integration Jan 27, 2025
@odilitime odilitime merged commit a7554dd into elizaOS:develop Jan 27, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants