Skip to content

Commit

Permalink
Metrics: test deployment without metrics (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
lusmoura authored Jul 11, 2024
1 parent 23c4697 commit a1e9e7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_app():
allow_headers=["*"],
)
app.add_middleware(LoggingMiddleware)
app.add_middleware(MetricsMiddleware)
# app.add_middleware(MetricsMiddleware)

return app

Expand Down
10 changes: 6 additions & 4 deletions src/backend/model_deployments/cohere_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ def list_models(cls) -> List[str]:
def is_available(cls) -> bool:
return all([os.environ.get(var) is not None for var in COHERE_ENV_VARS])

@collect_metrics_chat
# @collect_metrics_chat
async def invoke_chat(self, chat_request: CohereChatRequest, **kwargs: Any) -> Any:
response = self.client.chat(
**chat_request.model_dump(exclude={"stream", "file_ids", "agent_id"}),
)
yield to_dict(response)

@collect_metrics_chat_stream
# @collect_metrics_chat_stream
async def invoke_chat_stream(
self, chat_request: CohereChatRequest, **kwargs: Any
) -> AsyncGenerator[Any, Any]:
Expand All @@ -87,10 +87,12 @@ async def invoke_chat_stream(
for event in stream:
yield to_dict(event)

@collect_metrics_rerank
# @collect_metrics_rerank
async def invoke_rerank(
self, query: str, documents: List[Dict[str, Any]], **kwargs: Any
) -> Any:
return self.client.rerank(
response = self.client.rerank(
query=query, documents=documents, model=DEFAULT_RERANK_MODEL
)

return to_dict(response)

0 comments on commit a1e9e7d

Please sign in to comment.