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: add plugin tests #1096

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

feat: add plugin tests #1096

wants to merge 8 commits into from

Conversation

tushar-composio
Copy link
Collaborator

@tushar-composio tushar-composio commented Dec 27, 2024

Important

Add test for input serialization in get_tools() and optimize SentenceTransformer import for lazy loading.

  • Tests:
    • Add test_openai_toolset() in test_plugins.py to test input serialization in get_tools() of ComposioToolSet.
    • Verifies serialization of create_draft action with parameters message_body and thread_id.
    • Checks expected output format including function description, name, and parameter details.
  • Code Changes:
    • Move SentenceTransformer import inside Embedding.__init__() in embedder.py for lazy loading.
  • Misc:
    • Update tox.ini to install multiple plugins in a single command.

This description was created by Ellipsis for 7425b2f. It will automatically update as commits are pushed.

Copy link

vercel bot commented Dec 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 31, 2024 8:43am

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to cf4548c in 32 seconds

More details
  • Looked at 68 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_CG7uX4Xy3xiluGET


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of both type and anyOf for thread_id is inconsistent. Consider removing the type key or ensure it aligns with the anyOf specification.

"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The redundant type definition here could be simplified. Since thread_id is an optional string parameter, we could either:

  1. Remove the type: string and keep only the anyOf definition, or
  2. Use type: ["string", "null"] instead

The current implementation with both type and anyOf is redundant and could cause confusion in schema validation.

from composio import Action, App
from composio.client.enums.base import ActionData
from composio.tools.local.base import action
import composio_openai
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider grouping related imports together and removing unused ones:

from composio import Action, App  # Action is unused
from composio.client.enums.base import ActionData  # ActionData is unused
from composio.tools.local.base import action

# Group plugin imports
import composio_openai
import composio_crewai  # Unused
import composio_langchain  # Unused
import composio_llamaindex  # Unused

This will make the imports cleaner and more maintainable.

@shreysingla11
Copy link
Collaborator

Code Review Summary

The PR adds valuable test coverage for input serialization in the get_tools() method, particularly focusing on the OpenAI toolset implementation. The tests verify proper handling of:

  • Required and optional parameters
  • Parameter type definitions
  • Docstring parsing
  • Tool naming conventions

Suggestions for Improvement:

  1. Clean up imports by removing unused ones and grouping related imports
  2. Simplify the type definition for optional parameters to avoid redundancy
  3. Consider adding more test cases for:
    • Edge cases in parameter types
    • Error scenarios
    • Other runtime implementations beyond OpenAI

Overall, this is a good addition to the test suite that will help ensure consistent parameter handling across different runtime implementations. The code quality is good with room for minor improvements.

Comment on lines 38 to 51
"title": "Message Body",
"type": "string",
},
"thread_id": {
"description": "The ID of the thread to which the reply is to be "
"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
"anyOf": [
{"type": "string"},
{"type": "null"},
],
},

Choose a reason for hiding this comment

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

🤖 Bug Fix:

Redundant Schema Definition for 'thread_id'
The current schema definition for the 'thread_id' field uses both 'type' and 'anyOf', which is redundant and can lead to confusion in schema validation. To improve clarity and avoid potential validation errors, it's recommended to use only 'anyOf' if the intention is to allow both string and null values. This will streamline the schema and ensure consistent behavior.

🔧 Suggested Code Diff:
- "type": "string",
  "anyOf": [
      {"type": "string"},
      {"type": "null"},
  ],
📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
"title": "Message Body",
"type": "string",
},
"thread_id": {
"description": "The ID of the thread to which the reply is to be "
"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
"anyOf": [
{"type": "string"},
{"type": "null"},
],
},
{
"title": "Message Body",
"type": "string",
},
"thread_id": {
"description": "The ID of the thread to which the reply is to be drafted. Please provide a value of type string or null.",
"title": "Thread Id",
"anyOf": [
{"type": "string"},
{"type": "null"},
],
}

@tushar-composio tushar-composio changed the title chore: add tests for input serialization in get_tools() chore: add plugin tests Dec 31, 2024
@tushar-composio tushar-composio changed the title chore: add plugin tests feat: add plugin tests Dec 31, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on b3d0029 in 24 seconds

More details
  • Looked at 34 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. python/composio/tools/local/codeanalysis/embedder.py:51
  • Draft comment:
    Consider the impact of moving the 'SentenceTransformer' import inside the 'init' method. This can reduce initial load time but may delay instantiation.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The import statement for 'SentenceTransformer' was moved inside the 'init' method of the 'Embedding' class. This change is beneficial for reducing the initial load time and memory usage if the 'Embedding' class is not instantiated. However, it should be noted that this can lead to a slight delay when the class is first instantiated, as the import will occur at that time.
2. python/tests/test_tools/test_plugins.py:46
  • Draft comment:
    Remove 'type' when using 'anyOf' to avoid redundancy. Applicable to 'thread_id' and similar cases.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_b80AZGHzjVoSl00g


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Comment on lines +43 to +62
"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
"default": None,
"anyOf": [
{"type": "string"},
{"type": "null"},
],
},
},
"required": [
"message_body",
],
"title": "CreateDraftRequest",
"type": "object",
},
},
"type": "function",
},

Choose a reason for hiding this comment

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

🤖 Bug Fix:

Redundant Type Definition in 'thread_id' Field
The current schema for the 'thread_id' field uses both 'type' and 'anyOf', which is redundant and can lead to confusion. The 'anyOf' construct already specifies that the field can be either a string or null, making the 'type' declaration unnecessary. Removing the 'type' field will simplify the schema and prevent potential validation issues. This change will ensure clarity and maintainability of the code. 🛠️

🔧 Suggested Code Diff:
- "type": "string",
  "anyOf": [
      {"type": "string"},
      {"type": "null"},
  ],
📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
"default": None,
"anyOf": [
{"type": "string"},
{"type": "null"},
],
},
},
"required": [
"message_body",
],
"title": "CreateDraftRequest",
"type": "object",
},
},
"type": "function",
},
{
"thread_id": {
"description": "The ID of the thread to which the reply is to be drafted. Please provide a value of type string.",
"title": "Thread Id",
"default": None,
"anyOf": [
{"type": "string"},
{"type": "null"}
]
}
}

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on ba782b7 in 14 seconds

More details
  • Looked at 49 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. .github/workflows/common.yml:105
  • Draft comment:
    Consider moving the condition if: matrix.python-version == '3.10' to the job level for consistency with other jobs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The addition of the plugin tests in the workflow is a good step, but the condition for running them is not consistent with the rest of the workflow. The condition should be placed on the job level, not the step level, for consistency and clarity.
2. python/tox.ini:124
  • Draft comment:
    The installation of plugins/langchain is redundant here as it is already included in the [testenv:plugins] section. Consider removing it to avoid unnecessary installations.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The tox.ini file has a redundant installation of plugins/langchain in the [testenv:test] section. This is unnecessary because the [testenv:plugins] section already handles plugin installations.

Workflow ID: wflow_PeG3YqkBeAR35hWk


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Comment on lines +43 to +62
"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
"default": None,
"anyOf": [
{"type": "string"},
{"type": "null"},
],
},
},
"required": [
"message_body",
],
"title": "CreateDraftRequest",
"type": "object",
},
},
"type": "function",
},

Choose a reason for hiding this comment

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

🤖 Bug Fix:

Redundant Schema Definition in 'CreateDraftRequest'
The current schema definition for 'CreateDraftRequest' includes both a 'type' field and an 'anyOf' field, which is redundant and can lead to confusion in validation logic. If the intention is to allow both strings and null values, the 'type' field should be removed, and 'anyOf' should be used exclusively. Alternatively, if only strings are allowed, the 'anyOf' field should be removed. This will ensure clarity and correctness in the schema definition.

🔧 Suggested Code Diff:
- "type": "string",
+ // Remove the 'type' field if allowing both strings and null values
📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
"drafted. Please provide a value of type string.",
"title": "Thread Id",
# TODO: this seems wrong, why both type and anyof
"type": "string",
"default": None,
"anyOf": [
{"type": "string"},
{"type": "null"},
],
},
},
"required": [
"message_body",
],
"title": "CreateDraftRequest",
"type": "object",
},
},
"type": "function",
},
{
"CreateDraftRequest": {
"type": "object",
"properties": {
"message_body": {
"anyOf": [
{"type": "string"},
{"type": "null"}
],
"default": None
}
},
"required": [
"message_body"
],
"title": "CreateDraftRequest"
}
}

Comment on lines 121 to +128

; TODO: Extract plugin tests separately
; Installing separately because of the dependency conflicts
uv pip install plugins/langchain --no-deps
uv pip install plugins/langchain

pytest -vvv -rfE --doctest-modules composio/ tests/ swe/tests --junitxml=junit.xml --cov=composio --cov=examples --cov=swe --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc {posargs}
pytest -vvv -rfE --doctest-modules composio/ tests/ swe/tests --ignore tests/test_tools/test_plugins.py --junitxml=junit.xml --cov=composio --cov=examples --cov=swe --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc {posargs}

; uv pip install plugins/autogen
; uv pip install plugins/claude
; uv pip install plugins/crew_ai
; uv pip install plugins/griptape
; uv pip install plugins/julep
; uv pip install plugins/lyzr
; uv pip install plugins/openai

Choose a reason for hiding this comment

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

⚠️ Potential Issue:

Ensure Comprehensive Test Coverage for Excluded Test File
The recent change excludes tests/test_tools/test_plugins.py from the main test suite, which could lead to gaps in test coverage. It's crucial to ensure that this test file is included in a new dedicated job for plugin tests, especially under Python 3.10. This will help maintain comprehensive test coverage and prevent potential bugs from going unnoticed.

Actionable Steps:

  • Verify that tests/test_tools/test_plugins.py is included in a separate test job.
  • Ensure that the new job runs under Python 3.10 to maintain compatibility and coverage.
  • Regularly review test coverage reports to confirm no tests are omitted inadvertently.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e93a7f6 in 10 seconds

More details
  • Looked at 36 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. python/tests/test_tools/test_plugins.py:1
  • Draft comment:
    Remove unused imports to clean up the code. composio_crewai, composio_langchain, and composio_llamaindex are not used in this file.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import statements for unused modules in test_plugins.py should be removed to clean up the code.

Workflow ID: wflow_Qj9d71JEQRYgNIkg


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 7425b2f in 7 seconds

More details
  • Looked at 15 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. python/tox.ini:134
  • Draft comment:
    Combine plugin installations into a single command to improve performance and reduce redundancy.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The tox.ini file has been updated to include environment variables for the plugins test environment, which is a good practice for managing configurations. However, the deps section can be optimized by combining the plugin installations into a single command to improve performance.

Workflow ID: wflow_c8wdNMY7z9PIs7EG


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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