Skip to content

Commit

Permalink
Merge branch 'main' into coral-web-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tianjing-li authored Jan 14, 2025
2 parents 07ed6d1 + 802c232 commit 13d2667
Show file tree
Hide file tree
Showing 126 changed files with 11,859 additions and 11,772 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from alembic import op

from backend.database_models.seeders.deplyments_models_seed import (
from backend.database_models.seeders.deployments_models_seed import (
delete_default_models,
deployments_models_seed,
)
Expand Down
29 changes: 9 additions & 20 deletions src/backend/chat/custom/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from typing import Any

from backend.config.deployments import (
AVAILABLE_MODEL_DEPLOYMENTS,
get_default_deployment,
)
from backend.database_models.database import get_session
from backend.exceptions import DeploymentNotFoundError
from backend.model_deployments.base import BaseDeployment
from backend.schemas.context import Context
from backend.services import deployment as deployment_service


def get_deployment(name: str, ctx: Context, **kwargs: Any) -> BaseDeployment:
Expand All @@ -16,22 +15,12 @@ def get_deployment(name: str, ctx: Context, **kwargs: Any) -> BaseDeployment:
Returns:
BaseDeployment: Deployment implementation instance based on the deployment name.
Raises:
ValueError: If the deployment is not supported.
"""
kwargs["ctx"] = ctx
deployment = AVAILABLE_MODEL_DEPLOYMENTS.get(name)

# Check provided deployment against config const
if deployment is not None:
return deployment.deployment_class(**kwargs, **deployment.kwargs)

# Fallback to first available deployment
default = get_default_deployment(**kwargs)
if default is not None:
return default
try:
session = next(get_session())
deployment = deployment_service.get_deployment_by_name(session, name, **kwargs)
except DeploymentNotFoundError:
deployment = deployment_service.get_default_deployment(**kwargs)

raise ValueError(
f"Deployment {name} is not supported, and no available deployments were found."
)
return deployment
4 changes: 2 additions & 2 deletions src/backend/config/default_agent.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import datetime

from backend.config.deployments import ModelDeploymentName
from backend.config.tools import Tool
from backend.model_deployments.cohere_platform import CohereDeployment
from backend.schemas.agent import AgentPublic

DEFAULT_AGENT_ID = "default"
DEFAULT_DEPLOYMENT = ModelDeploymentName.CoherePlatform
DEFAULT_DEPLOYMENT = CohereDeployment.name()
DEFAULT_MODEL = "command-r-plus"

def get_default_agent() -> AgentPublic:
Expand Down
Loading

0 comments on commit 13d2667

Please sign in to comment.