opik-optimizer 1.0.6__py3-none-any.whl → 1.1.0__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.
- opik_optimizer/__init__.py +2 -0
- opik_optimizer/_throttle.py +2 -1
- opik_optimizer/base_optimizer.py +28 -11
- opik_optimizer/colbert.py +236 -0
- opik_optimizer/data/context7_eval.jsonl +3 -0
- opik_optimizer/datasets/context7_eval.py +90 -0
- opik_optimizer/datasets/tiny_test.py +33 -34
- opik_optimizer/datasets/truthful_qa.py +2 -2
- opik_optimizer/evolutionary_optimizer/crossover_ops.py +194 -0
- opik_optimizer/evolutionary_optimizer/evaluation_ops.py +73 -0
- opik_optimizer/evolutionary_optimizer/evolutionary_optimizer.py +124 -941
- opik_optimizer/evolutionary_optimizer/helpers.py +10 -0
- opik_optimizer/evolutionary_optimizer/llm_support.py +134 -0
- opik_optimizer/evolutionary_optimizer/mutation_ops.py +292 -0
- opik_optimizer/evolutionary_optimizer/population_ops.py +223 -0
- opik_optimizer/evolutionary_optimizer/prompts.py +305 -0
- opik_optimizer/evolutionary_optimizer/reporting.py +16 -4
- opik_optimizer/evolutionary_optimizer/style_ops.py +86 -0
- opik_optimizer/few_shot_bayesian_optimizer/few_shot_bayesian_optimizer.py +26 -23
- opik_optimizer/few_shot_bayesian_optimizer/reporting.py +12 -5
- opik_optimizer/gepa_optimizer/__init__.py +3 -0
- opik_optimizer/gepa_optimizer/adapter.py +152 -0
- opik_optimizer/gepa_optimizer/gepa_optimizer.py +556 -0
- opik_optimizer/gepa_optimizer/reporting.py +181 -0
- opik_optimizer/logging_config.py +42 -7
- opik_optimizer/mcp_utils/__init__.py +22 -0
- opik_optimizer/mcp_utils/mcp.py +541 -0
- opik_optimizer/mcp_utils/mcp_second_pass.py +152 -0
- opik_optimizer/mcp_utils/mcp_simulator.py +116 -0
- opik_optimizer/mcp_utils/mcp_workflow.py +493 -0
- opik_optimizer/meta_prompt_optimizer/meta_prompt_optimizer.py +399 -69
- opik_optimizer/meta_prompt_optimizer/reporting.py +16 -2
- opik_optimizer/mipro_optimizer/_lm.py +20 -20
- opik_optimizer/mipro_optimizer/_mipro_optimizer_v2.py +51 -50
- opik_optimizer/mipro_optimizer/mipro_optimizer.py +33 -28
- opik_optimizer/mipro_optimizer/utils.py +2 -4
- opik_optimizer/optimizable_agent.py +16 -16
- opik_optimizer/optimization_config/chat_prompt.py +44 -23
- opik_optimizer/optimization_config/configs.py +3 -3
- opik_optimizer/optimization_config/mappers.py +9 -8
- opik_optimizer/optimization_result.py +21 -14
- opik_optimizer/reporting_utils.py +61 -10
- opik_optimizer/task_evaluator.py +9 -8
- opik_optimizer/utils/__init__.py +15 -0
- opik_optimizer/{utils.py → utils/core.py} +111 -26
- opik_optimizer/utils/dataset_utils.py +49 -0
- opik_optimizer/utils/prompt_segments.py +186 -0
- {opik_optimizer-1.0.6.dist-info → opik_optimizer-1.1.0.dist-info}/METADATA +93 -16
- opik_optimizer-1.1.0.dist-info/RECORD +73 -0
- opik_optimizer-1.1.0.dist-info/licenses/LICENSE +203 -0
- opik_optimizer-1.0.6.dist-info/RECORD +0 -50
- opik_optimizer-1.0.6.dist-info/licenses/LICENSE +0 -21
- {opik_optimizer-1.0.6.dist-info → opik_optimizer-1.1.0.dist-info}/WHEEL +0 -0
- {opik_optimizer-1.0.6.dist-info → opik_optimizer-1.1.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import hashlib
|
4
|
+
import secrets
|
5
|
+
import time
|
6
|
+
from functools import lru_cache
|
7
|
+
from importlib import resources
|
8
|
+
from typing import Any
|
9
|
+
from collections.abc import Iterable
|
10
|
+
|
11
|
+
|
12
|
+
@lru_cache(maxsize=None)
|
13
|
+
def dataset_suffix(package: str, filename: str) -> str:
|
14
|
+
"""Return a stable checksum-based suffix for a JSONL dataset file."""
|
15
|
+
text = resources.files(package).joinpath(filename).read_text(encoding="utf-8")
|
16
|
+
return hashlib.md5(text.encode("utf-8")).hexdigest()[:8]
|
17
|
+
|
18
|
+
|
19
|
+
def generate_uuid7_str() -> str:
|
20
|
+
"""Generate a UUIDv7-compatible string, emulating the layout if unavailable."""
|
21
|
+
import uuid
|
22
|
+
|
23
|
+
if hasattr(uuid, "uuid7"):
|
24
|
+
return str(uuid.uuid7()) # type: ignore[attr-defined]
|
25
|
+
|
26
|
+
unix_ts_ms = int(time.time() * 1000) & ((1 << 48) - 1)
|
27
|
+
rand_a = secrets.randbits(12)
|
28
|
+
rand_b = secrets.randbits(62)
|
29
|
+
|
30
|
+
uuid_int = unix_ts_ms << 80
|
31
|
+
uuid_int |= 0x7 << 76 # version 7
|
32
|
+
uuid_int |= rand_a << 64
|
33
|
+
uuid_int |= 0b10 << 62 # RFC4122 variant
|
34
|
+
uuid_int |= rand_b
|
35
|
+
|
36
|
+
return str(uuid.UUID(int=uuid_int))
|
37
|
+
|
38
|
+
|
39
|
+
def attach_uuids(records: Iterable[dict[str, Any]]) -> list[dict[str, Any]]:
|
40
|
+
"""Copy records and assign a fresh UUIDv7 `id` to each."""
|
41
|
+
payload: list[dict[str, Any]] = []
|
42
|
+
for record in records:
|
43
|
+
rec = dict(record)
|
44
|
+
rec["id"] = generate_uuid7_str()
|
45
|
+
payload.append(rec)
|
46
|
+
return payload
|
47
|
+
|
48
|
+
|
49
|
+
__all__ = ["dataset_suffix", "generate_uuid7_str", "attach_uuids"]
|
@@ -0,0 +1,186 @@
|
|
1
|
+
"""Prompt segmentation helpers for targeted prompt updates.
|
2
|
+
|
3
|
+
These utilities operate on existing ``ChatPrompt`` instances without
|
4
|
+
changing their constructor, allowing callers to identify and update
|
5
|
+
specific sections (system message, individual chat messages, or tool
|
6
|
+
descriptions) while preserving backwards compatibility for the rest of
|
7
|
+
the optimizer stack.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from __future__ import annotations
|
11
|
+
|
12
|
+
from dataclasses import dataclass
|
13
|
+
from typing import Any
|
14
|
+
from collections.abc import Iterable
|
15
|
+
|
16
|
+
import copy
|
17
|
+
|
18
|
+
from ..optimization_config.chat_prompt import ChatPrompt
|
19
|
+
|
20
|
+
|
21
|
+
PROMPT_SEGMENT_PREFIX_TOOL = "tool:"
|
22
|
+
PROMPT_SEGMENT_PREFIX_MESSAGE = "message:"
|
23
|
+
|
24
|
+
|
25
|
+
@dataclass
|
26
|
+
class PromptSegment:
|
27
|
+
"""Lightweight view over a prompt component that may be edited."""
|
28
|
+
|
29
|
+
segment_id: str
|
30
|
+
kind: str
|
31
|
+
role: str | None
|
32
|
+
content: str
|
33
|
+
metadata: dict[str, Any]
|
34
|
+
|
35
|
+
def is_tool(self) -> bool:
|
36
|
+
return self.segment_id.startswith(PROMPT_SEGMENT_PREFIX_TOOL)
|
37
|
+
|
38
|
+
|
39
|
+
def _normalise_tool(tool: dict[str, Any]) -> dict[str, Any]:
|
40
|
+
"""Return tools in the ``{"function": {...}}`` structure for consistency."""
|
41
|
+
|
42
|
+
if "function" in tool:
|
43
|
+
return copy.deepcopy(tool)
|
44
|
+
|
45
|
+
normalised = copy.deepcopy(tool)
|
46
|
+
function_block = {
|
47
|
+
"name": normalised.pop("name", None),
|
48
|
+
"description": normalised.pop("description", ""),
|
49
|
+
"parameters": normalised.pop("parameters", None),
|
50
|
+
}
|
51
|
+
normalised = {"function": function_block, **normalised}
|
52
|
+
return normalised
|
53
|
+
|
54
|
+
|
55
|
+
def extract_prompt_segments(prompt: ChatPrompt) -> list[PromptSegment]:
|
56
|
+
"""Extract individual editable segments from ``prompt``.
|
57
|
+
|
58
|
+
The extraction preserves order for chat messages while assigning
|
59
|
+
stable segment identifiers:
|
60
|
+
|
61
|
+
* ``system`` for the system field (if present)
|
62
|
+
* ``user`` for the top-level user field (if present)
|
63
|
+
* ``message:<index>`` for entries in ``messages``
|
64
|
+
* ``tool:<name>`` for tool descriptions
|
65
|
+
"""
|
66
|
+
|
67
|
+
segments: list[PromptSegment] = []
|
68
|
+
|
69
|
+
if prompt.system is not None:
|
70
|
+
segments.append(
|
71
|
+
PromptSegment(
|
72
|
+
segment_id="system",
|
73
|
+
kind="system",
|
74
|
+
role="system",
|
75
|
+
content=prompt.system,
|
76
|
+
metadata={},
|
77
|
+
)
|
78
|
+
)
|
79
|
+
|
80
|
+
if prompt.messages is not None:
|
81
|
+
for idx, message in enumerate(prompt.messages):
|
82
|
+
segments.append(
|
83
|
+
PromptSegment(
|
84
|
+
segment_id=f"{PROMPT_SEGMENT_PREFIX_MESSAGE}{idx}",
|
85
|
+
kind="message",
|
86
|
+
role=message.get("role"),
|
87
|
+
content=message.get("content", ""),
|
88
|
+
metadata={
|
89
|
+
key: value for key, value in message.items() if key != "content"
|
90
|
+
},
|
91
|
+
)
|
92
|
+
)
|
93
|
+
|
94
|
+
if prompt.user is not None:
|
95
|
+
segments.append(
|
96
|
+
PromptSegment(
|
97
|
+
segment_id="user",
|
98
|
+
kind="user",
|
99
|
+
role="user",
|
100
|
+
content=prompt.user,
|
101
|
+
metadata={},
|
102
|
+
)
|
103
|
+
)
|
104
|
+
|
105
|
+
if prompt.tools:
|
106
|
+
for tool in prompt.tools:
|
107
|
+
normalised = _normalise_tool(tool)
|
108
|
+
function_block = normalised.get("function", {})
|
109
|
+
tool_name = function_block.get("name")
|
110
|
+
if not tool_name:
|
111
|
+
continue
|
112
|
+
segments.append(
|
113
|
+
PromptSegment(
|
114
|
+
segment_id=f"{PROMPT_SEGMENT_PREFIX_TOOL}{tool_name}",
|
115
|
+
kind="tool",
|
116
|
+
role="tool",
|
117
|
+
content=function_block.get("description", ""),
|
118
|
+
metadata={
|
119
|
+
"parameters": function_block.get("parameters"),
|
120
|
+
"raw_tool": normalised,
|
121
|
+
},
|
122
|
+
)
|
123
|
+
)
|
124
|
+
|
125
|
+
return segments
|
126
|
+
|
127
|
+
|
128
|
+
def apply_segment_updates(
|
129
|
+
prompt: ChatPrompt,
|
130
|
+
updates: dict[str, str],
|
131
|
+
) -> ChatPrompt:
|
132
|
+
"""Return a new ``ChatPrompt`` with selected segments replaced.
|
133
|
+
|
134
|
+
``updates`` maps segment identifiers (as produced by
|
135
|
+
``extract_prompt_segments``) to replacement strings.
|
136
|
+
"""
|
137
|
+
|
138
|
+
system = updates.get("system", prompt.system)
|
139
|
+
user = updates.get("user", prompt.user)
|
140
|
+
|
141
|
+
messages: list[dict[str, Any]] | None = None
|
142
|
+
if prompt.messages is not None:
|
143
|
+
new_messages: list[dict[str, Any]] = []
|
144
|
+
for idx, message in enumerate(prompt.messages):
|
145
|
+
segment_id = f"{PROMPT_SEGMENT_PREFIX_MESSAGE}{idx}"
|
146
|
+
replacement = updates.get(segment_id)
|
147
|
+
if replacement is not None:
|
148
|
+
updated_message = copy.deepcopy(message)
|
149
|
+
updated_message["content"] = replacement
|
150
|
+
new_messages.append(updated_message)
|
151
|
+
else:
|
152
|
+
new_messages.append(copy.deepcopy(message))
|
153
|
+
messages = new_messages
|
154
|
+
|
155
|
+
tools = copy.deepcopy(prompt.tools) if prompt.tools else None
|
156
|
+
if tools:
|
157
|
+
for tool in tools:
|
158
|
+
normalised = _normalise_tool(tool)
|
159
|
+
function_block = normalised.get("function", {})
|
160
|
+
tool_name = function_block.get("name")
|
161
|
+
if not tool_name:
|
162
|
+
continue
|
163
|
+
segment_id = f"{PROMPT_SEGMENT_PREFIX_TOOL}{tool_name}"
|
164
|
+
replacement = updates.get(segment_id)
|
165
|
+
if replacement is not None:
|
166
|
+
function_block["description"] = replacement
|
167
|
+
tool.update(normalised)
|
168
|
+
|
169
|
+
return ChatPrompt(
|
170
|
+
name=prompt.name,
|
171
|
+
system=system,
|
172
|
+
user=user,
|
173
|
+
messages=messages,
|
174
|
+
tools=tools,
|
175
|
+
function_map=prompt.function_map,
|
176
|
+
model=prompt.model,
|
177
|
+
invoke=prompt.invoke,
|
178
|
+
project_name=prompt.project_name,
|
179
|
+
**prompt.model_kwargs,
|
180
|
+
)
|
181
|
+
|
182
|
+
|
183
|
+
def segment_ids_for_tools(segments: Iterable[PromptSegment]) -> list[str]:
|
184
|
+
"""Convenience helper returning IDs of tool segments."""
|
185
|
+
|
186
|
+
return [segment.segment_id for segment in segments if segment.is_tool()]
|
@@ -1,42 +1,40 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: opik_optimizer
|
3
|
-
Version: 1.0
|
3
|
+
Version: 1.1.0
|
4
4
|
Summary: Agent optimization with Opik
|
5
5
|
Home-page: https://github.com/comet-ml/opik
|
6
6
|
Author: Comet ML
|
7
|
-
Author-email: support@comet.com
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Requires-Python: >=3.9,<3.13
|
7
|
+
Author-email: Comet ML <support@comet.com>
|
8
|
+
License: Apache 2.0
|
9
|
+
Project-URL: Homepage, https://github.com/comet-ml/opik/blob/main/sdks/opik_optimizer/README.md
|
10
|
+
Project-URL: Repository, https://github.com/comet-ml/opik
|
11
|
+
Requires-Python: >=3.10,<3.13
|
13
12
|
Description-Content-Type: text/markdown
|
14
13
|
License-File: LICENSE
|
15
14
|
Requires-Dist: datasets
|
16
15
|
Requires-Dist: deap>=1.4.3
|
17
16
|
Requires-Dist: diskcache
|
17
|
+
Requires-Dist: dspy<3
|
18
|
+
Requires-Dist: ujson
|
18
19
|
Requires-Dist: hf_xet
|
19
20
|
Requires-Dist: litellm
|
21
|
+
Requires-Dist: mcp>=1.0.0
|
20
22
|
Requires-Dist: opik>=1.7.17
|
21
23
|
Requires-Dist: optuna
|
22
24
|
Requires-Dist: pandas
|
23
25
|
Requires-Dist: pydantic
|
24
26
|
Requires-Dist: pyrate-limiter
|
25
27
|
Requires-Dist: tqdm
|
28
|
+
Requires-Dist: rich
|
26
29
|
Provides-Extra: dev
|
27
30
|
Requires-Dist: pytest; extra == "dev"
|
28
|
-
Requires-Dist: pytest-
|
31
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
32
|
+
Requires-Dist: langgraph; extra == "dev"
|
33
|
+
Requires-Dist: gepa>=0.0.7; extra == "dev"
|
29
34
|
Dynamic: author
|
30
|
-
Dynamic: author-email
|
31
|
-
Dynamic: classifier
|
32
|
-
Dynamic: description
|
33
|
-
Dynamic: description-content-type
|
34
35
|
Dynamic: home-page
|
35
36
|
Dynamic: license-file
|
36
|
-
Dynamic: provides-extra
|
37
|
-
Dynamic: requires-dist
|
38
37
|
Dynamic: requires-python
|
39
|
-
Dynamic: summary
|
40
38
|
|
41
39
|
# Opik Agent Optimizer
|
42
40
|
|
@@ -51,6 +49,7 @@ The Opik Agent Optimizer refines your prompts to achieve better performance from
|
|
51
49
|
* FewShotBayesianOptimizer
|
52
50
|
* MetaPromptOptimizer
|
53
51
|
* MiproOptimizer
|
52
|
+
* GepaOptimizer
|
54
53
|
|
55
54
|
Opik Optimizer is a component of the [Opik platform](https://github.com/comet-ml/opik), an open-source LLM evaluation platform by Comet.
|
56
55
|
For more information about the broader Opik ecosystem, visit our [Website](https://www.comet.com/site/products/opik/) or [Documentation](https://www.comet.com/docs/opik/).
|
@@ -156,6 +155,84 @@ result.display()
|
|
156
155
|
```
|
157
156
|
The `result` object contains the optimized prompt, evaluation scores, and other details from the optimization process. If `project_name` is provided and Opik is configured, results will also be logged to your Comet workspace.
|
158
157
|
|
158
|
+
## Tool Optimization (MCP) - Beta
|
159
|
+
|
160
|
+
The Opik Agent Optimizer supports **true tool optimization** for MCP (Model Context Protocol) tools. This feature is currently in **Beta** and supported by the **MetaPrompt Optimizer**.
|
161
|
+
|
162
|
+
### Key Features
|
163
|
+
|
164
|
+
- **MCP Tool Optimization** - Optimize MCP tool descriptions and usage patterns (Beta)
|
165
|
+
- **Tool-Aware Analysis** - The optimizer understands MCP tool schemas and usage patterns
|
166
|
+
- **Multi-step Workflow Support** - Optimize complex agent workflows involving MCP tools
|
167
|
+
|
168
|
+
### Agent Function Calling (Not Tool Optimization)
|
169
|
+
|
170
|
+
Many optimizers can optimize **agents that use function calling**, but this is different from true tool optimization. Here's an example with GEPA:
|
171
|
+
|
172
|
+
```python
|
173
|
+
from opik_optimizer import GepaOptimizer, ChatPrompt
|
174
|
+
|
175
|
+
# GEPA example: optimizing an agent with function calling
|
176
|
+
prompt = ChatPrompt(
|
177
|
+
system="You are a helpful assistant. Use the search_wikipedia tool when needed.",
|
178
|
+
user="{question}",
|
179
|
+
tools=[
|
180
|
+
{
|
181
|
+
"type": "function",
|
182
|
+
"function": {
|
183
|
+
"name": "search_wikipedia",
|
184
|
+
"description": "This function searches Wikipedia abstracts.",
|
185
|
+
"parameters": {
|
186
|
+
"type": "object",
|
187
|
+
"properties": {
|
188
|
+
"query": {"type": "string", "description": "Search query"}
|
189
|
+
},
|
190
|
+
"required": ["query"]
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
],
|
195
|
+
function_map={
|
196
|
+
"search_wikipedia": lambda query: search_wikipedia(query, use_api=True)
|
197
|
+
}
|
198
|
+
)
|
199
|
+
|
200
|
+
# GEPA optimizes the agent's prompt, not the tools themselves
|
201
|
+
optimizer = GepaOptimizer(model="gpt-4o-mini")
|
202
|
+
result = optimizer.optimize_prompt(prompt=prompt, dataset=dataset, metric=metric)
|
203
|
+
```
|
204
|
+
|
205
|
+
### True Tool Optimization (MCP) - Beta
|
206
|
+
|
207
|
+
```python
|
208
|
+
from opik_optimizer import MetaPromptOptimizer
|
209
|
+
|
210
|
+
# MCP tool optimization is currently in Beta
|
211
|
+
# See scripts/litellm_metaprompt_context7_mcp_example.py for working examples
|
212
|
+
optimizer = MetaPromptOptimizer(model="gpt-4")
|
213
|
+
# MCP tools are configured through mcp.json manifests
|
214
|
+
```
|
215
|
+
|
216
|
+
For comprehensive documentation on tool optimization, see the [Tool Optimization Guide](https://www.comet.com/docs/opik/agent_optimization/algorithms/tool_optimization).
|
217
|
+
|
218
|
+
### MCP Integration (Beta)
|
219
|
+
|
220
|
+
The optimizer includes utilities for MCP tool integration:
|
221
|
+
|
222
|
+
```bash
|
223
|
+
# Install MCP Python SDK
|
224
|
+
pip install mcp
|
225
|
+
|
226
|
+
# Run MCP examples (Beta)
|
227
|
+
python scripts/litellm_metaprompt_context7_mcp_example.py
|
228
|
+
```
|
229
|
+
|
230
|
+
Underlying utilities are available in `src/opik_optimizer/utils/{prompt_segments,mcp,mcp_simulator}.py`.
|
231
|
+
|
232
|
+
<Note>
|
233
|
+
**Important:** True tool optimization (MCP) is currently in **Beta**. Most examples show **agent optimization** (optimizing prompts for agents that use tools), which is different from optimizing the tools themselves.
|
234
|
+
</Note>
|
235
|
+
|
159
236
|
## Development
|
160
237
|
|
161
238
|
To contribute or use the Opik Optimizer from source:
|
@@ -176,6 +253,6 @@ To contribute or use the Opik Optimizer from source:
|
|
176
253
|
|
177
254
|
## Requirements
|
178
255
|
|
179
|
-
- Python `>=3.
|
256
|
+
- **Python `>=3.10,<3.13`** (see [Python version requirements](https://github.com/comet-ml/opik/pull/3373))
|
180
257
|
- Opik API key (recommended for full functionality, configure via `opik configure`)
|
181
258
|
- API key for your chosen LLM provider (e.g., OpenAI, Anthropic, Gemini), configured as per LiteLLM guidelines.
|
@@ -0,0 +1,73 @@
|
|
1
|
+
opik_optimizer/__init__.py,sha256=RfqtLQDCKVsyU0KyBctTn7Sa-4Pz0IT_t5FgCc4qsP8,1168
|
2
|
+
opik_optimizer/_throttle.py,sha256=1JXIhYlo0IaqCgwmNB0Hnh9CYhYPkwRFdVGIcE7pVNg,1362
|
3
|
+
opik_optimizer/base_optimizer.py,sha256=xljdM2UYEdcj1OHQuuIVMw6qzf_2s1FfWty-XG55DIw,6609
|
4
|
+
opik_optimizer/cache_config.py,sha256=Xd3NdUsL7bLQWoNe3pESqH4nHucU1iNTSGp-RqbwDog,599
|
5
|
+
opik_optimizer/colbert.py,sha256=qSrzKUUGw7P92mLy4Ofug5pBGeTsHBLMJXlXSJSfKuo,8147
|
6
|
+
opik_optimizer/logging_config.py,sha256=TmxX0C1P20amxoXuiNQvlENOjdSNfWwvL8jFy206VWM,3837
|
7
|
+
opik_optimizer/optimizable_agent.py,sha256=lzC7LyLaeqZP8FI6zaDAfhgA6AtPuX-UYH1sH7PCqpw,6024
|
8
|
+
opik_optimizer/optimization_result.py,sha256=BnrBwO1PAykqwSE7wPvntBKxlDMacdxPRYBDuILMLoM,8078
|
9
|
+
opik_optimizer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
opik_optimizer/reporting_utils.py,sha256=dcECFmzZ_J-DKoukMDEE_fm7X8sdQyl_ijTddvQtepE,8287
|
11
|
+
opik_optimizer/task_evaluator.py,sha256=1hILYwJLtn7XpPX96JjubnlMasmudVTHMVK3pmd22bE,4312
|
12
|
+
opik_optimizer/data/context7_eval.jsonl,sha256=vPR3XRfI0UbZ1hgUGaOdpraFT99RDLU1YWuPFLLQz40,1757
|
13
|
+
opik_optimizer/data/hotpot-500.json,sha256=YXxCtuvYvxSu5u0y4559a6b1qwgAYsWzT_SUKv_21ew,76862
|
14
|
+
opik_optimizer/datasets/__init__.py,sha256=V4LVDOaRjwzaYvhdQ3V6CAwFaeKnxyTV1lp_ES9Z31E,691
|
15
|
+
opik_optimizer/datasets/ai2_arc.py,sha256=vIxb8qlCAxx4_cz2P7SIqS7flquj--7XVUaDmy12UfY,1440
|
16
|
+
opik_optimizer/datasets/cnn_dailymail.py,sha256=RB-oMvnwzTudlrtnBK1maj-OEi7Dh884S81_yLaWeoc,1365
|
17
|
+
opik_optimizer/datasets/context7_eval.py,sha256=OUZ01AA3cRptBcDBCCStpm-fOQ7Vqr_FyVRJ0zLhP_I,2772
|
18
|
+
opik_optimizer/datasets/election_questions.py,sha256=3s0iYLH6gjrsP3-FvI6sbapJloEnudd_3NsBfc38Bis,1189
|
19
|
+
opik_optimizer/datasets/gsm8k.py,sha256=WUD-UEgYvJ-k_xZtBmgF5CUUCFUA_uJYuPS8xmRxXMM,1370
|
20
|
+
opik_optimizer/datasets/halu_eval.py,sha256=9pI_H13Z0zHc1xx4jIySJ6TC6osgvEQTbFjf-0_GvTg,1433
|
21
|
+
opik_optimizer/datasets/hotpot_qa.py,sha256=_VLMCSbJe1-jDq6RAg6rb-Hq5ZfOvI7pQfgiql8DRDM,2200
|
22
|
+
opik_optimizer/datasets/medhallu.py,sha256=h2X9SgGP0G5V1FDL25YjFvmOcqDeXllwyHmH5LFrQ4w,1489
|
23
|
+
opik_optimizer/datasets/rag_hallucinations.py,sha256=SHQ-wdI8YjaeuSkPPgNUYQ9KmAV648CuLeeDAi5s7Xk,1440
|
24
|
+
opik_optimizer/datasets/ragbench.py,sha256=Ltdz3yF1h3rfjr7EXbwJv48t7ud2BKGdxmuJOwc02ww,1475
|
25
|
+
opik_optimizer/datasets/tiny_test.py,sha256=2AhLxamXxeuy9PhHxAXkcJ8XXM6c2wqN4YufUnld8tQ,1878
|
26
|
+
opik_optimizer/datasets/truthful_qa.py,sha256=JpmGEcItMlMgcVRbsWB_BPDMIEu2Cnfo7aPK4qGQnyM,4228
|
27
|
+
opik_optimizer/demo/__init__.py,sha256=KSpFYhzN7fTmLEsIaciRHwxcJDeAiX5NDmYLdPsfpT8,150
|
28
|
+
opik_optimizer/demo/cache.py,sha256=CwjdmVjokVxmPXvgfOutZK8e0sV-PIUz3ou6ODXZBts,3738
|
29
|
+
opik_optimizer/demo/datasets.py,sha256=idod4NYHw1IbxhA8c0XVFD_pGpMZagNGNZuEYDTbbMM,2357
|
30
|
+
opik_optimizer/evolutionary_optimizer/__init__.py,sha256=bDa6FZR9Y_a5z337I4EtvaB69jB542P4dbruhYPHCEU,95
|
31
|
+
opik_optimizer/evolutionary_optimizer/crossover_ops.py,sha256=7kMvAWOiEA0R5PQMRdnLqbS1uCmIDVzLppNSsPsIO7o,7740
|
32
|
+
opik_optimizer/evolutionary_optimizer/evaluation_ops.py,sha256=5uqTnPA3_ohncmMaYE6HQXNrrskuLAECAYNU5cD5CKY,2517
|
33
|
+
opik_optimizer/evolutionary_optimizer/evolutionary_optimizer.py,sha256=CQzIGcfxLjrxFVDOpR5EY0lOJ_d0fatf67Rqlva_yq0,40461
|
34
|
+
opik_optimizer/evolutionary_optimizer/helpers.py,sha256=yWYW5JyVbr2smDByc9yaHCYbUS6cw35RBI7lM3pT69A,607
|
35
|
+
opik_optimizer/evolutionary_optimizer/llm_support.py,sha256=j0JnzDyUVp97rImu9UjBCHPY9N7-NytwG0QBzqD-iZI,5382
|
36
|
+
opik_optimizer/evolutionary_optimizer/mutation_ops.py,sha256=AG-a_ASBt5M85W2I79rvpCnzVnFnTD_8gJH6sCTlkDk,11853
|
37
|
+
opik_optimizer/evolutionary_optimizer/population_ops.py,sha256=dkQf9AkRWFtKFGbeMJHinPrjY9lOtYk18Wwmr9uGgdU,9816
|
38
|
+
opik_optimizer/evolutionary_optimizer/prompts.py,sha256=m-hl1KyaBj2KA7nPlYZPLlutraNfvZnT_yeCe1t4iQk,14954
|
39
|
+
opik_optimizer/evolutionary_optimizer/reporting.py,sha256=pLHz9-FvB9tyA3mx91f8mtuwB_LA1zWZMglrZcdXPU0,11803
|
40
|
+
opik_optimizer/evolutionary_optimizer/style_ops.py,sha256=XmGFS5s2Qr2DJMZVVsI_C6LqJ5zoyxpeWAtGmdg3TnA,3082
|
41
|
+
opik_optimizer/few_shot_bayesian_optimizer/__init__.py,sha256=VuH7FOROyGcjMPryejtZC-5Y0QHlVTFLTGUDgNqRAFw,113
|
42
|
+
opik_optimizer/few_shot_bayesian_optimizer/few_shot_bayesian_optimizer.py,sha256=iXf765o12084ME0uvpPtZ5ysserpNhU1c6o88XrsqEE,27611
|
43
|
+
opik_optimizer/few_shot_bayesian_optimizer/reporting.py,sha256=OMpLG4xsM6K7oQcP_nbnky47NklVsowNDlK6WliZM10,6311
|
44
|
+
opik_optimizer/gepa_optimizer/__init__.py,sha256=XcPah5t4mop7UCFo69E9l45Mem49-itqkQT7_J1aWOA,71
|
45
|
+
opik_optimizer/gepa_optimizer/adapter.py,sha256=UJ0F4MLxVQ-40LcjA5pibuIlS6yxM-SMZ25n0iLQcMk,5107
|
46
|
+
opik_optimizer/gepa_optimizer/gepa_optimizer.py,sha256=3HHYlVZGaBkufHHTOxuuPrDyxE8ysQuhRo3UMMGlguw,21759
|
47
|
+
opik_optimizer/gepa_optimizer/reporting.py,sha256=F0cxYSjRuFAszgi3rgqwH1A-KH26kZOLtENP7x1xrQs,5154
|
48
|
+
opik_optimizer/mcp_utils/__init__.py,sha256=BsWQT8nAa6JV6zcOD__OvPMepUS2IpJD4J2rnAXhpuU,710
|
49
|
+
opik_optimizer/mcp_utils/mcp.py,sha256=UylgpTJsybszS433_kuTAgKH-PPde-VHjHVelMardFs,18466
|
50
|
+
opik_optimizer/mcp_utils/mcp_second_pass.py,sha256=p2Knlxg1CKIZVMBbdskdRDqw1BRrnjM4gkcwAZtggm8,4519
|
51
|
+
opik_optimizer/mcp_utils/mcp_simulator.py,sha256=bLL7iVAGMRc8Mb2j_XpSjlkr6TvQLI90hkS4ifnwLqs,3427
|
52
|
+
opik_optimizer/mcp_utils/mcp_workflow.py,sha256=mtfH6A__SxmsIOVHRQCdnQa12hi8T9MSmk2OdJtzCGA,15767
|
53
|
+
opik_optimizer/meta_prompt_optimizer/__init__.py,sha256=syiN2_fMm5iZDQezZCHYe-ZiGOIPlBkLt49Sa1kuR70,97
|
54
|
+
opik_optimizer/meta_prompt_optimizer/meta_prompt_optimizer.py,sha256=KRB0l5HY7CA-zCDSrtnk5N14gZTzndR_Ds-ASkgiP4Y,51158
|
55
|
+
opik_optimizer/meta_prompt_optimizer/reporting.py,sha256=Py30NDYFNPzb8XrCXibQRtBC3vjjViQG74uG-O6lhXE,7783
|
56
|
+
opik_optimizer/mipro_optimizer/__init__.py,sha256=7sMq9OSWyjITqK7sVtkO9fhG1w6KRE8bN7V52CKaGvo,94
|
57
|
+
opik_optimizer/mipro_optimizer/_lm.py,sha256=A5Bs7JqdRawkjCLp_vuFnNzCD3cMMrvOORszZUtBhRU,16699
|
58
|
+
opik_optimizer/mipro_optimizer/_mipro_optimizer_v2.py,sha256=gK9kepdNqIWK3JFVcHNPTrnRne7myn3zjbv_aOuK9dw,39314
|
59
|
+
opik_optimizer/mipro_optimizer/mipro_optimizer.py,sha256=icgGMQ3TBilW1UX92Lq8wa1-6aia5Qn7JCyD5bdIhhw,24437
|
60
|
+
opik_optimizer/mipro_optimizer/utils.py,sha256=pP3mvai_GQmwUhcchVOiW1xPI3LatpXclE_5XvBYwTw,2493
|
61
|
+
opik_optimizer/optimization_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
|
+
opik_optimizer/optimization_config/chat_prompt.py,sha256=d3jwM1UvUeRQOSsYHa5GD842VO3JWjVDmB3ROUGp57c,7089
|
63
|
+
opik_optimizer/optimization_config/configs.py,sha256=EGacRNnl6TeWuf8RNsxpP6Nh5JhogjK-JxKllK8dQr0,413
|
64
|
+
opik_optimizer/optimization_config/mappers.py,sha256=4uBoPaIvCo4bqt_w-4rJyVe2LMAP_W7p6xxnDmGT-Sk,1724
|
65
|
+
opik_optimizer/utils/__init__.py,sha256=Ee0SnTPOcwRwp93M6Lh-X913lfSIwnvCiYYh5cpdRQE,486
|
66
|
+
opik_optimizer/utils/core.py,sha256=fTDO_M30DDvsGYBUE8fs0lsNpdwkE_T4Bz_RIR75Sts,13768
|
67
|
+
opik_optimizer/utils/dataset_utils.py,sha256=dqRUGOekjeNWL0J15R8xFwLyKJDJynJXzVyQmt8rhHA,1464
|
68
|
+
opik_optimizer/utils/prompt_segments.py,sha256=1zUITSccJ82Njac1rmANzim4WWM6rVac61mfluS7lFE,5931
|
69
|
+
opik_optimizer-1.1.0.dist-info/licenses/LICENSE,sha256=V-0VHJOBdcA_teT8VymvsBUQ1-CZU6yJRmMEjec_8tA,11372
|
70
|
+
opik_optimizer-1.1.0.dist-info/METADATA,sha256=KQied4TunQ1_HivBclDEIu-o2uwqY7vdd0PJiuX_idw,9481
|
71
|
+
opik_optimizer-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
72
|
+
opik_optimizer-1.1.0.dist-info/top_level.txt,sha256=ondOlpq6_yFckqpxoAHSfzZS2N-JfgmA-QQhOJfz7m0,15
|
73
|
+
opik_optimizer-1.1.0.dist-info/RECORD,,
|
@@ -0,0 +1,203 @@
|
|
1
|
+
Copyright (c) Comet ML, Inc
|
2
|
+
|
3
|
+
Apache License
|
4
|
+
Version 2.0, January 2004
|
5
|
+
http://www.apache.org/licenses/
|
6
|
+
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
|
+
|
9
|
+
1. Definitions.
|
10
|
+
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
13
|
+
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
15
|
+
the copyright owner that is granting the License.
|
16
|
+
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
18
|
+
other entities that control, are controlled by, or are under common
|
19
|
+
control with that entity. For the purposes of this definition,
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
21
|
+
direction or management of such entity, whether by contract or
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
24
|
+
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
26
|
+
exercising permissions granted by this License.
|
27
|
+
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
29
|
+
including but not limited to software source code, documentation
|
30
|
+
source, and configuration files.
|
31
|
+
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
33
|
+
transformation or translation of a Source form, including but
|
34
|
+
not limited to compiled object code, generated documentation,
|
35
|
+
and conversions to other media types.
|
36
|
+
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
38
|
+
Object form, made available under the License, as indicated by a
|
39
|
+
copyright notice that is included in or attached to the work
|
40
|
+
(an example is provided in the Appendix below).
|
41
|
+
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
48
|
+
the Work and Derivative Works thereof.
|
49
|
+
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
51
|
+
the original version of the Work and any modifications or additions
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
63
|
+
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
66
|
+
subsequently incorporated within the Work.
|
67
|
+
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
74
|
+
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
80
|
+
where such license applies only to those patent claims licensable
|
81
|
+
by such Contributor that are necessarily infringed by their
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
84
|
+
institute patent litigation against any entity (including a
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
87
|
+
or contributory patent infringement, then any patent licenses
|
88
|
+
granted to You under this License for that Work shall terminate
|
89
|
+
as of the date such litigation is filed.
|
90
|
+
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
93
|
+
modifications, and in Source or Object form, provided that You
|
94
|
+
meet the following conditions:
|
95
|
+
|
96
|
+
(a) You must give any other recipients of the Work or
|
97
|
+
Derivative Works a copy of this License; and
|
98
|
+
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
100
|
+
stating that You changed the files; and
|
101
|
+
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
104
|
+
attribution notices from the Source form of the Work,
|
105
|
+
excluding those notices that do not pertain to any part of
|
106
|
+
the Derivative Works; and
|
107
|
+
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
110
|
+
include a readable copy of the attribution notices contained
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
113
|
+
of the following places: within a NOTICE text file distributed
|
114
|
+
as part of the Derivative Works; within the Source form or
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
116
|
+
within a display generated by the Derivative Works, if and
|
117
|
+
wherever such third-party notices normally appear. The contents
|
118
|
+
of the NOTICE file are for informational purposes only and
|
119
|
+
do not modify the License. You may add Your own attribution
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
122
|
+
that such additional attribution notices cannot be construed
|
123
|
+
as modifying the License.
|
124
|
+
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
126
|
+
may provide additional or different license terms and conditions
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
130
|
+
the conditions stated in this License.
|
131
|
+
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
135
|
+
this License, without any additional terms or conditions.
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
137
|
+
the terms of any separate license agreement you may have executed
|
138
|
+
with Licensor regarding such Contributions.
|
139
|
+
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
142
|
+
except as required for reasonable and customary use in describing the
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
144
|
+
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
154
|
+
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
160
|
+
incidental, or consequential damages of any character arising as a
|
161
|
+
result of this License or out of the use or inability to use the
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
164
|
+
other commercial damages or losses), even if such Contributor
|
165
|
+
has been advised of the possibility of such damages.
|
166
|
+
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
170
|
+
or other liability obligations and/or rights consistent with this
|
171
|
+
License. However, in accepting such obligations, You may act only
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
176
|
+
of your accepting any such warranty or additional liability.
|
177
|
+
|
178
|
+
END OF TERMS AND CONDITIONS
|
179
|
+
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
181
|
+
|
182
|
+
To apply the Apache License to your work, attach the following
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
184
|
+
replaced with your own identifying information. (Don't include
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
186
|
+
comment syntax for the file format. We also recommend that a
|
187
|
+
file or class name and description of purpose be included on the
|
188
|
+
same "printed page" as the copyright notice for easier
|
189
|
+
identification within third-party archives.
|
190
|
+
|
191
|
+
Copyright 2025 Comet ML, Inc
|
192
|
+
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
194
|
+
you may not use this file except in compliance with the License.
|
195
|
+
You may obtain a copy of the License at
|
196
|
+
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
198
|
+
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202
|
+
See the License for the specific language governing permissions and
|
203
|
+
limitations under the License.
|