Skip to content

Commit c09cfe1

Browse files
committed
feat(InputMocking): read input schema from entrypoint to pass to mocker
1 parent 9b79004 commit c09cfe1

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

samples/calculator/evals/eval-sets/default.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@
6464
"evalSetId": "default-eval-set-id",
6565
"createdAt": "2025-09-04T18:54:58.378Z",
6666
"updatedAt": "2025-09-04T18:55:55.416Z"
67+
},
68+
{
69+
"id": "test-with-llm-input-mocking",
70+
"name": "Test with LLM input mocking",
71+
"inputs": {},
72+
"expectedOutput": {
73+
"result": 35
74+
},
75+
"expectedAgentBehavior": "",
76+
"inputMockingStrategy": {
77+
"prompt": "Generate a multiplication calculation where the first number is 5 and the second number is 7",
78+
"model": {
79+
"model": "gpt-4o-mini-2024-07-18",
80+
"temperature": 0.3
81+
}
82+
},
83+
"evalSetId": "default-eval-set-id",
84+
"createdAt": "2025-09-04T18:54:58.378Z",
85+
"updatedAt": "2025-09-04T18:55:55.416Z"
6786
}
6887
],
6988
"modelSettings": [],

src/uipath/_cli/_evals/_runtime.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import json
33
import logging
4+
import os
45
import uuid
56
from collections import defaultdict
67
from pathlib import Path
@@ -140,6 +141,7 @@ class UiPathEvalContext(UiPathRuntimeContext):
140141
workers: Optional[int] = 1
141142
eval_set: Optional[str] = None
142143
eval_ids: Optional[List[str]] = None
144+
input_schema: Optional[Dict[str, Any]] = None
143145

144146

145147
class UiPathEvalRuntime(UiPathBaseRuntime, Generic[T, C]):
@@ -156,6 +158,7 @@ def __init__(
156158
self.factory: UiPathRuntimeFactory[T, C] = factory
157159
self.event_bus: EventBus = event_bus
158160

161+
self._initialize_input_schema()
159162
self.span_exporter: ExecutionSpanExporter = ExecutionSpanExporter()
160163
self.span_collector: ExecutionSpanCollector = ExecutionSpanCollector()
161164

@@ -167,6 +170,18 @@ def __init__(
167170
self.logs_exporter: ExecutionLogsExporter = ExecutionLogsExporter()
168171
self.execution_id = str(uuid.uuid4())
169172

173+
def _initialize_input_schema(self) -> None:
174+
"""Initialize the input schema using a temporary runtime to get the entrypoint."""
175+
temp_context = self.factory.new_context(
176+
entrypoint=self.context.entrypoint, runtime_dir=os.getcwd()
177+
)
178+
temp_runtime = self.factory.from_context(temp_context)
179+
self.context.input_schema = temp_runtime.get_entrypoint.input
180+
181+
# Ensure additionalProperties is set for OpenAI strict mode compatibility
182+
if "additionalProperties" not in self.context.input_schema:
183+
self.context.input_schema["additionalProperties"] = False
184+
170185
@classmethod
171186
def from_eval_context(
172187
cls,
@@ -430,9 +445,7 @@ async def _generate_input_for_eval(
430445
self, eval_item: EvaluationItem
431446
) -> EvaluationItem:
432447
"""Use LLM to generate a mock input for an evaluation item."""
433-
# TODO(bai): get the input schema from agent definition, once it is available there.
434-
input_schema: dict[str, Any] = {}
435-
generated_input = await generate_llm_input(eval_item, input_schema)
448+
generated_input = await generate_llm_input(eval_item, self.context.input_schema)
436449
updated_eval_item = eval_item.model_copy(update={"inputs": generated_input})
437450
return updated_eval_item
438451

tests/cli/eval/test_evaluate.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from uipath._cli._evals._runtime import UiPathEvalContext
66
from uipath._cli._runtime._contracts import UiPathRuntimeContext, UiPathRuntimeFactory
77
from uipath._cli._runtime._runtime import UiPathRuntime
8+
from uipath._cli.models.runtime_schema import Entrypoint
89
from uipath._events._event_bus import EventBus
910

1011

@@ -18,12 +19,23 @@ async def test_evaluate():
1819
async def identity(input: Any) -> Any:
1920
return input
2021

21-
class MyFactory(UiPathRuntimeFactory[UiPathRuntime, UiPathRuntimeContext]):
22+
class TestRuntime(UiPathRuntime):
23+
@property
24+
def get_entrypoint(self) -> Entrypoint:
25+
return Entrypoint(
26+
file_path="test.py",
27+
unique_id="test",
28+
type="workflow",
29+
input={"type": "object", "properties": {}},
30+
output={"type": "object", "properties": {}},
31+
)
32+
33+
class MyFactory(UiPathRuntimeFactory[TestRuntime, UiPathRuntimeContext]):
2234
def __init__(self):
2335
super().__init__(
24-
UiPathRuntime,
36+
TestRuntime,
2537
UiPathRuntimeContext,
26-
runtime_generator=lambda context: UiPathRuntime(
38+
runtime_generator=lambda context: TestRuntime(
2739
context, executor=identity
2840
),
2941
)

0 commit comments

Comments
 (0)