Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tianjing-li committed Jan 10, 2025
2 parents 7316a98 + 5f83438 commit ae6a2d8
Show file tree
Hide file tree
Showing 22 changed files with 5,594 additions and 8,054 deletions.
12 changes: 6 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Thank you for contributing to the Cohere Toolkit!

- [ ] **PR title**: "area: description"

- Where "area" is whichever of interface, frontend, model, tools, backend, etc. is being modified. Use "docs: ..." for purely docs changes, "infra: ..." for CI changes.
- Example: "deployment: add Azure model option"

- [ ] **PR message**: **_Delete this entire checklist_** and replace with

- [ ] **PR message**: ***Delete this entire checklist*** and replace with
- **Description:** a description of the change
- **Issue:** the issue # it fixes, if applicable
- **Dependencies:** any dependencies required for this change

- **Description:** a description of the change
- **Issue:** the issue # it fixes, if applicable
- **Dependencies:** any dependencies required for this change

- [ ] **Add tests and docs**: Please include testing and documentation for your changes
- [ ] **Lint and test**: Run `make lint` and `make run-tests`
- [ ] **Lint and test**: Run `make lint` and `make run-unit-tests`

**AI Description**

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backend_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Test with pytest
if: github.actor != 'dependabot[bot]'
run: |
make run-unit-tests
make run-unit-tests-debug
env:
PYTHONPATH: src
- name: Upload coverage reports to Codecov
Expand Down
6 changes: 3 additions & 3 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @cohere-ai/toolkit @EugeneLightsOn @malexw @scottmx81 @tianjing-li
src/interfaces/coral_web @tomtobac @abimacarmes @knajjars @BeatrixCohere @tianjing-li @EugeneLightsOn @malexw
src/interfaces/assistants_web @tomtobac @abimacarmes @knajjars @BeatrixCohere @tianjing-li @EugeneLightsOn @malexw
* @cohere-ai/toolkit @EugeneLightsOn @malexw @tianjing-li @ezawadski
src/interfaces/coral_web @tomtobac @abimacarmes @knajjars @BeatrixCohere @tianjing-li @EugeneLightsOn @ezawadski
src/interfaces/assistants_web @tomtobac @abimacarmes @knajjars @BeatrixCohere @tianjing-li @EugeneLightsOn @ezawadski
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Build & Run
.PHONY: dev
dev:
make check-config
make -j 2 watch up

.PHONY: watch
watch:
@docker compose watch --no-up
Expand Down Expand Up @@ -39,10 +40,18 @@ exec-terrarium:
# Testing & Linting
.PHONY: run-unit-tests
run-unit-tests:
poetry run pytest -n auto src/backend/tests/unit/$(file) --cov=src/backend --cov-report=xml

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

.PHONY: run-community-tests
run-community-tests:
poetry run pytest -n auto src/community/tests/$(file) --cov=src/community --cov-report=xml

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

.PHONY: run-integration-tests
Expand Down Expand Up @@ -105,11 +114,15 @@ win-setup:
poetry install --with setup --verbose
poetry run python src/backend/scripts/cli/main.py

.PHONY: check-config
check-config:
.PHONY: check-config-install
check-config-install:
poetry install --with setup --verbose
poetry run python src/backend/scripts/config/check_config.py

.PHONY: check-config
check-config:
poetry run python src/backend/scripts/config/check_config.py

.PHONY: first-run
first-run:
make setup
Expand Down
79 changes: 57 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "~3.11"
fastapi = "^0.109.2"
fastapi = "0.115.5"
uvicorn = { extras = ["standard"], version = "^0.27.1" }
sqlalchemy = "^2.0.26"
pydantic = "^2.6.4"
Expand All @@ -19,15 +19,15 @@ alembic = "^1.13.1"
psycopg2 = "^2.9.9"
psycopg2-binary = "^2.9.9"
python-multipart = "^0.0.18"
sse-starlette = "^2.0.0"
sse-starlette = "2.1.3"
boto3 = "^1.0.0"
httpx = {extras = ["http2"], version = "^0.27.0"}
chromadb = "^0.4.16"
cohere = "^5.5.7"
inquirer = "^3.2.4"
langchain = "0.2.15"
langchain = "0.2.17"
langchain-cohere = "^0.1.1"
langchain-community = "0.2.15"
langchain-community = "0.2.19"
py-expression-eval = "^0.3.14"
tavily-python = "^0.3.3"
arxiv = "^2.1.0"
Expand Down Expand Up @@ -73,6 +73,7 @@ freezegun = "^1.5.1"
pre-commit = "^2.20.0"
ruff = "^0.6.0"
pytest-asyncio = "^0.23.7"
pytest-xdist = "^3.6.1"

[tool.poetry.group.setup]
optional = true
Expand All @@ -83,11 +84,11 @@ inquirer = "3.2.4"
python-dotenv = "1.0.1"
cohere = "^5.0.2"
sqlalchemy = "^2.0.26"
fastapi = "^0.109.2"
fastapi = "0.115.5"
psycopg2 = "^2.9.9"
boto3 = "^1.0.0"
py-expression-eval = "^0.3.14"
langchain = "0.2.15"
langchain = "0.2.17"
langchain-cohere = "^0.1.1"
tavily-python = "^0.3.3"

Expand Down
4 changes: 2 additions & 2 deletions src/backend/tests/unit/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Writing Unit Test
# Writing Unit Tests

This README will explain how to best write unit tests for the OSS Toolkit project.

Expand All @@ -10,7 +10,7 @@ make test-db
make run-unit-tests
```

## Test DB
## Testing the Database

Some of the unit tests rely on a database being present. The tests are expecting a postgres DB to be running in a docker container. the `make test-db` target will create the test database required for the tests to run.

Expand Down
21 changes: 10 additions & 11 deletions src/backend/tests/unit/routers/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,16 @@ def test_fail_create_user_missing_fullname(
response_user = response.json()

assert response.status_code == 422
assert "detail" in response_user
assert len(response_user["detail"]) == 1

error_detail = response_user["detail"][0]
assert error_detail["type"] == "missing"
assert error_detail["loc"] == ["body", "fullname"]
assert error_detail["msg"] == "Field required"
assert error_detail["input"] == {}
assert "url" in error_detail
assert isinstance(error_detail["url"], str)
assert error_detail["url"]
assert response_user == {
"detail": [
{
"type": "missing",
"loc": ["body", "fullname"],
"msg": "Field required",
"input": {},
}
]
}


def test_update_user(session_client: TestClient, session: Session) -> None:
Expand Down
5 changes: 3 additions & 2 deletions src/backend/tests/unit/tools/test_lang_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from backend.services.context import Context
from backend.tools import LangChainVectorDBRetriever, LangChainWikiRetriever
from backend.tools.base import ToolError, ToolErrorCode

is_cohere_env_set = (
os.environ.get("COHERE_API_KEY") is not None
Expand Down Expand Up @@ -78,7 +79,7 @@ async def test_wiki_retriever_no_docs() -> None:
):
result = await retriever.call({"query": query}, ctx)

assert result == [{'details': '','success': False,'text': 'No results found.','type': 'other'}]
assert result == ToolError(type=ToolErrorCode.OTHER, success=False, text='No results found.', details='No results found for the given params.')



Expand Down Expand Up @@ -164,4 +165,4 @@ async def test_vector_db_retriever_no_docs() -> None:
mock_db.as_retriever().get_relevant_documents.return_value = mock_docs
result = await retriever.call({"query": query}, ctx)

assert result == [{'details': '', 'success': False, 'text': 'No results found.', 'type': 'other'}]
assert result == ToolError(type=ToolErrorCode.OTHER, success=False, text='No results found.', details='No results found for the given params.')
2 changes: 1 addition & 1 deletion src/backend/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _get_class_specific_preamble(cls, tool_class_id):
preamble = f"If you decide to use the toolkit_python_interpreter tool and plan to plot something, try returning the result as a PNG. Ensure that the generated code does not require an internet connection. Avoid using the following packages in code generation: {forbidden_preamble_packages}. "
return preamble
except Exception as e:
logger.error(f"Error while retrieving the Python interpreter preamble.: {str(e)}")
logger.error(event=f"Error while retrieving the Python interpreter preamble: {str(e)}")
return None

return None
Expand Down
Loading

0 comments on commit ae6a2d8

Please sign in to comment.