-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NO WORKING CODE FOR RAGAS 0.2 IN THE ENTIRE INTERNET #1867
Comments
hey there @GenAI-Rocky - I'm sorry to see that your having a hard time but there is a bug in the code you posted. The you can read more about this format here: https://docs.ragas.io/en/stable/concepts/components/eval_dataset/ this is one converstion that might help # Create the dataset in the correct format
data = {
"chat_history": [chat_history], # Wrap in list since we have one example
"user_input": [user_input],
"response": [assistant_response]
}
# Convert to Hugging Face Dataset format
dataset = Dataset.from_dict(data)
# Evaluate the response with chat history
try:
score = evaluate(dataset)
print(f"Score: {score}")
except Exception as e:
print(f"Error during evaluation: {e}") can you check if it works - feel free to post any further questions you might have 🙂 PS: I'll also add a better error message here so users have an easier time debugging |
@dosu can you help him out? |
The error you're encountering is due to the from ragas import SingleTurnSample, EvaluationDataset, evaluate
# Chat history, user input, and assistant response related to Cricket
chat_history = ["Who won the last Cricket World Cup?", "England won the last Cricket World Cup."]
user_input = "Who was the captain of the winning team?"
assistant_response = "Eoin Morgan was the captain of the England team that won the last Cricket World Cup."
# Create a SingleTurnSample
sample = SingleTurnSample(
user_input=user_input,
retrieved_contexts=chat_history,
response=assistant_response,
reference="Eoin Morgan"
)
# Create the EvaluationDataset
dataset = EvaluationDataset(samples=[sample])
# Evaluate the response with chat history
try:
score = evaluate(dataset)
print(f"Score: {score}")
except Exception as e:
print(f"Error during evaluation: {e}")
# Print chat history
print("Chat History:")
for message in chat_history:
print(f"User: {message}") This code creates a To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
closing this now - feel free to reopen if needed |
I have checked the documentation and related resources and couldn't resolve my bug.
Describe the bug
Encountering error, "'list' object has no attribute 'get_sample_type'" while running the below code.
I have been surfing the entire Internet but couldn't find the working code for RAGAS Version 0.2.
Ragas version: 0.2.11
Python version: 3.12
Code to Reproduce
Error trace:
Expected behavior
The code should be executed without any error and the metric values should be printed
The text was updated successfully, but these errors were encountered: