jojortz's picture
add content from extract-leaderboard-gradio
f745baf
raw
history blame
1.28 kB
class Postprocessor:
"""Postprocessor."""
def run(self, text: str) -> str:
"""Postprocess."""
raise NotImplementedError("Postprocess method is not implemented")
class ClaudePostprocessor(Postprocessor):
"""Claude Postprocessor."""
def run(self, text: str) -> str:
"""Clean the response from the Claude model.
Args:
text (str): The response from the Claude model.
Returns:
str: The cleaned response.
"""
# remove the ```markdown and ``` at the beginning and end of the text
text = text.replace("```markdown", "").replace("```", "")
# Remove any leading or trailing whitespace
text = text.strip()
return text
class GPTPostprocessor(Postprocessor):
"""GPT Postprocessor."""
def run(self, text: str) -> str:
"""Clean the response from the GPT model.
Args:
text (str): The response from the GPT model.
Returns:
str: The cleaned response.
"""
# remove the ```markdown and ``` at the beginning and end of the text
text = text.replace("```markdown", "").replace("```", "")
# Remove any leading or trailing whitespace
text = text.strip()
return text