langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Impossible to connect PowerBI Dataset Agent to Azure services

Open JRlis opened this issue 1 year ago • 3 comments

System Info

Hi, I'm trying to reproduce this example https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html

When i launch this part of the code : toolkit = PowerBIToolkit( powerbi=PowerBIDataset.update_forward_refs(dataset_id=dataset-id, table_names=['Tables'], credential=DefaultAzureCredential()), llm=smart_llm )

I have this error : NameError: name 'TokenCredential' is not defined

What am I doing wrong ? Do i have to specify things with Azure credentials first ? Thanks for your help

Who can help?

No response

Information

  • [X] The official example notebooks/scripts
  • [ ] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [X] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

example here : https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html

I just modified powerbi=PowerBIDataset() to powerbi=PowerBIDataset.update_forward_refs() because of an error i had.

Expected behavior

Connect the agent to powerbi rest API

JRlis avatar Jun 14 '23 11:06 JRlis

Generated by a 🤖

Answer

To resolve the "NameError: name 'TokenCredential' is not defined" error, you need to import the TokenCredential class from the azure.core.credentials module. Add the following import statement at the beginning of your code:

from azure.core.credentials import TokenCredential

This will make the TokenCredential class available in your code and resolve the error.

Source


This response is meant to be useful and save users time. It is not meant to be a precise solution.

Please leave a 👍 if this is helpful and 👎 if it is irrelevant

devstein avatar Jun 14 '23 20:06 devstein

I am facing the similar issue, even after importing TokenCredential it is still not working

NishantSrivastava81 avatar Jun 15 '23 05:06 NishantSrivastava81

I forgot to precise but i tried to import TokenCredential too already, and i got the same error

JRlis avatar Jun 15 '23 07:06 JRlis

TokenCredential is defined in the azure-core package, that is a dependency of azure-identity used to get DefaultAzureCredential(). Since azure-core 1.23.0, TokenCredential is available to be imported (before that, it was only available to mypy). You would get error like this if azure-core is therefore less than 1.23.0.

Upgrading to at least 1.23.0 would solve the problem. I'm not familiar enough with langchain to be sure where this should be done though.

(I work in the Azure Python team at MS, responsible for azure-core)

lmazuel avatar Aug 25 '23 22:08 lmazuel

Hi, @JRlis! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you were experiencing an error when trying to connect the PowerBI Dataset Agent to Azure services. The error message you received was "NameError: name 'TokenCredential' is not defined". Devstein suggested importing the TokenCredential class from the azure.core.credentials module as a potential solution. However, NishantSrivastava81 confirmed that this solution did not work for them. Lmazuel from the Azure Python team suggested upgrading to at least version 1.23.0 of azure-core to resolve the problem.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project! Let us know if you have any further questions or concerns.

dosubot[bot] avatar Nov 24 '23 16:11 dosubot[bot]

I am still facing this issue

sawdeepa avatar Jan 09 '24 09:01 sawdeepa