You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False), # Use Azure Default Credential for authentication
187
+
api_version="latest",
187
188
)
188
189
```
189
190
@@ -194,57 +195,60 @@ To make the Microsoft Fabric tool available to your agent, use a connection to i
194
195
```python
195
196
# The Fabric connection id can be found in the Azure AI Foundry project as a property of the Fabric tool
196
197
# Your connection id is in the format /subscriptions/<your-subscription-id>/resourceGroups/<your-resource-group>/providers/Microsoft.MachineLearningServices/workspaces/<your-project-name>/connections/<your-fabric-connection-name>
197
-
conn_id ="your-connection-id"
198
198
199
-
# Initialize agent fabric tool and add the connection id
199
+
# Retrieve the Fabric connection ID from environment variables
200
+
conn_id = os.environ["FABRIC_CONNECTION_ID"] # Ensure the FABRIC_CONNECTION_ID environment variable is set
201
+
202
+
# Initialize the FabricTool with the connection ID
200
203
fabric = FabricTool(connection_id=conn_id)
201
204
202
-
# Create agent with the fabric tool and process agent run
205
+
# Create an agent with the Fabric tool
203
206
with project_client:
204
207
agent = project_client.agents.create_agent(
205
-
model="gpt-4o",
206
-
name="my-assistant",
207
-
instructions="You are a helpful assistant",
208
-
tools=fabric.definitions,
209
-
headers={"x-ms-enable-preview": "true"},
208
+
model=os.environ["MODEL_DEPLOYMENT_NAME"], # Model deployment name
209
+
name="my-agent", # Name of the agent
210
+
instructions="You are a helpful agent", # Instructions for the agent
211
+
tools=fabric.definitions,# Attach the Fabric tool
212
+
headers={"x-ms-enable-preview": "true"},# Enable preview features
210
213
)
211
-
print(f"Created agent, ID: {agent.id}")
214
+
print(f"Created Agent, ID: {agent.id}")
212
215
```
213
216
214
217
## Step 3: Create a thread
215
218
216
219
```python
217
-
# Create thread for communication
218
-
thread = project_client.agents.create_thread()
220
+
# Create a thread for communication
221
+
thread = project_client.agents.threads.create()
219
222
print(f"Created thread, ID: {thread.id}")
220
223
221
-
# Create message to thread
222
-
# Remember to update the message with your data
223
-
message = project_client.agents.create_message(
224
+
# Create a message in the thread
225
+
message = project_client.agents.messages.create(
224
226
thread_id=thread.id,
225
-
role="user",
226
-
content="what is top sold product in Contoso last month?",
227
+
role="user",# Role of the message sender
228
+
content="What insights can you provide from the Fabric resource?",# Message content
227
229
)
228
-
print(f"Created message, ID: {message.id}")
230
+
print(f"Created message, ID: {message['id']}")
229
231
```
230
232
231
233
## Step 4: Create a run and check the output
232
234
233
235
```python
234
-
# Create and process agent run in thread with tools
235
-
run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
236
+
# Create and process an agent run in the thread
237
+
run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
### Step 2: Upload local files to your project Azure Blob Storage container
50
-
Upload your local file to the project’s Azure Blob Storage container. This is the same storage account you connected to your agent during setup. When creating additional agents within the same project, you can reuse the asset URIs of any previously uploaded files that those agents need. This means you don't have to upload the same file repeatedly, as the asset URIs allow you to reference the files directly.
50
+
### Step 2: Use an existing file in Azure Blob Storage
51
+
52
+
Use the `asset_uri` of a file already in Azure Blob Storage to create a vector store. This is useful if you have multiple agents that need access to the same files, as it eliminates the need to upload the same file multiple times.
51
53
52
-
Then, create a vector store using the ```asset_uri```, which is the location of your file in your project's datastore.
53
54
```python
54
-
# We'll upload the local file to your project Azure Blob Storage container and will use it for vector store creation.
### Step 4: Create second vector store using the previously uploaded file
102
-
Now, create a second vector store using the previously uploaded file. Using the ```asset_uri``` of a file already in Azure Blob Storage is useful if you have multiple agents that need access to the same files, as it eliminates the need to upload the same file multiple times.
103
-
```python
104
-
105
-
# create a vector store with a previously uploaded file and wait for it to be processed
0 commit comments