Skip to content

Commit

Permalink
Merge latest main and fix a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malexw committed Nov 22, 2024
2 parents 6b8025e + 85de86a commit 87d4367
Show file tree
Hide file tree
Showing 138 changed files with 2,417 additions and 2,480 deletions.
1 change: 0 additions & 1 deletion .github/workflows/backend_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Backend - Integration tests
on:
push:
branches: [main]
merge_group: {}

jobs:
pytest:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/backend_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request: {}
merge_group: {}

jobs:
pytest:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/frontend_assistants_web_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
paths:
- src/interfaces/assistants_web/**
pull_request: {}
merge_group: {}

jobs:
interface_tests:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/frontend_coral_web_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
paths:
- src/interfaces/coral_web/**
pull_request: {}
merge_group: {}

jobs:
interface_tests:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/frontend_slack_bot_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
paths:
- src/interfaces/slack_bot/**
pull_request: {}
merge_group: {}

jobs:
interface_tests:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ down:

.PHONY: run-unit-tests
run-unit-tests:
poetry run pytest src/backend/tests/unit --cov=src/backend --cov-report=xml
poetry run pytest src/backend/tests/unit/$(file) --cov=src/backend --cov-report=xml

.PHONY: run-community-tests
run-community-tests:
Expand Down
2 changes: 0 additions & 2 deletions docs/config_details/config_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
- redis - Redis configurations
- url - URL of the redis, for example, redis://:redis@redis:6379
- tools - Tool configurations
- enabled_tools - these are the tools that are enabled for the toolkit. The full list of tools can be found in the src/backend/config/tools.py file.
The community tools are listed in the src/community/config/tools.py file. Please note that the tools availability is checked too.
- python_interpreter - Python interpreter configurations
- url - URL of the python interpreter tool
- feature_flags - Feature flags configurations
Expand Down
4 changes: 2 additions & 2 deletions docs/custom_tool_guides/slack.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SLACK_CLIENT_SECRET=<your_client_secret from step 1>

## 4. Enable the Slack Tool in the Frontend

To enable the Slack tool in the frontend, you will need to modify the `src/community/config/tools.py` file. Add the `TOOL_SLACK_ID` to the `AGENT_SETTINGS_TOOLS` list.
To enable the Slack tool in the frontend, you will need to modify the `src/interfaces/assistants_web/src/constants/tools.ts` file. Add the `TOOL_SLACK_ID` to the `AGENT_SETTINGS_TOOLS` list.

```typescript
export const AGENT_SETTINGS_TOOLS = [
Expand All @@ -58,7 +58,7 @@ export const AGENT_SETTINGS_TOOLS = [
];
```

To enable the Slack tool in the frontend for Base Agent, you will need to modify the `src/community/config/tools.py` file. Remove the `TOOL_SLACK_ID` from the `BASE_AGENT_EXCLUDED_TOOLS` list.
To enable the Slack tool in the frontend for Base Agent, you will need to modify the `src/interfaces/assistants_web/src/constants/tools.ts` file. Remove the `TOOL_SLACK_ID` from the `BASE_AGENT_EXCLUDED_TOOLS` list.
By default, the Slack Tool is disabled for the Base Agent. Also if you need to exclude some tool from the Base Agent just add it to the `BASE_AGENT_EXCLUDED_TOOLS` list.
```typescript
export const BASE_AGENT_EXCLUDED_TOOLS = [];
Expand Down
50 changes: 23 additions & 27 deletions docs/custom_tool_guides/tool_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from community.tools import BaseTool


class ArxivRetriever(BaseTool):
NAME = "arxiv"
ID = "arxiv"

def __init__(self):
self.client = ArxivAPIWrapper()
Expand All @@ -64,6 +64,27 @@ class ArxivRetriever(BaseTool):
def is_available(cls) -> bool:
return True

@classmethod
# You will need to add a tool definition here
def get_tool_definition(cls) -> ToolDefinition:
return ToolDefinition(
name=cls.ID,
display_name="Arxiv",
implementation=cls,
parameter_definitions={
"query": {
"description": "Query for retrieval.",
"type": "str",
"required": True,
}
},
is_visible=False,
is_available=cls.is_available(),
error_message=cls.generate_error_message(),
category=ToolCategory.DataLoader,
description="Retrieves documents from Arxiv.",
)

# Your tool needs to implement this call() method
def call(self, parameters: str, **kwargs: Any) -> List[Dict[str, Any]]:
result = self.client.run(parameters)
Expand All @@ -84,34 +105,9 @@ return [{"text": "The fox is blue", "url": "wikipedia.org/foxes", "title": "Colo

Next, add your tool class to the init file by locating it in `src/community/tools/__init__.py`. Import your tool here, then add it to the `__all__` list.

To enable your tool, you will need to go to the `configuration.yaml` file and add your tool's name to the list of `enabled_tools`. This tool name will correspond to the one defined in the `NAME` attribute of your class.

Finally, you will need to add your tool definition to the config file. Locate it in `src/community/config/tools.py`, and import your tool at the top with `from backend.tools import ..`.

In the ToolName enum, add your tool as an enum value. For example, `My_Tool = MyTool.NAME`.

In the `ALL_TOOLS` dictionary, add your tool definition. This should look like:

```python
ToolName.My_Tool: ManagedTool( # THE TOOLNAME HERE CORRESPONDS TO THE ENUM YOU DEFINED EARLIER
display_name="My Tool",
implementation=MyTool, # THIS IS THE CLASS YOU IMPORTED AT THE TOP
parameter_definitions={ # THESE ARE PARAMS THE MODEL WILL SEND TO YOUR TOOL, ADJUST AS NEEDED
"query": {
"description": "Query to search with",
"type": "str",
"required": True,
}
},
is_visible=True,
is_available=MyTool.is_available(),
auth_implementation=None, # EMPTY IF NO AUTH NEEDED
error_message="Something went wrong",
category=Category.DataLoader, # CHECK CATEGORY ENUM FOR POSSIBLE VALUES
description="An example definition to get you started.",
),
```

Finally, to enable your tool, add your tool as an enum value. For example, `My_Tool = MyToolClass`.

## Step 5: Test Your Tool!

Expand Down
2 changes: 1 addition & 1 deletion docs/how_to_guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The core chat interface is the Coral frontend. To implement your own interface:
If you have already created a [connector](https://docs.cohere.com/docs/connectors), you can utilize it within the toolkit by following these steps:

1. Configure your connector using `ConnectorRetriever`.
2. Add its definition in [community/config/tools.py](https://github.com/cohere-ai/cohere-toolkit/blob/main/src/community/config/tools.py), following the `Arxiv` implementation, using the category `Category.DataLoader`.
2. Add its definition in [community/config/tools.py](https://github.com/cohere-ai/cohere-toolkit/blob/main/src/community/config/tools.py), following the `Arxiv` implementation, using the category `ToolCategory.DataLoader`.

You can now use both the Coral frontend and API with your connector.

Expand Down
Loading

0 comments on commit 87d4367

Please sign in to comment.