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: atoma provider #2082

Merged
merged 24 commits into from
Jan 16, 2025
Merged

Conversation

francis2tm
Copy link
Contributor

@francis2tm francis2tm commented Jan 9, 2025

Background

Atoma is a decentralized private and verifiable AI execution network. It provides the infrastructure for developers and enterprises to use open-source AI models and build AI applications with full privacy.

What does this PR do?

Adds Atoma Network as an inference provider

What kind of change is this?

Features (non-breaking change which adds functionality)

Web3 Agents deserve a decentralized AI cloud.

Documentation changes needed?

Yes, add atoma provider docs

Testing

Ran pnpm start --character="characters/trump.character.json" with "modelProvider": "atoma"

Where should a reviewer start?

Detailed testing steps

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 @francis2tm! Welcome to the ai16z community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now a ai16z contributor!

@francis2tm francis2tm changed the title Feat/atoma provider feat: atoma provider Jan 9, 2025
…eason, usage metrics, and timestamp conversion
packages/core/src/models.ts Outdated Show resolved Hide resolved
packages/core/src/generation.ts Outdated Show resolved Hide resolved
…K version change

- Added Atoma API URL and model configurations to .env.example.
- Updated pnpm-lock.yaml to reference the latest Atoma SDK version.
- Enhanced index.ts to include Atoma as a model provider for token retrieval.
- Implemented Atoma model initialization and response handling in generation.ts.
- Updated models.ts to utilize dynamic settings for Atoma model classes.
…dels.ts

- Deleted EMBEDDING_ATOMA_MODEL and IMAGE_ATOMA_MODEL from .env.example.
- Removed corresponding model class settings from models.ts to streamline configuration.
…and consistency

- Updated Atoma model settings in models.ts to encapsulate parameters (stop, maxInputTokens, maxOutputTokens, temperature) within each model class.
- Reformatted code for better readability and maintainability.
- Minor formatting adjustments in types.ts for consistency in enum declaration and interface method signatures.
@francis2tm francis2tm changed the base branch from main to develop January 16, 2025 00:39
- Standardized import statements and removed unnecessary line breaks.
- Simplified function definitions and improved inline comments for clarity.
- Enhanced logging messages for better debugging and error tracking.
- Ensured consistent use of single quotes for strings throughout the file.
- Deleted the handleAtoma function, which was responsible for generating objects for Atoma models.
- This change simplifies the codebase by removing unused functionality, improving maintainability.
@francis2tm francis2tm marked this pull request as ready for review January 16, 2025 01:05
@fabianhug
Copy link
Contributor

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

📝 Walkthrough

Walkthrough

The pull request introduces integration for the Atoma SDK across multiple configuration and source files. The changes add a new model provider called "Atoma" with support for small, medium, and large model configurations. The implementation includes environment configuration, token retrieval, text generation capabilities, and type definitions to seamlessly incorporate the Atoma model into the existing system architecture.

Changes

File Change Summary
.env.example Added Atoma SDK configuration entries for bearer auth, API URL, and model settings
agent/src/index.ts Extended getTokenForProvider to handle Atoma provider authentication
packages/core/src/generation.ts Added support for Atoma model in generateText function
packages/core/src/models.ts Introduced Atoma model provider with small, medium, and large model configurations
packages/core/src/types.ts Updated Models type and ModelProviderName enum to include Atoma provider

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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: 0

🧹 Nitpick comments (2)
packages/core/src/models.ts (1)

1001-1032: Consider differentiating models for different size classes.

The current configuration uses the same model "meta-llama/Llama-3.3-70B-Instruct" for all size classes. Consider using different models optimized for each class to provide better resource utilization and performance options.

Add frequency and presence penalties for better text generation.

Add frequency_penalty and presence_penalty parameters to align with other providers and improve text generation quality:

     [ModelProviderName.ATOMA]: {
         endpoint: settings.ATOMA_API_URL || "https://api.atoma.network/v1",
         model: {
             [ModelClass.SMALL]: {
                 name:
                     settings.SMALL_ATOMA_MODEL ||
                     "meta-llama/Llama-3.3-70B-Instruct",
                 stop: [],
                 maxInputTokens: 128000,
                 maxOutputTokens: 8192,
                 temperature: 0.7,
+                frequency_penalty: 0.4,
+                presence_penalty: 0.4,
             },
             // Apply similar changes to MEDIUM and LARGE classes

Consider adding embedding and image model support.

Many providers support embedding and image models. Consider adding these capabilities if the Atoma provider supports them.

.env.example (1)

89-95: Consider differentiating model tiers and enhancing documentation.

  1. All model tiers currently default to the same model. Consider using different models for each tier to better balance performance and cost.
  2. The API URL comment mentions "Default:" but doesn't specify the value.
  3. The bearer token format and requirements should be documented.

Apply this diff to improve the configuration block:

 # Atoma SDK Configuration
-ATOMASDK_BEARER_AUTH=           # Atoma SDK Bearer Auth token
-ATOMA_API_URL=                  # Default: https://api.atoma.network/v1
-SMALL_ATOMA_MODEL=              # Default: meta-llama/Llama-3.3-70B-Instruct
-MEDIUM_ATOMA_MODEL=             # Default: meta-llama/Llama-3.3-70B-Instruct
-LARGE_ATOMA_MODEL=              # Default: meta-llama/Llama-3.3-70B-Instruct
+ATOMASDK_BEARER_AUTH=           # Atoma SDK Bearer Auth token (format: at-xxxxxxxxxxxx)
+ATOMA_API_URL=https://api.atoma.network/v1  # Default: https://api.atoma.network/v1
+SMALL_ATOMA_MODEL=meta-llama/Llama-3.3-7B-Instruct    # Default: meta-llama/Llama-3.3-7B-Instruct
+MEDIUM_ATOMA_MODEL=meta-llama/Llama-3.3-70B-Instruct  # Default: meta-llama/Llama-3.3-70B-Instruct
+LARGE_ATOMA_MODEL=meta-llama/Llama-3.3-140B-Instruct  # Default: meta-llama/Llama-3.3-140B-Instruct
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5076588 and c3f8617.

📒 Files selected for processing (5)
  • .env.example (1 hunks)
  • agent/src/index.ts (1 hunks)
  • packages/core/src/generation.ts (2 hunks)
  • packages/core/src/models.ts (1 hunks)
  • packages/core/src/types.ts (3 hunks)
🔇 Additional comments (4)
packages/core/src/types.ts (1)

232-232: LGTM!

The ATOMA provider is correctly added to both the Models type and ModelProviderName enum, maintaining type safety and following the established pattern.

Also applies to: 268-268

agent/src/index.ts (1)

476-480: LGTM!

The ATOMA case in getTokenForProvider follows the established pattern and correctly handles token retrieval from both character settings and global settings.

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

966-994: LGTM!

The ATOMA case in generateText is well-implemented, using createOpenAI with proper configuration and following the established pattern for text generation.

.env.example (1)

89-89: LGTM! Proper section placement.

The Atoma SDK configuration block is correctly placed in the "Model Provider Configurations" section, maintaining alphabetical ordering.

@shakkernerd shakkernerd merged commit ac87ec7 into elizaOS:develop Jan 16, 2025
3 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.

4 participants