Rasa Pro Tutorial with Azure OpenAI Service not working - Rasa CALM - Rasa Community Forum

Rasa Pro Tutorial with Azure OpenAI Service not working

post by aoezdTchibo on Apr 30, 2024

Greetings!
I am having problems running the Rasa Pro tutorial locally. My config.yml looks like this:

recipe: default.v1
language: en
pipeline:
- name: LLMCommandGenerator
  llm:
    model_name: gpt-3.5-turbo
    api_type: azure
    api_base: https://[CUSTOM].openai.azure.com/
    api_version: 2023-12-01-preview
    engine: [CUSTOM]

policies:
- name: FlowPolicy

In addition, I have stored the OpenAI API key as an environment variable (OPENAI_API_KEY) within my terminal. If I execute rasa train in my terminal I get the following error:

(.venv) ~/PycharmProjects/rasa-pro-calm-demo
rasa train
/Users/User/PycharmProjects/rasa-pro-calm-demo/.venv/lib/python3.10/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic.error_wrappers:ValidationError` has been moved to `pydantic:ValidationError`.
  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
...  
2024-04-30 16:40:24 ERROR    rasa.dialogue_understanding.generator.llm_command_generator  - [error    ] Flow retrieval store is inaccessible. error=AuthenticationError(message='Incorrect API key provided: *******************. You can find your API key at https://platform.openai.com/account/api-keys.', http_status=401, request_id=None) event_key=llm_command_generator.train.failed

It seems that the configuration in the config.yml regarding the LLM is not taken over.


post by emilymoore04 on Apr 30, 2024

The error message clearly shows that the API key provided is incorrect. You should double check that you’ve correctly set up the environment variable OPENAI_API_KEY in your terminal.

Make sure that you’ve copied the API key accurately and that there are no extra spaces or characters and verify that the API key hasn’t expired and that it has the necessary permissions to access the OpenAI service.

Once you’ve confirmed that the API key is correct, try running the rasa train command again. If the issue persists, you may need to troubleshoot further by checking the API key’s permissions and verifying the endpoint configuration in your config.yml file.


post by camattin on Apr 30, 2024

Hi, this is due to the flow_retrieval being enabled by default. Note this line from your debug output:

2024-04-30 16:40:23 INFO rasa.dialogue_understanding.generator.llm_command_generator - [info ] llm_command_generator.flow_retrieval.enabled

If your assistant has a large number of flows you may find this feature helpful. This feature is enabled by default and uses an embeddings model. It defaults to the OpenAI endpoints if not configured.

To disable the feature you can add:

flow_retrieval:
  active: false

In your LLMCommandGenerator configuration.


post by aoezdTchibo on May 1, 2024

Thank you Emily for your advice. Within the config.yml the API type is explicitly set to azure, so therefore I find it confusing that Rasa tries to authenticate with the OpenAI API and not with Azure. Also I use those same credentials on a daily basis, so I know that those are definitely correct. → I was wrong!

EDIT: No, Emily you were right. I had a small typo in my API key. After fixing that I still got an error regarding the Flow retrieval feature but with the hint of Chris I got that fixed. So now everything is running. Thanks!


post by aoezdTchibo on May 1, 2024

This solved my issue and I was able to train the model. Thank you so much! You are great, Chris!
Maybe a little hint in the documentation would have been helpful, since I just started experimenting with Rasa. For this reason it was not clear to me and I mistakenly focused only on the explicit error message. But even then in my opinion for a beginner it is still hard to decipher that the problem is rooted within the flow_retrieval feature.


post by aoezdTchibo on May 1, 2024

After the help of Emily and Chris I was able to run the tutorial locally on my machine with the Azure OpenAI Service with the following config.yml:

recipe: default.v1
language: en
pipeline:
- name: LLMCommandGenerator
  flow_retrieval:
    embeddings:
      model: "text-embedding-ada-002"
      openai_api_type: "azure"
      openai_api_base: "MY_API_BASE"
      openai_api_version: "2023-12-01-preview"
      openai_api_key: "MY_API_KEY"
      deployment: "MY_DEPLOYMENT"
  llm:
    model_name: "gpt-3.5-turbo"
    openai_api_type: "azure"
    openai_api_base: "MY_API_BASE"
    openai_api_version: "2023-12-01-preview"
    openai_api_key: "MY_API_KEY"
    deployment: "MY_DEPLOYMENT"

policies:
- name: FlowPolicy

post by camattin on May 1, 2024

Thank you for the feedback and we will look to improve the documentation around this feature!


post by Ayushi1 on Nov 6, 2024

Hii I have used the same above config file(with my credentials) but still getting error and not able to train the model in my local. Pls anyone help

ProviderClientAPIException: ProviderClientAPIException: Failed to embed documents Original error: litellm.APIError: AzureException APIError - Error code: 404 - {‘error’: {‘code’: ‘404’, ‘message’: ‘Resource not found’}}
Getting this error…