Coder Social home page Coder Social logo

Comments (2)

drazvan avatar drazvan commented on July 18, 2024

Hi @jamescalam!

It depends on how you're using NeMo Guardrails. If you're using directly the generate/generate_asyc methods, you can send an additional message at the beginning of the conversation (or anywhere inside) with the role set to context. See the example here: https://github.com/NVIDIA/NeMo-Guardrails/blob/main/docs/user_guide/python-api.md#message-generation

new_message = app.generate(messages=[{
    "role": "context",
    "content": {
        "some_var": "some_value"
    }
},
{
    "role": "user",
    "content": "Hello! What can you do for me?"
}])

We can add support for register_context_var similar to register_action. If you have a bit of time to contribute, I can point you in the right direction. What is your use case for this?

from nemo-guardrails.

jamescalam avatar jamescalam commented on July 18, 2024

Okay, I wasn't aware that we could use the context role like this, that is very helpful. The use case would be where we want to include details like $name, $company_name, etc.

I'm still trying to familiarize myself with the library and Colang so I'm not sure if this is a valid use case too, but in the case that I'd like the flows to vary based on whether certain requirements have been satisfied, it would be helpful to do that with a register_context_var method. For example, my Colang file could look like:

define flow
    # after X criteria has been satisfied, like the conversation has continued for more than 2 minutes
    user ask question
    if $long_conversation
        bot express tiredness
    else
        bot answer question

And in Python we'd have a check for time spent since the conversation began, and once that exceeds 2 minutes we would do something like rails.register_context_var("long_conversation", True)

Happy to contribute if it seems relevant

from nemo-guardrails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.