File tree Expand file tree Collapse file tree 2 files changed +21
-16
lines changed
components/pages-shared/automations/AddEditRuleDialog Expand file tree Collapse file tree 2 files changed +21
-16
lines changed Original file line number Diff line number Diff line change @@ -183,24 +183,20 @@ const AddEditRuleDialog: React.FC<AddEditRuleDialogProps> = ({
183
183
const handleScopeChange = useCallback (
184
184
( value : EVALUATORS_RULE_SCOPE ) => {
185
185
const applyChange = ( ) => {
186
- if ( value === EVALUATORS_RULE_SCOPE . thread ) {
187
- form . setValue ( "uiType" , UI_EVALUATORS_RULE_TYPE . llm_judge ) ;
188
- }
189
-
190
186
const { uiType } = form . getValues ( ) ;
191
187
const type = getBackendRuleType ( value , uiType ) ;
192
188
193
189
form . setValue ( "scope" , value ) ;
194
190
form . setValue ( "type" , type ) ;
195
191
196
- form . resetField ( "llmJudgeDetails" , {
197
- defaultValue : cloneDeep ( DEFAULT_LLM_AS_JUDGE_DATA [ value ] ) ,
198
- keepDirty : false ,
199
- } ) ;
200
- form . resetField ( "pythonCodeDetails" , {
201
- defaultValue : cloneDeep ( DEFAULT_PYTHON_CODE_DATA [ value ] ) ,
202
- keepDirty : false ,
203
- } ) ;
192
+ form . setValue (
193
+ "llmJudgeDetails" ,
194
+ cloneDeep ( DEFAULT_LLM_AS_JUDGE_DATA [ value ] ) ,
195
+ ) ;
196
+ form . setValue (
197
+ "pythonCodeDetails" ,
198
+ cloneDeep ( DEFAULT_PYTHON_CODE_DATA [ value ] ) ,
199
+ ) ;
204
200
} ;
205
201
206
202
if (
@@ -464,7 +460,7 @@ const AddEditRuleDialog: React.FC<AddEditRuleDialogProps> = ({
464
460
) }
465
461
/>
466
462
467
- { ! isEdit && ! isThreadScope && (
463
+ { ! isEdit && (
468
464
< FormField
469
465
control = { form . control }
470
466
name = "uiType"
Original file line number Diff line number Diff line change @@ -585,14 +585,23 @@ export const DEFAULT_PYTHON_CODE_THREAD_DATA: PythonCodeDetailsThreadForm = {
585
585
metric :
586
586
"from typing import Union, List, Any\n" +
587
587
"from opik.evaluation.metrics import base_metric, score_result\n" +
588
- "from opik.evaluation.types import Conversation \n" +
588
+ "from opik.evaluation.metrics.conversation import conversation_thread_metric, types \n" +
589
589
"\n" +
590
- "class MyCustomMetric(base_metric.BaseMetric ):\n" +
590
+ "class MyCustomMetric(conversation_thread_metric.ConversationThreadMetric ):\n" +
591
591
' """A custom metric for evaluating conversation threads."""\n' +
592
+ " def __init__(\n" +
593
+ " self,\n" +
594
+ ' name: str = "my_custom_thread_metric",\n' +
595
+ " ):\n" +
596
+ " super().__init__(\n" +
597
+ " name=name,\n" +
598
+ " )\n" +
592
599
"\n" +
593
600
" def score(\n" +
594
- " self, conversation: Conversation, **kwargs: Any\n" +
601
+ " self, conversation: types. Conversation, **kwargs: Any\n" +
595
602
" ) -> Union[score_result.ScoreResult, List[score_result.ScoreResult]]:\n" +
603
+ " # conversation is a List[Dict] where each dict has:\n" +
604
+ ' # {"role": "user" | "assistant", "content": "message text"}\n' +
596
605
" # Add you logic here\n" +
597
606
"\n" +
598
607
" return score_result.ScoreResult(\n" +
You can’t perform that action at this time.
0 commit comments