Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
BeatrixCohere committed Jul 12, 2024
1 parent af08fae commit eb05d57
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/backend/model_deployments/cohere_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
from typing import Any, AsyncGenerator, Dict, List

from backend.services.logger import get_logger, send_log_message
import cohere
import requests
from cohere.core.api_error import ApiError
Expand All @@ -27,6 +28,8 @@
DEFAULT_RERANK_MODEL = "rerank-english-v2.0"


logger = get_logger()

class CohereDeployment(BaseDeployment):
"""Cohere Platform Deployment."""

Expand Down Expand Up @@ -85,6 +88,13 @@ async def invoke_chat_stream(
)

for event in stream:
send_log_message(
logger,
f"Chat event: {to_dict(event)}",
level="info",
conversation_id=kwargs.get("conversation_id"),
user_id=kwargs.get("user_id"),
)
yield to_dict(event)

@collect_metrics_rerank
Expand Down

0 comments on commit eb05d57

Please sign in to comment.