Combine GPT3 with RASA

I am using RASA forms to take information from user. I need to combine GPT3 chatbot feature for any out of scope question ask by user inside form filling. I created a custom action which uses GPT3 chatbot. I add a rule for out of scope intent, which will activate custom function and use will chat with gpt3 bot. But rule is not getting trigger when I enter out of scope query while chatting with bot. Is anybody already use combination of RASA and GPT3. Can you help me how we can create a rule for this.



Thank you for your question, you could try this:

- rule: Handle out of scope
  - active_loop: user_info_form
  - intent: out_of_scope
  - action: action_call_gpt3
  - action: user_info_form
  - active_loop: user_info_form

Also you could check my tutorial about Rasa and Blenderbot integration to see different options. I will add your case later, thank you.

hello @rupesh2306 ,

I am trying to integrate rasa with gpt3, but not getting the proper response. Can help me out to look at my code and tell me issue.

def gpt3(text):
    response = openai.Completion.create(
        # engine="ada",
        prompt="\n\n" + text,
        stop=[" \n\n"]
    return response['choices'][0]['text']

class ActionDefaultFallback(Action):
    def init(self):
        # self.gpt3 = gpt3()

    def name(self) -> Text:
        return "action_default_fallback"

    async def run(self, dispatcher, tracker, domain):
        query = tracker.latest_message['text']

        return [UserUtteranceReverted()]

Not able to understand the issue. Help me out to solve this.




Could you expand the problem in “the proper response”? Action seems ok to me. I’ve never used GPT-3. Does you gpt3 function respond okay?

Thanks @artemsnegirev for your response.

If I separately run the def gpt3(text) function than getting the proper response. But using rasa server it not giving proper response, some meaning less response. I guess because of execution time of gpt-3 api in rasa server. Do you have any solution how we can solve this issue.

Do i correctly understand that if you send to gpt3 function separately some text (for example “hello how are you”), then you get a proper answer and if you send to gpt3 function using rasa the same text you don’t get proper answer?

@artemsnegirev Yes, exactly

Have you tried to check you get equal query text as you input text to Rasa? If they are equal, i have no idea.

yes, both are equal.

Hi, wondering if you found a solution here. Thank you!