Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into eugene1/tlk-2622-instantiate-fast…
Browse files Browse the repository at this point in the history
…api-app-once-when-building-test-fixtures

# Conflicts:
#	src/backend/main.py
  • Loading branch information
EugeneLightsOn committed Jan 15, 2025
2 parents d96ac00 + 6a81440 commit e80c0a6
Show file tree
Hide file tree
Showing 62 changed files with 7,694 additions and 3,228 deletions.
5 changes: 2 additions & 3 deletions src/backend/chat/enums.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from enum import Enum
from enum import StrEnum


class StreamEvent(str, Enum):
class StreamEvent(StrEnum):
"""
Stream Events returned by Cohere's chat stream response.
"""

STREAM_START = "stream-start"
SEARCH_QUERIES_GENERATION = "search-queries-generation"
SEARCH_RESULTS = "search-results"
Expand Down
12 changes: 12 additions & 0 deletions src/backend/config/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class RouterName(StrEnum):
CONVERSATION = "conversation"
DEPLOYMENT = "deployment"
EXPERIMENTAL_FEATURES = "experimental_features"
ORGANIZATION = "organization"
TOOL = "tool"
USER = "user"
AGENT = "agent"
Expand Down Expand Up @@ -90,6 +91,17 @@ class RouterName(StrEnum):
Depends(validate_organization_header),
],
},
RouterName.ORGANIZATION: {
"default": [
Depends(get_session),
Depends(validate_organization_header),
],
"auth": [
Depends(get_session),
Depends(validate_authorization),
Depends(validate_organization_header),
],
},
RouterName.TOOL: {
"default": [
Depends(get_session),
Expand Down
16 changes: 14 additions & 2 deletions src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
ORIGINS = ["*"]


_RELEASE_VERSION = "v1.1.5"


@asynccontextmanager
async def lifespan(app: FastAPI):
# Retrieves all the Auth provider endpoints if authentication is enabled.
Expand All @@ -55,7 +58,12 @@ async def lifespan(app: FastAPI):


def create_app() -> FastAPI:
app = FastAPI(lifespan=lifespan)
app = FastAPI(
title="Cohere Toolkit API",
description="This is the API for the Open Source Cohere Toolkit",
version=_RELEASE_VERSION,
lifespan=lifespan,
)

routers = [
auth_router,
Expand Down Expand Up @@ -151,7 +159,11 @@ async def health():
return {"status": "OK"}


@app.post("/migrate", dependencies=[Depends(verify_migrate_token)])
@app.post(
"/migrate",
dependencies=[Depends(verify_migrate_token)],
include_in_schema=False,
)
async def apply_migrations():
"""
Applies Alembic migrations - useful for serverless applications
Expand Down
Loading

0 comments on commit e80c0a6

Please sign in to comment.