NVIDIA / NeMo-Guardrails

NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems.
Other
4.22k stars 402 forks source link

feat: add relevant chunks prompts #745

Closed Pouyanpi closed 2 months ago

Pouyanpi commented 2 months ago

Add relevant chunks for generate_flow_continuation and generate_user_intent_and_bot_action_from_user_action tasks

tested with abc_v2 config (also for meta/llama3-70b-instruct) without kb folder.

from nemoguardrails import LLMRails, RailsConfig

config = RailsConfig.from_path("./examples/bots/abc_v2")
rails = LLMRails(config)

response = rails.generate(messages=[{
    "role": "context",
    "content": {
        "relevant_chunks": """
            Employees are eligible for the following time off:
              * Vacation: 15 days per year, accrued monthly.
              * Sick leave: 25 days per year, accrued monthly.
              * Personal days: 5 days per year, accrued monthly.
              * Paid holidays: New Year's Day, Memorial Day, Independence Day, Thanksgiving Day, Christmas Day.
              * Bereavement leave: 3 days paid leave for immediate family members, 1 day for non-immediate family members. """
    }
},{
    "role": "user",

    "content": "How many sick leaves do employees have?"
}])

response["content"] must contain 25 days.