Helper class that provides a standard way to create an ABC using inheritance.
Example Usage
from ragas_experimental.embedding import ragas_embeddingfrom ragas_experimental.prompt import Promptfrom openai import OpenAIembedding = ragas_embedding(provider="openai", client=OpenAI(),model="text-embedding-3-small")# Create a basic promptprompt = Prompt( instruction="Evaluate if given answer {response} is same as expected answer {expected_answer}")# Add examples with dict inputs and dict outputsprompt.add_example( {"response": "You can get a full refund if you miss your flight.","expected_answer": "Refunds depend on ticket type; only refundable tickets qualify for full refunds." }, {"score": "fail"})prompt = DynamicFewShotPrompt.from_prompt( prompt, embedding_model=embedding, num_examples=1)prompt.add_example( {"response": "Bananas are high in potassium and great for quick energy.","expected_answer": "Bananas provide potassium and are a good source of fast-digesting carbohydrates." }, {"score": "pass"})prompt.add_example( {"response": "Using two-factor authentication greatly enhances account security.","expected_answer": "Two-factor authentication adds a layer of protection by requiring a second form of identity verification." }, {"score": "fail"})prompt.example_store.get_examples({"response": "Regularly updating your software reduces the risk of vulnerabilities.","expected_answer": "Keeping software up to date helps patch known security flaws and prevents exploits." })print(prompt.format(**{"response": "Regularly updating your software reduces the risk of vulnerabilities.","expected_answer": "Keeping software up to date helps patch known security flaws and prevents exploits." }))
Evaluate if given answer Regularly updating your software reduces the risk of vulnerabilities. is same as expected answer Keeping software up to date helps patch known security flaws and prevents exploits.
Examples:
Example 1:
Input:
response: Using two-factor authentication greatly enhances account security.
expected_answer: Two-factor authentication adds a layer of protection by requiring a second form of identity verification.
Output:
score: fail