1
1
from typing import Any , Optional , Union
2
2
import pydantic
3
- import asyncstdlib as a
4
3
5
4
from opik .evaluation .metrics import base_metric , score_result
6
5
from opik .evaluation .models import base_model , models_factory
@@ -52,11 +51,14 @@ def __init__(
52
51
self ._chain_of_thought_response = ""
53
52
54
53
def llm_chain_of_thought (self ) -> str :
55
- prompt = template .G_EVAL_COT_TEMPLATE .format (
56
- task_introduction = self .task_introduction ,
57
- evaluation_criteria = self .evaluation_criteria ,
58
- )
59
- return self ._model .generate_string (input = prompt )
54
+ if not self ._chain_of_thought_response :
55
+ prompt = template .G_EVAL_COT_TEMPLATE .format (
56
+ task_introduction = self .task_introduction ,
57
+ evaluation_criteria = self .evaluation_criteria ,
58
+ )
59
+ self ._chain_of_thought_response = self ._model .generate_string (input = prompt )
60
+
61
+ return self ._chain_of_thought_response
60
62
61
63
62
64
async def allm_chain_of_thought (self ) -> str :
@@ -144,10 +146,6 @@ async def ascore(
144
146
llm_query = template .G_EVAL_QUERY_TEMPLATE .format (
145
147
task_introduction = self .task_introduction ,
146
148
evaluation_criteria = self .evaluation_criteria ,
147
- << << << < HEAD
148
-
149
- == == == =
150
- > >> >> >> 857e26 be (COT simplified )
151
149
chain_of_thought = await self .allm_chain_of_thought (),
152
150
input = output ,
153
151
)
@@ -170,4 +168,4 @@ async def ascore(
170
168
content = model_output ,
171
169
name = self .name ,
172
170
log_probs_supported = self ._log_probs_supported ,
173
- )
171
+ )
0 commit comments