-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added Mistral LLM #919
Conversation
WalkthroughThe update introduces the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
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 fromLLM
, aligning with the objective to integrate Mistral LLM into the project. This inheritance ensures thatMistralai
adheres to the expected interface and behavior of language model classes within the project.- 28-33: The approach to obtaining the
api_token
fromkwargs
or environment variables is robust, ensuring flexibility in configuration. However, the explicit check forNone
and raising anAPIKeyNotFoundError
if not found is a good practice for early error detection and clear error messaging.
There was a problem hiding this 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? ✨
There was a problem hiding this 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
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 theos
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 usingPATH_DATA
and a configuration forllm
appears correct. However, ensure thatPATH_DATA
is correctly defined and accessible within the test environment, especially since theos
import was removed. This might affect the resolution ofPATH_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 theos
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 forllm
, similar to the previous file. Ensure thatPATH_DATA
is correctly defined and accessible, and that the file path used for initializingSmartDataframe
is valid and points to an existing CSV file.
import unittest | ||
|
||
from pandasai import SmartDataframe |
There was a problem hiding this comment.
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.
import unittest | ||
|
||
from pandasai import SmartDataframe |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Summary by CodeRabbit