Skip to content

Conversation

@robbeverhelst
Copy link
Contributor

@robbeverhelst robbeverhelst commented Oct 30, 2024

Summary by Sourcery

Documentation:

  • Add a comprehensive guide on utilizing AI features in SettleMint, focusing on OpenAI nodes and pgvector in Hasura for building AI-powered workflows.

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive guide for utilizing AI features within the SettleMint platform, focusing on OpenAI integration and similarity searches.
  • Documentation

    • Added ai-features.md detailing workflows for data vectorization and similarity searches using OpenAI and Hasura, including setup instructions and advanced use cases.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 30, 2024

Reviewer's Guide by Sourcery

This PR adds comprehensive documentation for AI features in SettleMint, specifically focusing on how to implement OpenAI nodes and pgvector in Hasura. The documentation provides a detailed, step-by-step guide for creating AI-powered workflows that handle data vectorization and similarity searches.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added new developer documentation for AI features implementation
  • Created step-by-step guide for setting up vector storage in Hasura
  • Documented workflow creation process for data fetching and vectorization
  • Added instructions for implementing similarity search endpoints
  • Included code examples for GraphQL mutations and queries
  • Added prerequisites and example flow descriptions
  • Provided next steps and advanced use cases for blockchain-specific applications
  • Included relevant documentation links and resources
docs/developer-guides/ai-features.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the feat New feature label Oct 30, 2024
@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2024

Walkthrough

A new documentation file named ai-features.md has been added to the docs/developer-guides/ directory. This guide provides a detailed overview of integrating AI features into the SettleMint platform, specifically focusing on the use of OpenAI nodes and the pgvector plugin in Hasura. It explains how to create workflows for data vectorization and similarity searches, including setup instructions for Hasura and GraphQL mutations.

Changes

File Change Summary
docs/developer-guides/ai-features.md Added a comprehensive guide for utilizing AI features, covering workflows for data vectorization and similarity searches using OpenAI and Hasura.

Possibly related PRs

  • feat: custom deployment docs #81: The changes in this PR involve documentation for deploying custom components, which may relate to the integration of AI features in custom workflows, as both involve enhancing the SettleMint platform's capabilities.

Suggested reviewers

  • roderik
  • daanporon
  • mrtcntn

🐇 In the garden of code so bright,
A new guide blooms, a wondrous sight.
With AI's help, we weave and play,
Vectorizing data, come what may.
In Hasura's arms, our queries dance,
Join us, dear friends, in this new chance! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 99007e4 and 358f4fb.

📒 Files selected for processing (1)
  • docs/developer-guides/ai-features.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/developer-guides/ai-features.md

🪧 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 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

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @robbeverhelst - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a direct link to the 'Getting Started Guide' in the introduction section for easier navigation.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 3 issues found

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


### Step 1: Set Up Vector Storage in Hasura

1. Access your SettleMints Hasura instance through the admin console.
Copy link

Choose a reason for hiding this comment

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

issue (documentation): Fix typo in 'SettleMints' - should be 'SettleMint's'

Copy link

@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

🧹 Outside diff range and nitpick comments (5)
docs/developer-guides/ai-features.md (5)

8-14: Add OpenAI API key requirement to the introduction.

The introduction should mention that users need an OpenAI API key to use these features, as it's a critical prerequisite for the OpenAI nodes to function.

 In this guide, you will learn to create workflows that:
 - Use **OpenAI nodes** to vectorize data.
 - Store vectorized data in **Hasura** using `pgvector`.
 - Conduct similarity searches to find relevant matches for new queries.
+
+> **Note**: You'll need an OpenAI API key to use the OpenAI nodes. You can obtain one from the [OpenAI platform](https://platform.openai.com/).

15-19: Add version requirements to prerequisites.

To prevent compatibility issues, specify the minimum required versions of Integration Studio and Hasura.

 ### Prerequisites
 - A SettleMint Platform account with **Integration Studio** and **Hasura** deployed
+  - Integration Studio version 2.0 or higher
+  - Hasura version 2.25 or higher with pgvector extension enabled
 - Access to the Integration Studio and Hasura consoles in your SettleMint environment
 - A data source to vectorize (e.g., Graph Node, Attestation Indexer, or external API endpoint)

64-71: Add error handling to GraphQL mutation example.

The mutation example should include error handling to help users debug issues.

 mutation insertVector($id: uuid!, $vector: [Float!]!) {
   insert_vectors(objects: {id: $id, vector: $vector}) {
     affected_rows
+    returning {
+      id
+    }
+    # Add error handling
+    __typename
   }
 }

114-120: Specify distance metric and add response format example.

The vector search query should specify the distance metric and include an example of the expected response format.

 query searchVectors($vector: [Float!]!) {
   vectors(
     order_by: {vector: {_vector_distance: $vector}},
+    # Specify distance metric (cosine similarity)
+    vector_distance_metric: "cosine",
     limit: 5
   ) {
     id
     vector
+    distance
   }
 }

Add example response:

{
  "data": {
    "vectors": [
      {
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "distance": 0.123
      }
    ]
  }
}

157-163: Add community support channels and versioned documentation links.

Consider adding:

  1. SettleMint community support channels
  2. Version-specific documentation links to prevent broken references
 For further resources, check out:
 
 - [SettleMint Integration Studio Documentation](https://console.settlemint.com/documentation/docs/using-platform/integration-studio/)
 - [Node-RED Documentation](https://nodered.org/docs/)
 - [OpenAI API Documentation](https://beta.openai.com/docs/)
 - [Hasura pgvector Documentation](https://hasura.io/docs/3.0/connectors/postgresql/native-operations/vector-search/)
+- [SettleMint Community Forum](https://community.settlemint.com)
+- [SettleMint Discord Server](https://discord.gg/settlemint)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bf7297f and 99007e4.

⛔ Files ignored due to path filters (1)
  • static/img/developer-guides/openai-node.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • docs/developer-guides/ai-features.md (1 hunks)
🔇 Additional comments (1)
docs/developer-guides/ai-features.md (1)

1-6: LGTM! Well-structured metadata section.

The metadata section includes all necessary fields and relevant keywords for documentation indexing.

Comment on lines +37 to +40
2. Create a new table called `document_embeddings` with the following columns:
- `id` (type: UUID, primary key)
- `embedding` (type: vector(1536)) - For storing OpenAI embeddings

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add vector index creation step for performance.

The table creation instructions should include creating an index for vector similarity searches to optimize query performance.

 2. Create a new table called `document_embeddings` with the following columns:
    - `id` (type: UUID, primary key)
    - `embedding` (type: vector(1536)) - For storing OpenAI embeddings
+
+ 3. Create an index for vector similarity search:
+    ```sql
+    CREATE INDEX ON document_embeddings 
+    USING ivfflat (embedding vector_cosine_ops)
+    WITH (lists = 100);
+    ```

@roderik roderik merged commit d95f311 into main Oct 30, 2024
1 check passed
@roderik roderik deleted the feat/ai-features branch October 30, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants