Skip to content

Commit

Permalink
feat: make cohere optional
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelrince committed Apr 15, 2024
1 parent 25e7f68 commit dfcfa80
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 98 deletions.
18 changes: 14 additions & 4 deletions ecologits/tracers/cohere_tracer.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import time
from typing import Any, AsyncIterator, Callable, Iterator

from cohere import AsyncClient, Client
from cohere.types.non_streamed_chat_response import NonStreamedChatResponse as _NonStreamedChatResponse
from cohere.types.streamed_chat_response import StreamedChatResponse
from cohere.types.streamed_chat_response import StreamedChatResponse_StreamEnd as _StreamedChatResponse_StreamEnd
from wrapt import wrap_function_wrapper

from ecologits.impacts import Impacts
from ecologits.tracers.utils import compute_llm_impacts

try:

This comment has been minimized.

Copy link
@adrienbanse

adrienbanse Apr 15, 2024

Member

@samuelrince Shouldn't we do this for OpenAI as well?

from cohere import AsyncClient, Client
from cohere.types.non_streamed_chat_response import NonStreamedChatResponse as _NonStreamedChatResponse
from cohere.types.streamed_chat_response import StreamedChatResponse
from cohere.types.streamed_chat_response import StreamedChatResponse_StreamEnd as _StreamedChatResponse_StreamEnd
except ImportError:
Client = object()
AsyncClient = object()
_NonStreamedChatResponse = object()
StreamedChatResponse = object()
_StreamedChatResponse_StreamEnd = object()


PROVIDER = "cohere"


class NonStreamedChatResponse(_NonStreamedChatResponse):
impacts: Impacts

Expand Down
Loading

0 comments on commit dfcfa80

Please sign in to comment.