Skip to content

Commit 87e3113

Browse files
Add LM-Eval inline provider and unit tests
1 parent 29b5c9a commit 87e3113

File tree

12 files changed

+1113
-16
lines changed

12 files changed

+1113
-16
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module: llama_stack_provider_lmeval.inline
2+
config_class: llama_stack_provider_lmeval.config.LMEvalEvalProviderConfig
3+
pip_packages: ["lm-eval"]
4+
api_dependencies: ["inference"]
5+
optional_api_dependencies: []

providers.d/remote/eval/trustyai_lmeval.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ adapter:
22
adapter_type: lmeval
33
pip_packages: ["kubernetes"]
44
config_class: llama_stack_provider_lmeval.config.LMEvalEvalProviderConfig
5-
module: llama_stack_provider_lmeval
5+
module: llama_stack_provider_lmeval.remote
66
api_dependencies: ["inference"]
77
optional_api_dependencies: []

run-inline.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "2"
2+
image_name: trustyai-lmeval
3+
apis:
4+
- inference
5+
- eval
6+
providers:
7+
inference:
8+
- provider_id: vllm
9+
provider_type: remote::vllm
10+
config:
11+
url: ${env.VLLM_URL:=http://localhost:8080/v1}
12+
max_tokens: ${env.VLLM_MAX_TOKENS:=4096}
13+
api_token: ${env.VLLM_API_TOKEN:=fake}
14+
tls_verify: ${env.VLLM_TLS_VERIFY:=false}
15+
eval:
16+
- provider_id: trustyai_lmeval
17+
provider_type: inline::trustyai_lmeval
18+
config:
19+
base_url: ${env.BASE_URL:=http://localhost:8321/v1}
20+
use_k8s: ${env.USE_K8S:=false}
21+
# server:
22+
# port: ${env.PORT:=8321}
23+
external_providers_dir: ./providers.d

src/llama_stack_provider_lmeval/config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ def __post_init__(self):
130130
"""Validate the configuration"""
131131
if not isinstance(self.use_k8s, bool):
132132
raise LMEvalConfigError("use_k8s must be a boolean")
133-
if self.use_k8s is False:
134-
raise LMEvalConfigError(
135-
"Only Kubernetes LMEval backend is supported at the moment"
136-
)
137-
138133

139134
__all__ = [
140135
"TLSConfig",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import logging
2+
from typing import Optional
3+
4+
from llama_stack.apis.datatypes import Api
5+
from llama_stack.providers.datatypes import ProviderSpec
6+
7+
from llama_stack_provider_lmeval.config import LMEvalBenchmarkConfig
8+
from .lmeval import LMEvalInline
9+
10+
logger = logging.getLogger(__name__)
11+
12+
async def get_provider_impl(
13+
config: LMEvalBenchmarkConfig,
14+
deps: Optional[dict[Api, ProviderSpec]] = None,
15+
) -> LMEvalInline:
16+
"""Get an inline Eval implementation from the configuration.
17+
18+
Args:
19+
config: LMEvalInlineBenchmarkConfig
20+
deps: Optional[dict[Api, ProviderSpec]] = None
21+
22+
Returns:
23+
Configured LMEval Inline implementation
24+
25+
Raises:
26+
Exception: If configuration is invalid
27+
"""
28+
try:
29+
if deps is None:
30+
deps = {}
31+
32+
# Extract base_url from config if available
33+
base_url = None
34+
if hasattr(config, "model_args") and config.model_args:
35+
for arg in config.model_args:
36+
if arg.get("name") == "base_url":
37+
base_url = arg.get("value")
38+
logger.debug(f"Using base_url from config: {base_url}")
39+
break
40+
41+
return LMEvalInline(config=config)
42+
except Exception as e:
43+
raise Exception(f"Failed to create LMEval implementation: {str(e)}") from e
44+
45+
__all__ = [
46+
"get_provider_impl",
47+
"LMEvalInline",
48+
]

0 commit comments

Comments
 (0)