Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ragas/llms/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ def to_string(self) -> str:
"""
Generate the prompt string from the variables.
"""
prompt_str = self.instruction + "\n"
added_json_instruction = (
"\nOutput in only valid JSON format."
if self.output_type.lower() == "json"
else ""
)
prompt_str = self.instruction + added_json_instruction + "\n"

if self.examples:
# Format the examples to match the Langchain prompt template
Expand Down
2 changes: 1 addition & 1 deletion src/ragas/metrics/_context_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

CONTEXT_PRECISION = Prompt(
name="context_precision",
instruction="""Given question, answer and context verify if the context was useful in arriving at the given answer. Give verdict as "1" if useful and "0" if not. """,
instruction="""Given question, answer and context verify if the context was useful in arriving at the given answer. Give verdict as "1" if useful and "0" if not with json output. """,
examples=[
{
"question": """What can you tell me about albert Albert Einstein?""",
Expand Down