generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from dataforgoodfr/feat/anthropic-tracer
Implement tracer mode with tests
- Loading branch information
Showing
19 changed files
with
751 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
install: | ||
poetry install --all-extras --with dev,docs | ||
|
||
test: | ||
poetry run pytest | ||
|
||
test-record: | ||
poetry run pytest --record-mode=once |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from genai_impact.client import Anthropic, MistralClient, OpenAI | ||
from .tracer import Tracer | ||
|
||
__all__ = ["OpenAI", "MistralClient", "Anthropic"] | ||
__all__ = ["Tracer"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import importlib.util | ||
|
||
|
||
class Tracer: | ||
|
||
@staticmethod | ||
def init() -> None: | ||
init_instruments() | ||
|
||
|
||
def init_instruments() -> None: | ||
init_openai_instrumentor() | ||
init_anthropic_instrumentor() | ||
init_mistralai_instrumentor() | ||
|
||
|
||
def init_openai_instrumentor() -> None: | ||
if importlib.util.find_spec("openai") is not None: | ||
from genai_impact.tracers.openai_tracer import OpenAIInstrumentor | ||
|
||
instrumentor = OpenAIInstrumentor() | ||
instrumentor.instrument() | ||
|
||
|
||
def init_anthropic_instrumentor() -> None: | ||
if importlib.util.find_spec("anthropic") is not None: | ||
from genai_impact.tracers.anthropic_tracer import AnthropicInstrumentor | ||
|
||
instrumentor = AnthropicInstrumentor() | ||
instrumentor.instrument() | ||
|
||
|
||
def init_mistralai_instrumentor() -> None: | ||
if importlib.util.find_spec("mistralai") is not None: | ||
from genai_impact.tracers.mistralai_tracer import MistralAIInstrumentor | ||
|
||
instrumentor = MistralAIInstrumentor() | ||
instrumentor.instrument() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.