"vscode:/vscode.git/clone" did not exist on "9c4d3b2ae3eed7d82c52678435527ad1091c7df3"
Commit a7362d8b authored by Baber's avatar Baber
Browse files

add `parse_generations` to OpenAIChatCompletion

parent 3e28eed1
......@@ -295,3 +295,15 @@ class OpenAIChatCompletion(LocalChatCompletion):
elif "o3" in self.model:
output.pop("temperature")
return output
@staticmethod
def parse_generations(outputs: Union[Dict, List[Dict]], **kwargs) -> List[str]:
res = []
if not isinstance(outputs, list):
outputs = [outputs]
for out in outputs:
tmp = [None] * len(out["choices"])
for choices in out["choices"]:
tmp[choices["index"]] = choices["message"]["content"]
res = res + tmp
return res
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment