Skip to content
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

Feature Request: Have optional vars in assertions with ability to define fallbacks #766

Open
reallyinvincible opened this issue May 7, 2024 · 0 comments

Comments

@reallyinvincible
Copy link

While writing custom assertions for test cases, there are several times we need an optional parameter to fine tune the assertions or provide an ability to switch custom logic on the fly (Like switching between different rubrics or based on the vars).

For eg.

  1. I want to make threshold_percentage in the following yaml snippet optional. I have a logic in custom python assertion script (llm_similarity_rubrics_test.py) to directly use 80% if no value is provided.
  - vars:
      question: Help me preparing a birthday cake!
      similarity_text: I'm sorry, but as a customer service AI assistant,
        I'm focused on helping you with your shopping experience.
        If you have any questions related to that, please feel free to ask!
      threshold_percentage: 70  #Removing this line from here should also work since I have fallbacks in custom python code
    assert:
      - type: python
        value: file://llm_similarity_rubrics_test.py
  1. I want to have a separate custom python rubric that needs to have separate set of parameters to be passed in the same yaml file
  - vars:
      question: Help me preparing a birthday cake!
      contains_text: I'm focused on helping you with your shopping experience. 
      #This rubrics just checks if a particular piece of text is in output or not. I should be able to switch the params for it on the fly.
    assert:
      - type: python
        value: file://llm_contains_rubrics_test.py

I'm also quite new to promptfoo so if there are other ways to achieve this, please educate me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant