Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power BI Dataset Agent Issue #4325

Closed
3 of 14 tasks
satishgunjal opened this issue May 8, 2023 · 14 comments · Fixed by #4983
Closed
3 of 14 tasks

Power BI Dataset Agent Issue #4325

satishgunjal opened this issue May 8, 2023 · 14 comments · Fixed by #4983

Comments

@satishgunjal
Copy link

System Info

We are using the below Power BI Agent guide to try to connect to Power BI dashboard.

Power BI Dataset Agent

We are able to connect to OpenAI API but facing issues with the below line of code.

powerbi=PowerBIDataset(dataset_id="<dataset_id>", table_names=['table1', 'table2'], credential=DefaultAzureCredential())

Error:

ConfigError: field "credential" not yet prepared so type is still a ForwardRef, you might need to call PowerBIDataset.update_forward_refs().

We tried searching to solve the issues we no luck so far. Is there any configuration we are missing? Can you share more details, is there any specific configuration or access required on power BI side?

thanks in advance...

Who can help?

No response

Information

  • 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
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

Same steps mentioned your official PowerBI Dataset Agent documentation

Expected behavior

We should be able to connect to power BI

@satishgunjal
Copy link
Author

Hi,

Received response from @xiangyan99 in forum azure-sdk-for-python that bug in langchain: https://github.com/hwchase17/langchain/blob/master/langchain/utilities/powerbi.py

TokenCredential is only defined in TYPE_CHECKING.

@Ioannis-Pikoulis
Copy link

Having the same issue.

@avinesh-a
Copy link

avinesh-a commented May 9, 2023

in utilities>powerbi.py
if we import TokenCredential without checking TYPE_CHECKING flag the issue is getting resolved.

Request the team to look into it
@hwchase17

@aditya-pethe
Copy link
Contributor

Also having this issue - not sure if there is/should be a separate integ test for the powerbi tool

@aditya-pethe
Copy link
Contributor

@satishgunjal I opened a PR for this that should resolve this issue. In addition to the TYPE_CHECKING issue, the notebook code should be using ChatOpenAI instead of AzureOpenAI, I.e

fast_llm = ChatOpenAI(temperature=0.5, max_tokens=1000, model_name="gpt-3.5-turbo", verbose=True)
smart_llm = ChatOpenAI(temperature=0, max_tokens=100, model_name="gpt-4", verbose=True)

@JRlis
Copy link

JRlis commented Jun 14, 2023

Hi !
Have you find a way to make the agent work ? we have the same error here

ConfigError: field "credential" not yet prepared so type is still a ForwardRef, you might need to call PowerBIDataset.update_forward_refs().
If we use powerbidataset.update.forward.refs() we then have this error : NameError: name 'TokenCredential' is not defined

It seems like the issue was resolved by i still have it on my side.
Someone knows how to bypass that ?

@aditya-pethe
Copy link
Contributor

aditya-pethe commented Jun 15, 2023

It looks like parts of this change were reverted back in an update #5062

if TYPE_CHECKING: from azure.core.credentials import TokenCredential

@hwchase17, is there a way to handle the import in a different way? My initial fix in #4983 used a try-except instead, since azure is not a required dependency.

It looks like the type checking condition breaks the powerbi tool with the error mentioned by @JRlis

@grillon6u
Copy link

Hi! We are still facing this issue. Do we have any updates/fixes/bypasses about it?

@alaturqua
Copy link

Hi, this issue is still happening:

line 22, in <module>
    powerbi=PowerBIDataset(
  File "pydantic\main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic\main.py", line 1076, in pydantic.main.validate_model
  File "pydantic\fields.py", line 860, in pydantic.fields.ModelField.validate
pydantic.errors.ConfigError: field "credential" not yet prepared so type is still a ForwardRef, you might need to call PowerBIDataset.update_forward_refs().

@lewisdba
Copy link

Here is the code to solve this issue

!pip install powerbiclient
################################################
#Using powerbiclient to get token instead of DefaultAzureCredential
###############################################

from powerbiclient.authentication import DeviceCodeLoginAuthentication
auth = DeviceCodeLoginAuthentication()
token = auth.get_access_token()

llm = AzureOpenAI(temperature=0, deployment_name="gpt-35-turbo", model_name="gpt-35-turbo",)
toolkit = PowerBIToolkit(
powerbi=PowerBIDataset(
dataset_id="your_dataset_id",
table_names=["HR Employees", "Sales Orders"],
token= token, #<--------------Using token instead credential
),
llm=llm,
output_token_limit = 1024
)

agent_executor = create_pbi_agent(
llm=llm,
toolkit=toolkit,
verbose=True
)

agent_executor.run('How many rows are in HR Employees')

@ghost
Copy link

ghost commented Sep 27, 2023

Here is the code to solve this issue

!pip install powerbiclient ################################################ #Using powerbiclient to get token instead of DefaultAzureCredential ###############################################

from powerbiclient.authentication import DeviceCodeLoginAuthentication auth = DeviceCodeLoginAuthentication() token = auth.get_access_token()

llm = AzureOpenAI(temperature=0, deployment_name="gpt-35-turbo", model_name="gpt-35-turbo",) toolkit = PowerBIToolkit( powerbi=PowerBIDataset( dataset_id="your_dataset_id", table_names=["HR Employees", "Sales Orders"], token= token, #<--------------Using token instead credential ), llm=llm, output_token_limit = 1024 )

agent_executor = create_pbi_agent( llm=llm, toolkit=toolkit, verbose=True )

agent_executor.run('How many rows are in HR Employees')

Thanks a lot, it works this way!

@Cozokim
Copy link

Cozokim commented Sep 27, 2023

Here is the code to solve this issue

!pip install powerbiclient ################################################ #Using powerbiclient to get token instead of DefaultAzureCredential ###############################################

from powerbiclient.authentication import DeviceCodeLoginAuthentication auth = DeviceCodeLoginAuthentication() token = auth.get_access_token()

llm = AzureOpenAI(temperature=0, deployment_name="gpt-35-turbo", model_name="gpt-35-turbo",) toolkit = PowerBIToolkit( powerbi=PowerBIDataset( dataset_id="your_dataset_id", table_names=["HR Employees", "Sales Orders"], token= token, #<--------------Using token instead credential ), llm=llm, output_token_limit = 1024 )

agent_executor = create_pbi_agent( llm=llm, toolkit=toolkit, verbose=True )

agent_executor.run('How many rows are in HR Employees')

It works this way indeed. Thanks a lot @lewisdba !

@BaimaCaio
Copy link

Aqui está o código para resolver este problema

!pip instalar powerbiclient ) ) Embalhação (em, í) Usando powerbiclient para obter token em vez de DefaultAzureCredential ) ) Embalhação (em, í)

de powerbiclient.authentication import DeviceCodeLoginAutenticação auth ? DeviceCodeLoginAutentication() token ? auth.get_access_token() (em inglês)

llm ? AzureOpenAI(temperatura 0, deployment_name?"gpt-35-turbo", model_name?"gpt-35-turbo,") kit de ferramentas ? PowerBIToolkit( powerbi'PowerBIDataset (em inglês) dataset_id"your_dataset_id," (em inglês). table_names["HR Employees", "Ordens de vendas"], token, ?------------------- Uting token em vez de credencial ) - Em que o nome de porta - o que é! llm?llm, em inglês, . output_token_limit ? 1024 ) - Em que é)

agent_executor ? create_pbi_agent( llm?llm, em inglês, . toolkit?toolkit, em inglês, versão de verbose-True ) - )

agent_executor.run('Quantas linhas estão em RH')

Ok, for me it really works. But, i am coding a product for my boss. I need an automatic login.

All classes from azure.identity return the same error:

credential = UsernamePasswordCredential(
username='myemail@email.net.br',
password='mypass',
client_id='a181f0*9f'
)

PowerBIDataset.update_forward_refs()
dataset = PowerBIDataset(
dataset_id="26d-9a-4b-*-c132ed*8",
table_names=["Sell"],
credential=credential)

ERROR:
name 'TokenCredential' is not defined

I tried:

credential = UsernamePasswordCredential(
username='myemail@email.net.br',
password='mypass',
client_id='a181f0*9f'
)

from azure.core.credentials import TokenCredential
PowerBIDataset.update_forward_refs()
dataset = PowerBIDataset(
dataset_id="26d-9a-4b-*-c132ed*8",
table_names=["Sell"],
credential=credential)

But, it not works...

@bloopepper
Copy link

Here is the code to solve this issue
!pip install powerbiclient ################################################ #Using powerbiclient to get token instead of DefaultAzureCredential ###############################################
from powerbiclient.authentication import DeviceCodeLoginAuthentication auth = DeviceCodeLoginAuthentication() token = auth.get_access_token()
llm = AzureOpenAI(temperature=0, deployment_name="gpt-35-turbo", model_name="gpt-35-turbo",) toolkit = PowerBIToolkit( powerbi=PowerBIDataset( dataset_id="your_dataset_id", table_names=["HR Employees", "Sales Orders"], token= token, #<--------------Using token instead credential ), llm=llm, output_token_limit = 1024 )
agent_executor = create_pbi_agent( llm=llm, toolkit=toolkit, verbose=True )
agent_executor.run('How many rows are in HR Employees')

Thanks a lot, it works this way!

This solution is really helpful :)))
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet