Skip to content

Commit fdba9a2

Browse files
ssoimaSergiu Soima
andauthored
solved issue that adaptation crashes when havig multiple nested promp… (#1181)
I have faced the issue that when I adapt some prompts, some of the key-value pairs are objects itself and then do not get stored properly. The adaptation does not fail, however, when loading those prompt, they break since they are not in proper json format. This fix solves this particular issue I am using json.dumps on those object to store json-conform strings. Co-authored-by: Sergiu Soima <[email protected]>
1 parent fcee39e commit fdba9a2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ragas/llms/prompt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def format(self, **kwargs: t.Any) -> PromptValue:
158158
raise ValueError(
159159
f"Input variables {self.input_keys} do not match with the given parameters {list(kwargs.keys())}"
160160
)
161+
for key, value in kwargs.items():
162+
if isinstance(value, str):
163+
kwargs[key] = json.dumps(value)
164+
161165
prompt = self.to_string()
162166
return PromptValue(prompt_str=prompt.format(**kwargs))
163167

0 commit comments

Comments
 (0)