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: Creating Archetype Selector #2422

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

alvarosps
Copy link

Add Archetype Selector for Agent Customization

What does this PR do?

This PR introduces the Archetype Selector feature to enable customization of agent behaviors via predefined archetypes. This contribution includes:

New Component: ArchetypeSelector

  • Allows users to preview, download, and apply archetypes to agents.

Backend API Integration:

  • Reuses the /agents/:agentId/set route to apply archetypes.

  • Ensures validation and logging during archetype application.

UI Enhancements:

  • Sidebar now includes a "Change Agent's Archetype" button for each agent.

This feature enhances user experience by:

Allowing users to modify agent behavior dynamically without direct configuration file edits.
Supporting modular design with predefined archetypes for consistent customization.

Documentation changes needed?

My changes do not require a project documentation change.

Testing

I wanted to write unit tests, but this is my first contribution to the project, and I could not find unit tests already created in the frontend project, only inside the project packages. Since I did not want to make more changes, like adding new libraries, I didn't include unit tests (even though I've written some test cases).

To test, you can run the application locally, and you should be able to see the button in the sidebar to see the new UI, and select from the current example archetypes. This will change the current agent archetype. This is a 1st version of the feature, so there is a lot of room for improvement in the future.

Screenshots

image

Discord username alvarosps

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 @alvarosps! 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!

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

coderabbitai bot commented Jan 17, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a new feature for agent archetype selection and management. A new ArchetypeSelector component is added to the application, allowing users to select, download, and apply different character archetypes to agents. The changes include routing updates, sidebar modifications, and the creation of a new API method to support archetype application.

Changes

File Change Summary
client/src/App.tsx Added route for ArchetypeSelector component at settings/archetypes/:agentId
client/src/components/app-sidebar.tsx Updated sidebar to include settings links for each agent alongside existing chat links
client/src/components/archetype-selector.tsx New component for selecting and applying agent archetypes
client/src/lib/api.ts Added applyArchetype method to apiClient for setting agent archetypes
client/src/types/archetypes.ts Introduced ArchetypeName enum and archetypes constant with predefined character configurations
packages/client-direct/src/api.ts Minor formatting and code readability improvements

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 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)
client/src/types/archetypes.ts (1)

17-21: Remove duplicated style properties

The style properties are identical across all contexts (all, chat, post) for each archetype. Consider simplifying the structure.

         style: {
-            all: ["Optimistic", "Encouraging", "Kind"],
-            chat: ["Optimistic", "Encouraging", "Kind"],
-            post: ["Optimistic", "Encouraging", "Kind"],
+            all: ["Optimistic", "Encouraging", "Kind"]
         },

Also applies to: 48-52, 86-90

client/src/lib/api.ts (1)

105-110: Add return type annotation for consistency.

The implementation looks good but could benefit from an explicit return type annotation for better type safety and documentation.

-    applyArchetype: (agentId: string, archetype: Character) =>
+    applyArchetype: (agentId: string, archetype: Character): Promise<Character> =>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eb140e0 and 1559885.

📒 Files selected for processing (6)
  • client/src/App.tsx (2 hunks)
  • client/src/components/app-sidebar.tsx (1 hunks)
  • client/src/components/archetype-selector.tsx (1 hunks)
  • client/src/lib/api.ts (1 hunks)
  • client/src/types/archetypes.ts (1 hunks)
  • packages/client-direct/src/api.ts (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/client-direct/src/api.ts
🧰 Additional context used
🪛 Biome (1.9.4)
client/src/components/app-sidebar.tsx

[error] 93-93: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: integration-tests
  • GitHub Check: smoke-tests
🔇 Additional comments (2)
client/src/lib/api.ts (2)

105-110: Implementation looks good!

The method follows existing patterns, uses proper types, and inherits robust error handling from the fetcher utility.


105-110: Consider URL pattern consistency.

Some endpoints use /agents/ prefix while others don't. Consider standardizing the URL patterns across all agent-related endpoints.

client/src/App.tsx Show resolved Hide resolved
client/src/components/archetype-selector.tsx Outdated Show resolved Hide resolved
client/src/components/archetype-selector.tsx Outdated Show resolved Hide resolved
client/src/types/archetypes.ts Outdated Show resolved Hide resolved
client/src/components/app-sidebar.tsx Outdated Show resolved Hide resolved
@alvarosps alvarosps changed the title feature: Creating Archetype Selector feat: Creating Archetype Selector Jan 17, 2025
auto-merge was automatically disabled January 17, 2025 20:00

Head branch was pushed to by a user without write access

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