judgeval 0.16.0__py3-none-any.whl → 0.16.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- judgeval/api/api_types.py +2 -1
- judgeval/data/judgment_types.py +2 -1
- judgeval/logger.py +1 -1
- judgeval/tracer/__init__.py +10 -7
- judgeval/tracer/keys.py +7 -3
- judgeval/tracer/llm/__init__.py +2 -1259
- judgeval/tracer/llm/config.py +110 -0
- judgeval/tracer/llm/constants.py +10 -0
- judgeval/tracer/llm/llm_anthropic/__init__.py +3 -0
- judgeval/tracer/llm/llm_anthropic/wrapper.py +611 -0
- judgeval/tracer/llm/llm_google/__init__.py +0 -0
- judgeval/tracer/llm/llm_google/config.py +24 -0
- judgeval/tracer/llm/llm_google/wrapper.py +426 -0
- judgeval/tracer/llm/llm_groq/__init__.py +0 -0
- judgeval/tracer/llm/llm_groq/config.py +23 -0
- judgeval/tracer/llm/llm_groq/wrapper.py +477 -0
- judgeval/tracer/llm/llm_openai/__init__.py +3 -0
- judgeval/tracer/llm/llm_openai/wrapper.py +637 -0
- judgeval/tracer/llm/llm_together/__init__.py +0 -0
- judgeval/tracer/llm/llm_together/config.py +23 -0
- judgeval/tracer/llm/llm_together/wrapper.py +478 -0
- judgeval/tracer/llm/providers.py +5 -5
- judgeval/tracer/processors/__init__.py +1 -1
- judgeval/trainer/console.py +1 -1
- judgeval/utils/decorators/__init__.py +0 -0
- judgeval/utils/decorators/dont_throw.py +21 -0
- judgeval/utils/{decorators.py → decorators/use_once.py} +0 -11
- judgeval/utils/meta.py +1 -1
- judgeval/utils/version_check.py +1 -1
- judgeval/version.py +1 -1
- {judgeval-0.16.0.dist-info → judgeval-0.16.1.dist-info}/METADATA +1 -1
- {judgeval-0.16.0.dist-info → judgeval-0.16.1.dist-info}/RECORD +37 -23
- judgeval/tracer/llm/google/__init__.py +0 -21
- judgeval/tracer/llm/groq/__init__.py +0 -20
- judgeval/tracer/llm/together/__init__.py +0 -20
- /judgeval/tracer/llm/{anthropic/__init__.py → llm_anthropic/config.py} +0 -0
- /judgeval/tracer/llm/{openai/__init__.py → llm_openai/config.py} +0 -0
- {judgeval-0.16.0.dist-info → judgeval-0.16.1.dist-info}/WHEEL +0 -0
- {judgeval-0.16.0.dist-info → judgeval-0.16.1.dist-info}/entry_points.txt +0 -0
- {judgeval-0.16.0.dist-info → judgeval-0.16.1.dist-info}/licenses/LICENSE.md +0 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING
|
3
|
+
from judgeval.logger import judgeval_logger
|
4
|
+
|
5
|
+
from judgeval.tracer.llm.constants import ProviderType
|
6
|
+
from judgeval.tracer.llm.providers import (
|
7
|
+
HAS_OPENAI,
|
8
|
+
HAS_TOGETHER,
|
9
|
+
HAS_ANTHROPIC,
|
10
|
+
HAS_GOOGLE_GENAI,
|
11
|
+
HAS_GROQ,
|
12
|
+
ApiClient,
|
13
|
+
)
|
14
|
+
|
15
|
+
if TYPE_CHECKING:
|
16
|
+
from judgeval.tracer import Tracer
|
17
|
+
|
18
|
+
|
19
|
+
def _detect_provider(client: ApiClient) -> ProviderType:
|
20
|
+
if HAS_OPENAI:
|
21
|
+
from judgeval.tracer.llm.providers import openai_OpenAI, openai_AsyncOpenAI
|
22
|
+
|
23
|
+
assert openai_OpenAI is not None, "OpenAI client not found"
|
24
|
+
assert openai_AsyncOpenAI is not None, "OpenAI async client not found"
|
25
|
+
if isinstance(client, (openai_OpenAI, openai_AsyncOpenAI)):
|
26
|
+
return ProviderType.OPENAI
|
27
|
+
|
28
|
+
if HAS_ANTHROPIC:
|
29
|
+
from judgeval.tracer.llm.providers import (
|
30
|
+
anthropic_Anthropic,
|
31
|
+
anthropic_AsyncAnthropic,
|
32
|
+
)
|
33
|
+
|
34
|
+
assert anthropic_Anthropic is not None, "Anthropic client not found"
|
35
|
+
assert anthropic_AsyncAnthropic is not None, "Anthropic async client not found"
|
36
|
+
if isinstance(client, (anthropic_Anthropic, anthropic_AsyncAnthropic)):
|
37
|
+
return ProviderType.ANTHROPIC
|
38
|
+
|
39
|
+
if HAS_TOGETHER:
|
40
|
+
from judgeval.tracer.llm.providers import (
|
41
|
+
together_Together,
|
42
|
+
together_AsyncTogether,
|
43
|
+
)
|
44
|
+
|
45
|
+
assert together_Together is not None, "Together client not found"
|
46
|
+
assert together_AsyncTogether is not None, "Together async client not found"
|
47
|
+
if isinstance(client, (together_Together, together_AsyncTogether)):
|
48
|
+
return ProviderType.TOGETHER
|
49
|
+
|
50
|
+
if HAS_GOOGLE_GENAI:
|
51
|
+
from judgeval.tracer.llm.providers import (
|
52
|
+
google_genai_Client,
|
53
|
+
google_genai_AsyncClient,
|
54
|
+
)
|
55
|
+
|
56
|
+
assert google_genai_Client is not None, "Google GenAI client not found"
|
57
|
+
assert google_genai_AsyncClient is not None, (
|
58
|
+
"Google GenAI async client not found"
|
59
|
+
)
|
60
|
+
if isinstance(client, (google_genai_Client, google_genai_AsyncClient)):
|
61
|
+
return ProviderType.GOOGLE
|
62
|
+
|
63
|
+
if HAS_GROQ:
|
64
|
+
from judgeval.tracer.llm.providers import groq_Groq, groq_AsyncGroq
|
65
|
+
|
66
|
+
assert groq_Groq is not None, "Groq client not found"
|
67
|
+
assert groq_AsyncGroq is not None, "Groq async client not found"
|
68
|
+
if isinstance(client, (groq_Groq, groq_AsyncGroq)):
|
69
|
+
return ProviderType.GROQ
|
70
|
+
|
71
|
+
judgeval_logger.warning(
|
72
|
+
f"Unknown client type {type(client)}, Trying to wrap as OpenAI-compatible. "
|
73
|
+
"If this is a mistake or you think we should support this client, please file an issue at https://github.com/JudgmentLabs/judgeval/issues!"
|
74
|
+
)
|
75
|
+
|
76
|
+
return ProviderType.DEFAULT
|
77
|
+
|
78
|
+
|
79
|
+
def wrap_provider(tracer: Tracer, client: ApiClient) -> ApiClient:
|
80
|
+
"""
|
81
|
+
Wraps an API client to add tracing capabilities.
|
82
|
+
Supports OpenAI, Together, Anthropic, Google GenAI, and Groq clients.
|
83
|
+
"""
|
84
|
+
provider_type = _detect_provider(client)
|
85
|
+
|
86
|
+
if provider_type == ProviderType.OPENAI:
|
87
|
+
from .llm_openai.wrapper import wrap_openai_client
|
88
|
+
|
89
|
+
return wrap_openai_client(tracer, client)
|
90
|
+
elif provider_type == ProviderType.ANTHROPIC:
|
91
|
+
from .llm_anthropic.wrapper import wrap_anthropic_client
|
92
|
+
|
93
|
+
return wrap_anthropic_client(tracer, client)
|
94
|
+
elif provider_type == ProviderType.TOGETHER:
|
95
|
+
from .llm_together.wrapper import wrap_together_client
|
96
|
+
|
97
|
+
return wrap_together_client(tracer, client)
|
98
|
+
elif provider_type == ProviderType.GOOGLE:
|
99
|
+
from .llm_google.wrapper import wrap_google_client
|
100
|
+
|
101
|
+
return wrap_google_client(tracer, client)
|
102
|
+
elif provider_type == ProviderType.GROQ:
|
103
|
+
from .llm_groq.wrapper import wrap_groq_client
|
104
|
+
|
105
|
+
return wrap_groq_client(tracer, client)
|
106
|
+
else:
|
107
|
+
# Default to OpenAI-compatible wrapping for unknown clients
|
108
|
+
from .llm_openai.wrapper import wrap_openai_client
|
109
|
+
|
110
|
+
return wrap_openai_client(tracer, client)
|