Replies: 19 comments 26 replies
-
I'm not sure you are calling the function properly (even though I haven't seen your code). Here is the proper way to do this. Just enter in your semantic model name and workspace name in the corresponding parameters. You can also specify a measure or list of measures using the 'measure_name' parameter within the generate_measure_descriptions function. from sempy_labs.tom import connect_semantic_model
with connect_semantic_model(dataset='', workspace='', readonly=False) as tom:
tom.generate_measure_descriptions() |
Beta Was this translation helpful? Give feedback.
-
You need to run this on a paid F64 sku or higher. |
Beta Was this translation helpful? Give feedback.
-
Hmm, interesting. I'll have to check and get back to you - likely after the holidays. |
Beta Was this translation helpful? Give feedback.
-
This should be resolved in 0.9.0. |
Beta Was this translation helpful? Give feedback.
-
hi m-Kovalsky FabricHTTPException: 401 Unauthorized for url: https://msitapi.fabric.microsoft.com//explore/v202304/nl2nl/completions We are executing this in F256 capacity |
Beta Was this translation helpful? Give feedback.
-
Which region are you using? |
Beta Was this translation helpful? Give feedback.
-
West us
…On Wed, Apr 9, 2025, 11:46 PM m-kovalsky ***@***.***> wrote:
Which region are you using?
—
Reply to this email directly, view it on GitHub
<#383 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYBVVI5TX2VKIEETT5FN32YYHS5AVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENZYG42DINY>
.
You are receiving this because you commented.Message ID:
<microsoft/semantic-link-labs/repo-discussions/383/comments/12787447@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Do you get this error immediately or after the function runs for some time? |
Beta Was this translation helpful? Give feedback.
-
So I tested for measures with double quotes and they work fine. Are you able to identify the measure which causes the issue? You can specify a measure or list of measures within the function’s parameter. Sharing the DAX of the problem measure would help a lot. |
Beta Was this translation helpful? Give feedback.
-
Could you try running this? It gets descriptions for 5 measures at a time. Before it runs the API to get the descriptions, it prints out the 5 measure names. Find the last printout of the measure names and within those you will find the culprit. Would then be great to see the DAX for those 5 measures (you can then run those 5 measures individually to find the specific culprit). from sempy_labs.tom import connect_semantic_model
import pandas as pd
from typing import Optional, List
import sempy_labs._icons as icons
dataset = ''
workspace = ''
with connect_semantic_model(dataset=dataset, workspace=workspace, readonly=True) as tom:
def generate_measure_descriptions(
measure_name: Optional[str | List[str]] = None,
max_batch_size: Optional[int] = 5,
) -> pd.DataFrame:
"""
Auto-generates descriptions for measures using an LLM. This function requires a paid F-sku (Fabric) of F64 or higher.
Setting the 'readonly' parameter in connect_semantic_model to True will allow you to see the auto-generated descriptions in a dataframe. Setting the 'readonly' parameter
to False will update the descriptions for the measures within the 'measure_name' parameter.
Parameters
----------
measure_name : str | List[str], default=None
The measure name (or a list of measure names).
Defaults to None which generates descriptions for all measures in the semantic model.
max_batch_size : int, default=5
Sets the max batch size for each API call.
Returns
-------
pandas.DataFrame
A pandas dataframe showing the updated measure(s) and their new description(s).
"""
df = pd.DataFrame(
columns=["Table Name", "Measure Name", "Expression", "Description"]
)
data = []
# import concurrent.futures
if measure_name is None:
measure_name = [m.Name for m in tom.all_measures()]
if isinstance(measure_name, str):
measure_name = [measure_name]
if len(measure_name) > max_batch_size:
measure_lists = [
measure_name[i : i + max_batch_size]
for i in range(0, len(measure_name), max_batch_size)
]
else:
measure_lists = [measure_name]
# Each API call can have a max of 5 measures
for measure_list in measure_lists:
payload = {
"scenarioDefinition": {
"generateModelItemDescriptions": {
"modelItems": [],
},
},
"workspaceId": tom._workspace_id,
"artifactInfo": {"artifactType": "SemanticModel"},
}
for m_name in measure_list:
expr, t_name = next(
(ms.Expression, ms.Parent.Name)
for ms in tom.all_measures()
if ms.Name == m_name
)
if t_name is None:
raise ValueError(
f"{icons.red_dot} The '{m_name}' measure does not exist in the '{tom._dataset_name}' semantic model within the '{tom._workspace_name}' workspace."
)
new_item = {
"urn": m_name,
"type": 1,
"name": m_name,
"expression": expr,
}
payload["scenarioDefinition"]["generateModelItemDescriptions"][
"modelItems"
].append(new_item)
print(measure_list)
response = _base_api(
request="/explore/v202304/nl2nl/completions",
method="post",
payload=payload,
)
for item in response.json().get("modelItems", []):
ms_name = item["urn"]
if ms_name.startswith("urn: "):
ms_name = ms_name[5:]
desc = item.get("description")
(table_name, expr) = next(
(m.Parent.Name, m.Expression)
for m in tom.all_measures()
if m.Name == ms_name
)
tom.model.Tables[table_name].Measures[ms_name].Description = desc
# Collect new descriptions in a dataframe
new_data = {
"Table Name": table_name,
"Measure Name": ms_name,
"Expression": expr,
"Description": desc,
}
data.append(new_data)
if data:
df = pd.concat([df, pd.DataFrame(data)], ignore_index=True)
return df
x = generate_measure_descriptions() |
Beta Was this translation helpful? Give feedback.
-
In msit
…On Mon, May 12, 2025, 1:03 AM m-kovalsky ***@***.***> wrote:
I cannot reproduce this error. I made a measure with essentially the same
code and it works just fine. In which environment are you running this
(prod/msit etc.)? And in which region?
image.png (view on web)
<https://github.com/user-attachments/assets/29f84800-f38a-47f0-b52a-1ec3476e6cf8>
—
Reply to this email directly, view it on GitHub
<#383 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYBVTUSGVWCLEDH7YDQOL26BIWBAVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJRGQ3DKNA>
.
You are receiving this because you commented.Message ID:
<microsoft/semantic-link-labs/repo-discussions/383/comments/13114654@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
In msit and west us
…On Mon, May 12, 2025, 1:59 PM sabarinathan R ***@***.***> wrote:
In msit
On Mon, May 12, 2025, 1:03 AM m-kovalsky ***@***.***> wrote:
> I cannot reproduce this error. I made a measure with essentially the same
> code and it works just fine. In which environment are you running this
> (prod/msit etc.)? And in which region?
>
> image.png (view on web)
> <https://github.com/user-attachments/assets/29f84800-f38a-47f0-b52a-1ec3476e6cf8>
>
> —
> Reply to this email directly, view it on GitHub
> <#383 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAEYBVTUSGVWCLEDH7YDQOL26BIWBAVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJRGQ3DKNA>
> .
> You are receiving this because you commented.Message ID:
> <microsoft/semantic-link-labs/repo-discussions/383/comments/13114654@
> github.com>
>
|
Beta Was this translation helpful? Give feedback.
-
I am also getting a "401 Unauthorized for url: https://api.fabric.microsoft.com//explore/v202304/nl2nl/completions" error when attempting to generate metric descriptions. We have an F64, we have all necessary AI and Open AI configurations configured. I have tried to just generate 5 metric descriptions at a time, but get the error. I am able to connect to the semantic model and see the metrics. The user executing the code is the owner of the semantic model and apart of the security group that has Fabric AI permissions. The only issue I'm curious about is that our Capacity is in a different environment than our Power BI; F64 is in South and Power BI is in North Central. Could that cause any issues? Here is the error message: "Specific measures approach failed: 401 Unauthorized for url: https://api.fabric.microsoft.com//explore/v202304/nl2nl/completions |
Beta Was this translation helpful? Give feedback.
-
Hi @m-kovalsky, I am trying to run the tom.generate_measure_descriptions function, but I am getting the following error message below: FabricHTTPException: 401 Unauthorized for url: https://api.fabric.microsoft.com//explore/v202304/nl2nl/completions Can you help me with that? I am running the function using the Fabric Notebook under PBI Service. Capacity that we are using are F64. |
Beta Was this translation helpful? Give feedback.
-
Yes, I have and the auto description option works fine if I open the model
through the Semantic Model and click on the create copilot's description
button.
…On Mon, Sep 8, 2025 at 1:52 PM m-kovalsky ***@***.***> wrote:
Do you have copilot enabled on your fabric capacity?
—
Reply to this email directly, view it on GitHub
<#383 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWLEGOMU4WICJXHRIF3F4MT3RWX37AVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMZUGI3DQOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: <microsoft/semantic-link-labs/repo-discussions/383/comments/14342688@
github.com>
--
*Erick Campos*
Phone: (12) 98818-2337
MS Teams: erick.de.campos
|
Beta Was this translation helpful? Give feedback.
-
After upgrading the version of the library to the 0.12.2, it has executed
successfully in Fabric! Thank you so much for fixing that issue @m-kovalsky
…On Fri, Sep 12, 2025 at 7:16 AM m-kovalsky ***@***.***> wrote:
Would you try 0.12.2
<https://github.com/microsoft/semantic-link-labs/releases/tag/0.12.2> and
let me know.
—
Reply to this email directly, view it on GitHub
<#383 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWLEGOIWLP4CKOGUK4Z7HG33SKMQ3AVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMZYGMYDQMI>
.
You are receiving this because you are subscribed to this thread.Message
ID: <microsoft/semantic-link-labs/repo-discussions/383/comments/14383081@
github.com>
--
*Erick Campos*
Phone: (12) 98818-2337
MS Teams: erick.de.campos
|
Beta Was this translation helpful? Give feedback.
-
HI @m-kovalsky, Now i am getting different error could you please check itAttributeError Traceback (most recent call last) File /nfs4/pyenv-8845f6c3-2d39-41a6-b4bb-470832d2ba40/lib/python3.10/site-packages/sempy_labs/tom/_model.py:4673, in TOMWrapper.generate_measure_descriptions(self, measure_name, max_batch_size) File /nfs4/pyenv-8845f6c3-2d39-41a6-b4bb-470832d2ba40/lib/python3.10/site-packages/sempy/fabric/exceptions/_exceptions.py:24, in FabricHTTPException.init(self, response) AttributeError: 'str' object has no attribute 'reason' |
Beta Was this translation helpful? Give feedback.
-
What are you sending as dataset to the function?
Em sex., 12 de set. de 2025, 20:27, CharlesSaulnier <
***@***.***> escreveu:
… I did get the same error when trying to call the function with the default
parameters, but it should work with something like this:
`from sempy_labs.tom import connect_semantic_model
with connect_semantic_model(dataset=dataset, readonly=True,
workspace=workspace) as tom:
for m in tom.all_measures():
# print(m.Name)
measure = m.Name
description = tom.generate_measure_descriptions(measure_name=measure)
name = description["Measure Name"]
measure_description = description["Description"]
print(name + ': ' + measure_description)
`
—
Reply to this email directly, view it on GitHub
<#383 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWLEGOP4KKIPKHMDU6PMICL3SNJEHAVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMZYHA3DSNQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: <microsoft/semantic-link-labs/repo-discussions/383/comments/14388696@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Please try 0.12.3. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've firstly run the module "connect_semantic_model" in order to connect to a semantic model and being able to use TOM package.
After that, I've run the "labs.tom.TOMWrapper.generate_measure_descriptions" command but obtained this error:
TypeError: TOMWrapper.generate_measure_descriptions() missing 1 required positional argument: 'self'
What is the missing argument? Based on documentation, no argument is mandatory (measure_name and max_batch_size are optional)
Beta Was this translation helpful? Give feedback.
All reactions