Skip to content

Commit

Permalink
Add all plugins in examples tests (#394)
Browse files Browse the repository at this point in the history
Add all plugins in examples tests
  • Loading branch information
kaavee315 authored Jul 26, 2024
1 parent 92b4085 commit 74408b3
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/plugins/crew_ai/crewai_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
)

# Execute task
task.execute()
task.execute_sync()
6 changes: 5 additions & 1 deletion python/plugins/julep/julep_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@
)

# Execute function calls
print(composio_toolset.handle_tool_calls(response)) # type: ignore
print(
composio_toolset.handle_tool_calls(
response=response, session_id=session.id, julep_client=client
)
)
9 changes: 2 additions & 7 deletions python/plugins/openai/openai_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dotenv
from openai import OpenAI

from composio_openai import Action, App, ComposioToolSet
from composio_openai import App, ComposioToolSet


# Load environment variables from .env
Expand All @@ -23,12 +23,7 @@

# Extension of system prompt(Not using at this moment)
_ = composio_toolset.get_agent_instructions(
apps=[App.GMAIL],
actions=[
Action.MATHEMATICAL_CALCULATOR,
Action.GITHUB_ACTIONS_ADD_CUSTOM_LABELS_TO_SELF_HOSTED_RUNNER_FOR_ORG,
Action.ASANA_ALLOCATIONS_DELETE_ALLOCATION_BY_ID,
],
apps=[App.GITHUB],
)

# Get response from the LLM
Expand Down
95 changes: 88 additions & 7 deletions python/tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
# Require env vars
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
COMPOSIO_API_KEY = os.environ.get("COMPOSIO_API_KEY")
JULEP_API_KEY = os.environ.get("JULEP_API_KEY")
JULEP_API_URL = os.environ.get("JULEP_API_URL")

# Plugin test definitions
EXAMPLES = (
{
EXAMPLES = {
"autogen": {
"file": PLUGINS / "autogen" / "autogen_demo.py",
"match": {
"type": "stdout",
Expand All @@ -33,7 +35,7 @@
"COMPOSIO_API_KEY": COMPOSIO_API_KEY,
},
},
{
"llamaindex": {
"file": PLUGINS / "llamaindex" / "llamaindex_demo.py",
"match": {
"type": "stdout",
Expand All @@ -46,7 +48,7 @@
"COMPOSIO_API_KEY": COMPOSIO_API_KEY,
},
},
{
"local_tools": {
"file": EXAMPLES_PATH / "local_tools" / "autogen_math.py",
"match": {
"type": "stdout",
Expand All @@ -56,15 +58,94 @@
},
"env": {"OPENAI_API_KEY": OPENAI_API_KEY},
},
)
"crewai": {
"file": PLUGINS / "crew_ai" / "crewai_demo.py",
"match": {
"type": "stdout",
"values": [
"{'execution_details': {'executed': True}, 'response_data': ''}"
],
},
"env": {
"OPENAI_API_KEY": OPENAI_API_KEY,
"COMPOSIO_API_KEY": COMPOSIO_API_KEY,
},
},
"julep": {
"file": PLUGINS / "julep" / "julep_demo.py",
"match": {
"type": "stdout",
"values": ["finish_reason=<ChatResponseFinishReason.STOP: 'stop'>"],
},
"env": {
"OPENAI_API_KEY": OPENAI_API_KEY,
"COMPOSIO_API_KEY": COMPOSIO_API_KEY,
"JULEP_API_KEY": JULEP_API_KEY,
"JULEP_API_URL": JULEP_API_URL,
},
},
"langchain": {
"file": PLUGINS / "langchain" / "langchain_demo.py",
"match": {
"type": "stdout",
"values": [
"{'execution_details': {'executed': True}, 'response_data': ''}"
],
},
"env": {"OPENAI_API_KEY": OPENAI_API_KEY, "COMPOSIO_API_KEY": COMPOSIO_API_KEY},
},
"langgraph": {
"file": PLUGINS / "langgraph" / "langgraph_demo.py",
"match": {
"type": "stdout",
"values": [
"{'execution_details': {'executed': True}, 'response_data': ''}"
],
},
"env": {"OPENAI_API_KEY": OPENAI_API_KEY, "COMPOSIO_API_KEY": COMPOSIO_API_KEY},
},
"openai": {
"file": PLUGINS / "openai" / "openai_demo.py",
"match": {
"type": "stdout",
"values": [
"{'execution_details': {'executed': True}, 'response_data': ''}"
],
},
"env": {"OPENAI_API_KEY": OPENAI_API_KEY, "COMPOSIO_API_KEY": COMPOSIO_API_KEY},
},
"lyzr": {
"file": PLUGINS / "lyzr" / "lyzr_demo.py",
"match": {
"type": "stdout",
"values": [
"{'execution_details': {'executed': True}, 'response_data': ''}"
],
},
"env": {"OPENAI_API_KEY": OPENAI_API_KEY, "COMPOSIO_API_KEY": COMPOSIO_API_KEY},
},
"praisonai": {
"file": PLUGINS / "praisonai" / "praisonai_demo.py",
"match": {
"type": "stdout",
"values": [
"{'execution_details': {'executed': True}, 'response_data': ''}"
],
},
"env": {"OPENAI_API_KEY": OPENAI_API_KEY, "COMPOSIO_API_KEY": COMPOSIO_API_KEY},
}
# TODO: Fix and add claude, camel
}


@pytest.mark.skipif(
condition=os.environ.get("CI") is not None,
reason="Testing in CI will lead to too much LLM API usage",
)
@pytest.mark.parametrize("example", EXAMPLES)
def test_example(example: dict) -> None:
@pytest.mark.parametrize("example_name, example", EXAMPLES.items())
def test_example(
example_name: str, example: dict # pylint: disable=unused-argument
) -> None:
"""Test an example with given environment."""
for key, val in example["env"].items():
assert (
Expand Down

0 comments on commit 74408b3

Please sign in to comment.