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

Added Mistral LLM #919

Closed
wants to merge 0 commits into from
Closed

Conversation

kartheekyakkala
Copy link
Contributor

@kartheekyakkala kartheekyakkala commented Jan 31, 2024

  • Closes #xxxx (Replace xxxx with the GitHub issue number).
  • Tests added and passed if fixing a bug or adding a new feature.
  • All code checks passed.

Summary by CodeRabbit

  • New Features
    • Introduced the Mistralai class for enhanced interaction with the Mistral Language Model, including querying and processing responses from the Mistralai API.

Copy link
Contributor

coderabbitai bot commented Jan 31, 2024

Walkthrough

The update introduces the Mistralai class, a significant addition designed to interact with the Mistral LLM. This class is tailored for querying the Mistralai API, managing calls to the language model, and ensuring robust handling of retries and response processing. It marks a pivotal enhancement in the system's ability to communicate with advanced language models.

Changes

File Change Summary
pandasai/llm/Mistralai.py Introduced Mistralai class for API interaction and LLM communication.
tests/integration_tests/test_cricket.py Removed os import.
tests/integration_tests/test_gin.py Removed os import.
tests/integration_tests/test_spotify.py Removed os import; modified import for SmartDataframe from pandasai.

🐇✨
In the digital meadow, under the byte-sized sun,
A new class was born, Mistralai, ready to run.
With queries and retries, through data it hops,
Bringing wisdom and answers, never it stops.
🌟📚

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f145da9 and c43b072.
Files ignored due to path filters (1)
  • pyproject.toml is excluded by: !**/*.toml
Files selected for processing (1)
  • pandasai/llm/Mistralai.py (1 hunks)
Additional comments: 2
pandasai/llm/Mistralai.py (2)
  • 18-20: The class Mistralai correctly inherits from LLM, aligning with the objective to integrate Mistral LLM into the project. This inheritance ensures that Mistralai adheres to the expected interface and behavior of language model classes within the project.
  • 28-33: The approach to obtaining the api_token from kwargs or environment variables is robust, ensuring flexibility in configuration. However, the explicit check for None and raising an APIKeyNotFoundError if not found is a good practice for early error detection and clear error messaging.

pandasai/llm/Mistralai.py Outdated Show resolved Hide resolved
pandasai/llm/Mistralai.py Outdated Show resolved Hide resolved
pandasai/llm/Mistralai.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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.

PR Type: Enhancement

PR Summary: The pull request introduces a new class, Mistralai, which is designed to integrate with the Mistral LLM API. This class provides methods to set up the API client with necessary credentials, query the API with user instructions, and handle the response. It also includes a retry mechanism for API calls and a method to process and return the response from the LLM.

Decision: Comment

📝 Type: 'Enhancement' - not supported yet.
  • Sourcery currently only approves 'Typo fix' PRs.
✅ Issue addressed: this change correctly addresses the issue or implements the desired feature.
No details provided.
📝 Complexity: the changes are too large or complex for Sourcery to approve.
  • Unsupported files: the diff contains files that Sourcery does not currently support during reviews.

General suggestions:

  • Ensure that the class and method docstrings accurately describe the functionality and that any references to other LLMs (e.g., HuggingFace) are removed if they are not relevant.
  • Review the retry logic to ensure that it behaves as expected, particularly in how it handles the 'suffix' parameter.
  • Clarify any comments that may be ambiguous or not informative enough to understand the code's intention, such as the '# No streaming' comment.
  • Consider improving variable names for clarity, such as the loop counter in the retry logic.

Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c43b072 and 978a824.
Files ignored due to path filters (2)
  • poetry.lock is excluded by: !**/*.lock
  • pyproject.toml is excluded by: !**/*.toml
Files selected for processing (4)
  • pandasai/llm/Mistralai.py (1 hunks)
  • tests/integration_tests/test_cricket.py (1 hunks)
  • tests/integration_tests/test_gin.py (1 hunks)
  • tests/integration_tests/test_spotify.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/integration_tests/test_gin.py
Files skipped from review as they are similar to previous changes (1)
  • pandasai/llm/Mistralai.py
Additional comments: 4
tests/integration_tests/test_spotify.py (2)
  • 3-3: The removal of the os import is noted. Ensure that no part of the test file relies on environment variables or file system paths that would require the os module. If such dependencies exist, this change could potentially break the test functionality.
  • 1-3: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [9-9]

The instantiation of SmartDataframe with a file path constructed using PATH_DATA and a configuration for llm appears correct. However, ensure that PATH_DATA is correctly defined and accessible within the test environment, especially since the os import was removed. This might affect the resolution of PATH_DATA if it relies on environment variables or relative paths.

tests/integration_tests/test_cricket.py (2)
  • 3-3: Similar to the previous file, the removal of the os import is noted. Verify that this change does not impact the functionality of the test, especially in terms of accessing file paths or environment variables that might have required the os module.
  • 1-3: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [9-9]

The setup method correctly initializes SmartDataframe with a configuration for llm, similar to the previous file. Ensure that PATH_DATA is correctly defined and accessible, and that the file path used for initializing SmartDataframe is valid and points to an existing CSV file.

Comment on lines 1 to 4
import unittest

from pandasai import SmartDataframe
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [11-34]

The test methods test_number_response, test_plot_response, test_string_response, and test_dataframe_response are well-structured and seem to cover a variety of response types from the SmartDataframe.chat method. However, consider adding assertions for negative test cases or unexpected inputs to ensure robust error handling and validation within the SmartDataframe class.

Comment on lines 1 to 4
import unittest

from pandasai import SmartDataframe
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [11-34]

The test methods in this file, like test_number_response, test_plot_response, test_string_response, and test_dataframe_response, are structured to test various aspects of the SmartDataframe.chat method's functionality. It's recommended to include tests for error handling and edge cases to ensure the resilience and robustness of the SmartDataframe class.

pyproject.toml Outdated
@@ -15,13 +15,13 @@ astor = "^0.8.1"
openai = "<2"
ipython = "^8.13.1"
matplotlib = "^3.7.1"
pydantic = "^1"
pydantic = ">=2.5.2"

Choose a reason for hiding this comment

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

I see you changed the pydantic version from 1 to >2.0 . And I think thats a ground breaking change. Because in Version 2.0 alot of Pydantic 1 changes got deprecated(or the way to use them changed). So I do have doubt by changing the Version to >2.0 will break something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Zidane786 thanks for your review. But mistralai is not working if pydantic is < 2.5.2. Can you suggest me some way for this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gventuri could you also once look into this?

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