ibm-watsonx-orchestrate-evaluation-framework 1.1.3__py3-none-any.whl → 1.1.8b0__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.
Files changed (97) hide show
  1. {ibm_watsonx_orchestrate_evaluation_framework-1.1.3.dist-info → ibm_watsonx_orchestrate_evaluation_framework-1.1.8b0.dist-info}/METADATA +19 -1
  2. ibm_watsonx_orchestrate_evaluation_framework-1.1.8b0.dist-info/RECORD +146 -0
  3. wxo_agentic_evaluation/analytics/tools/analyzer.py +4 -2
  4. wxo_agentic_evaluation/analyze_run.py +1025 -220
  5. wxo_agentic_evaluation/annotate.py +2 -2
  6. wxo_agentic_evaluation/arg_configs.py +60 -2
  7. wxo_agentic_evaluation/base_user.py +25 -0
  8. wxo_agentic_evaluation/batch_annotate.py +19 -2
  9. wxo_agentic_evaluation/clients.py +103 -0
  10. wxo_agentic_evaluation/compare_runs/__init__.py +0 -0
  11. wxo_agentic_evaluation/compare_runs/compare_2_runs.py +74 -0
  12. wxo_agentic_evaluation/compare_runs/diff.py +554 -0
  13. wxo_agentic_evaluation/compare_runs/model.py +193 -0
  14. wxo_agentic_evaluation/data_annotator.py +25 -7
  15. wxo_agentic_evaluation/description_quality_checker.py +29 -6
  16. wxo_agentic_evaluation/evaluation.py +16 -8
  17. wxo_agentic_evaluation/evaluation_controller/evaluation_controller.py +303 -0
  18. wxo_agentic_evaluation/evaluation_package.py +414 -69
  19. wxo_agentic_evaluation/external_agent/__init__.py +1 -1
  20. wxo_agentic_evaluation/external_agent/external_validate.py +7 -5
  21. wxo_agentic_evaluation/external_agent/types.py +3 -9
  22. wxo_agentic_evaluation/extractors/__init__.py +3 -0
  23. wxo_agentic_evaluation/extractors/extractor_base.py +21 -0
  24. wxo_agentic_evaluation/extractors/labeled_messages.py +47 -0
  25. wxo_agentic_evaluation/hr_agent_langgraph.py +68 -0
  26. wxo_agentic_evaluation/langfuse_collection.py +60 -0
  27. wxo_agentic_evaluation/langfuse_evaluation_package.py +192 -0
  28. wxo_agentic_evaluation/llm_matching.py +104 -2
  29. wxo_agentic_evaluation/llm_safety_eval.py +64 -0
  30. wxo_agentic_evaluation/llm_user.py +5 -4
  31. wxo_agentic_evaluation/llm_user_v2.py +114 -0
  32. wxo_agentic_evaluation/main.py +112 -343
  33. wxo_agentic_evaluation/metrics/__init__.py +15 -0
  34. wxo_agentic_evaluation/metrics/dummy_metric.py +16 -0
  35. wxo_agentic_evaluation/metrics/evaluations.py +107 -0
  36. wxo_agentic_evaluation/metrics/journey_success.py +137 -0
  37. wxo_agentic_evaluation/metrics/llm_as_judge.py +26 -0
  38. wxo_agentic_evaluation/metrics/metrics.py +276 -8
  39. wxo_agentic_evaluation/metrics/tool_calling.py +93 -0
  40. wxo_agentic_evaluation/otel_parser/__init__.py +1 -0
  41. wxo_agentic_evaluation/otel_parser/langflow_parser.py +86 -0
  42. wxo_agentic_evaluation/otel_parser/langgraph_parser.py +61 -0
  43. wxo_agentic_evaluation/otel_parser/parser.py +163 -0
  44. wxo_agentic_evaluation/otel_parser/parser_types.py +38 -0
  45. wxo_agentic_evaluation/otel_parser/pydantic_parser.py +50 -0
  46. wxo_agentic_evaluation/otel_parser/utils.py +15 -0
  47. wxo_agentic_evaluation/otel_parser/wxo_parser.py +39 -0
  48. wxo_agentic_evaluation/otel_support/evaluate_tau.py +44 -10
  49. wxo_agentic_evaluation/otel_support/otel_message_conversion.py +12 -4
  50. wxo_agentic_evaluation/otel_support/tasks_test.py +456 -116
  51. wxo_agentic_evaluation/prompt/derailment_prompt.jinja2 +55 -0
  52. wxo_agentic_evaluation/prompt/llama_user_prompt.jinja2 +50 -4
  53. wxo_agentic_evaluation/prompt/llmaaj_prompt.jinja2 +15 -0
  54. wxo_agentic_evaluation/prompt/off_policy_attack_generation_prompt.jinja2 +1 -1
  55. wxo_agentic_evaluation/prompt/semantic_matching_prompt.jinja2 +41 -9
  56. wxo_agentic_evaluation/prompt/template_render.py +103 -4
  57. wxo_agentic_evaluation/prompt/unsafe_topic_prompt.jinja2 +65 -0
  58. wxo_agentic_evaluation/quick_eval.py +33 -17
  59. wxo_agentic_evaluation/record_chat.py +38 -32
  60. wxo_agentic_evaluation/red_teaming/attack_evaluator.py +211 -62
  61. wxo_agentic_evaluation/red_teaming/attack_generator.py +63 -40
  62. wxo_agentic_evaluation/red_teaming/attack_list.py +95 -7
  63. wxo_agentic_evaluation/red_teaming/attack_runner.py +77 -17
  64. wxo_agentic_evaluation/referenceless_eval/function_calling/metrics/function_call/general_metrics.json +783 -0
  65. wxo_agentic_evaluation/referenceless_eval/function_calling/metrics/function_selection/function_selection_metrics.json +600 -0
  66. wxo_agentic_evaluation/referenceless_eval/function_calling/pipeline/types.py +10 -10
  67. wxo_agentic_evaluation/referenceless_eval/referenceless_eval.py +105 -39
  68. wxo_agentic_evaluation/resource_map.py +3 -1
  69. wxo_agentic_evaluation/runner.py +329 -0
  70. wxo_agentic_evaluation/runtime_adapter/a2a_runtime_adapter.py +0 -0
  71. wxo_agentic_evaluation/runtime_adapter/runtime_adapter.py +14 -0
  72. wxo_agentic_evaluation/{inference_backend.py → runtime_adapter/wxo_runtime_adapter.py} +24 -293
  73. wxo_agentic_evaluation/scheduler.py +247 -0
  74. wxo_agentic_evaluation/service_instance.py +26 -17
  75. wxo_agentic_evaluation/service_provider/__init__.py +145 -9
  76. wxo_agentic_evaluation/service_provider/gateway_provider.py +707 -0
  77. wxo_agentic_evaluation/service_provider/model_proxy_provider.py +417 -17
  78. wxo_agentic_evaluation/service_provider/ollama_provider.py +393 -22
  79. wxo_agentic_evaluation/service_provider/portkey_provider.py +229 -0
  80. wxo_agentic_evaluation/service_provider/provider.py +130 -10
  81. wxo_agentic_evaluation/service_provider/referenceless_provider_wrapper.py +52 -0
  82. wxo_agentic_evaluation/service_provider/watsonx_provider.py +481 -53
  83. wxo_agentic_evaluation/simluation_runner.py +125 -0
  84. wxo_agentic_evaluation/test_prompt.py +4 -4
  85. wxo_agentic_evaluation/type.py +185 -16
  86. wxo_agentic_evaluation/user_simulator/demo_usage_llm_user.py +100 -0
  87. wxo_agentic_evaluation/utils/__init__.py +44 -3
  88. wxo_agentic_evaluation/utils/evaluation_discovery.py +47 -0
  89. wxo_agentic_evaluation/utils/gateway_provider_utils.py +39 -0
  90. wxo_agentic_evaluation/utils/messages_parser.py +30 -0
  91. wxo_agentic_evaluation/utils/parsers.py +71 -0
  92. wxo_agentic_evaluation/utils/utils.py +313 -9
  93. wxo_agentic_evaluation/wxo_client.py +81 -0
  94. ibm_watsonx_orchestrate_evaluation_framework-1.1.3.dist-info/RECORD +0 -102
  95. wxo_agentic_evaluation/otel_support/evaluate_tau_traces.py +0 -176
  96. {ibm_watsonx_orchestrate_evaluation_framework-1.1.3.dist-info → ibm_watsonx_orchestrate_evaluation_framework-1.1.8b0.dist-info}/WHEEL +0 -0
  97. {ibm_watsonx_orchestrate_evaluation_framework-1.1.3.dist-info → ibm_watsonx_orchestrate_evaluation_framework-1.1.8b0.dist-info}/top_level.txt +0 -0
@@ -1,18 +1,138 @@
1
- from abc import ABC, abstractmethod
2
- from typing import List
1
+ from __future__ import annotations
3
2
 
3
+ import logging
4
+ import os
5
+ from abc import ABC, ABCMeta, abstractmethod
6
+ from dataclasses import dataclass
7
+ from threading import Lock
8
+ from typing import Any, Dict, List, Optional, Sequence, Tuple
4
9
 
5
- class Provider(ABC):
6
- def __init__(self):
7
- pass
10
+ from wxo_agentic_evaluation.type import ProviderInstancesCacheKey
11
+
12
+
13
+ class SingletonProviderMeta(type):
14
+
15
+ _provider_instances: Dict[str, "Provider"] = {}
16
+ _instantiation_lock = Lock()
17
+
18
+ def __call__(cls, *args, **kwargs):
19
+
20
+ key_str: str = str(cls._get_key(cls.__name__, args, kwargs))
21
+
22
+ if key_str not in cls._provider_instances:
23
+ with cls._instantiation_lock:
24
+ if key_str not in cls._provider_instances:
25
+ cls._provider_instances[key_str] = super().__call__(
26
+ *args, **kwargs
27
+ )
28
+
29
+ return cls._provider_instances[key_str]
30
+
31
+ @staticmethod
32
+ def _get_key(
33
+ provider: str, args: Tuple[Any, ...], kwargs: Dict[str, Any]
34
+ ) -> ProviderInstancesCacheKey:
35
+
36
+ args_str = str(args) if args else "noargs"
37
+ kwargs_str = str(sorted(kwargs.items())) if kwargs else "nokwargs"
38
+
39
+ return ProviderInstancesCacheKey(
40
+ provider=provider,
41
+ hashed_args=args_str,
42
+ hashed_kwargs=kwargs_str,
43
+ )
44
+
45
+
46
+ class SingletonProviderABCMeta(ABCMeta, SingletonProviderMeta):
47
+ pass
48
+
49
+
50
+ @dataclass
51
+ class ChatResult:
52
+ text: str
53
+ usage: Optional[Dict[str, Any]] = None
54
+ finish_reason: Optional[str] = None
55
+ raw: Optional[Any] = None
56
+
57
+
58
+ class Provider(ABC, metaclass=SingletonProviderABCMeta):
59
+ def __init__(
60
+ self,
61
+ use_legacy_query: Optional[bool] = None,
62
+ logger: Optional[logging.Logger] = None,
63
+ ) -> None:
64
+ self.logger = logger or logging.getLogger(self.__class__.__name__)
65
+
66
+ env_use_legacy = os.environ.get("USE_LEGACY_QUERY")
67
+ if env_use_legacy is not None:
68
+ self.use_legacy_query: bool = env_use_legacy.strip().lower() in (
69
+ "1",
70
+ "true",
71
+ "yes",
72
+ "on",
73
+ )
74
+ else:
75
+ self.use_legacy_query = (
76
+ bool(use_legacy_query) if use_legacy_query is not None else True
77
+ )
78
+ if self.use_legacy_query:
79
+ self.logger.debug("[d][b]Using legacy /text/generation queries")
80
+ else:
81
+ self.logger.debug("[d][b]Using new /chat/completions queries")
8
82
 
9
83
  @abstractmethod
10
- def query(self, sentence: str) -> str:
11
- pass
84
+ def old_query(self, sentence: str) -> str:
85
+ raise NotImplementedError
12
86
 
13
- def batch_query(self, sentences: List[str]) -> List[str]:
14
- return [self.query(sentence) for sentence in sentences]
87
+ @abstractmethod
88
+ def new_query(self, sentence: str) -> str:
89
+ raise NotImplementedError
15
90
 
16
91
  @abstractmethod
17
92
  def encode(self, sentences: List[str]) -> List[list]:
18
- pass
93
+ raise NotImplementedError
94
+
95
+ def query(self, sentence: str) -> str:
96
+ if self.use_legacy_query:
97
+ return self.old_query(sentence)
98
+ return self.new_query(sentence)
99
+
100
+ def chat(
101
+ self,
102
+ messages: Sequence[Dict[str, str]],
103
+ params: Optional[Dict[str, Any]] = None,
104
+ ) -> ChatResult:
105
+ raise NotImplementedError(
106
+ f"{self.__class__.__name__} does not implement chat()."
107
+ )
108
+
109
+ def batch_query(
110
+ self,
111
+ sentences: List[str],
112
+ max_workers: Optional[int] = None,
113
+ ) -> List[str]:
114
+ if not sentences:
115
+ return []
116
+
117
+ if not max_workers or max_workers <= 1:
118
+ return [self.query(sentence) for sentence in sentences]
119
+
120
+ from concurrent.futures import ThreadPoolExecutor, as_completed
121
+
122
+ results: List[Optional[str]] = [None] * len(sentences)
123
+ with ThreadPoolExecutor(max_workers=max_workers) as pool:
124
+ future_to_idx = {
125
+ pool.submit(self.query, s): i for i, s in enumerate(sentences)
126
+ }
127
+ for fut in as_completed(future_to_idx):
128
+ idx = future_to_idx[fut]
129
+ results[idx] = fut.result()
130
+
131
+ return [r if r is not None else "" for r in results]
132
+
133
+ def set_routing(self, use_legacy_query: Optional[bool] = None) -> None:
134
+ if use_legacy_query is not None:
135
+ self.use_legacy_query = bool(use_legacy_query)
136
+
137
+ def close(self) -> None:
138
+ return
@@ -1,9 +1,14 @@
1
+ import uuid
1
2
  from abc import ABC, abstractmethod
2
3
  from typing import Any, List, Mapping, Optional, Union
3
4
 
4
5
  import requests
5
6
  import rich
6
7
 
8
+ from wxo_agentic_evaluation.service_provider.gateway_provider import (
9
+ GatewayProvider,
10
+ _translate_params_to_chat,
11
+ )
7
12
  from wxo_agentic_evaluation.service_provider.model_proxy_provider import (
8
13
  ModelProxyProvider,
9
14
  )
@@ -149,3 +154,50 @@ class WatsonXLLMKitWrapper(WatsonXProvider, LLMKitWrapper):
149
154
  return resp.json()
150
155
  else:
151
156
  resp.raise_for_status()
157
+
158
+
159
+ class GatewayProviderLLMKitWrapper(GatewayProvider, LLMKitWrapper):
160
+ def chat(self, sentence: Union[str, List[Mapping[str, str]]]):
161
+ if isinstance(sentence, str):
162
+ messages = []
163
+ if self.system_prompt:
164
+ messages.append(
165
+ {"role": "system", "content": self.system_prompt}
166
+ )
167
+ messages.append({"role": "user", "content": sentence})
168
+ else:
169
+ messages = sentence
170
+
171
+ if self.model_id is None:
172
+ raise Exception("model id must be specified for text generation")
173
+
174
+ self.refresh_token_if_expires()
175
+
176
+ merged_params = dict(self.params or {})
177
+ chat_params = _translate_params_to_chat(merged_params)
178
+ chat_params.pop("stream", None)
179
+
180
+ override_params = dict(merged_params)
181
+ override_params["model"] = self.model_id
182
+
183
+ payload = {
184
+ "model": self._payload_model_str(self.model_id),
185
+ "messages": list(messages),
186
+ **chat_params,
187
+ }
188
+
189
+ request_id = str(uuid.uuid4())
190
+ headers = self._headers(request_id, override_params)
191
+
192
+ resp = requests.post(
193
+ self.chat_url,
194
+ json=payload,
195
+ headers=headers,
196
+ verify=self._wo_ssl_verify,
197
+ timeout=self.timeout,
198
+ )
199
+
200
+ if resp.status_code == 200:
201
+ return resp.json()
202
+ else:
203
+ resp.raise_for_status()