-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
AI Project client says "Invalid tool value(s): azure_function" #39778
Comments
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @achauhan-scc @kingernupur @luigiw @needuv @paulshealy1 @singankit. |
The reason of this error is because the Azure AI Foundry and hub are missing the capability host. The easiest way is to create the new Azur AI Foundry project as outlined here.
pip install -U azure-cli
# Create the capability host for hub
az config set extension.dynamic_install_allow_preview=true
az ml capability-host create -g my-resource-group -w my-hub
# Create capabilityhost for the project, but now provide necessary connections to the data store and AI search resource:
az ml capability-host create create -g my-resource-group -w my-project -s my-project/workspaceblobstore -v vector_store_connection_name_from_step_3 -a ai_services_connection_used_by_a_project Please also follow the Readme steps here to deploy Azure function. |
Hi @nick863 I am having trouble with Azure Function as tool calling to my Azure AI Agent. Azure AI Search works fine. |
What is the Azure AI Foundry region? |
@nick863 Sweden Central |
Hi, |
@kuljotSB swedencentral is supported region, https://learn.microsoft.com/en-us/azure/ai-services/agents/concepts/model-region-support#azure-openai-models, which model you were using? Also did you choose agents standard template when deployed resources? That is required for azure functions tool to work. |
@jhakulin I believe the model was gpt-4o......tried doing it with other models like gpt-4, gpt-35-turbo and in east us region too but doesn't work....keep receiving this in the terminal -
|
@kuljotSB Which deployment template you used? Basic or Standard? Or did you create resources somehow else? |
@jhakulin I must have followed the "Standard Agent Setup" |
@jhakulin I had already configured an Azure AI Foundry project and created an agent via code-first environment (VSCode IDE) so I presume it follows the "Standard Agent Setup" |
@kuljotSB Did you create project in Azure AI Foundry UI? If so, it is probable that the needed capabilities are not be set for Azure Functions. Thus currently, what I can suggest is to use the Standard Agent deployment template below to deploye resources (incl. project) again and then test with the project resource created there. |
@jhakulin Yes upon deploying the standard agent template I am able to create an azure function tooled agent..........although the reason for this still remains unknown and strange, thanks for your help, appreciate it! |
@kuljotSB Thanks for information! The reason is probably that required capability hosts were not set. Would be great if you remember still how did you earlier created the resources, was it using Azure AI Foundry UI or something else? |
@jhakulin I did it via the Foundry UI earlier........wondering if there's a way to fix it via the UI without launching the template again? |
Generally, we have these issues arise from the capbility host being missing. Have you tried to add the capability host? |
Hi @kuljotSB. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
@jhakulin so sorry for replying late, was busy with my college work. Coming to the question, I went a step ahead and surprisingly, the function app integration with ai agent doesn't work.....gives an "internal server error". Function app code (app.py):
local.settings.json file:
Observations: 2)When a request is send to the HTTP triggered function which invokes the agent (example: hello, how are you?) - the agent responds properly but when invoked with a request that triggers the function tool (example - send a greeting message to kuljot in Batman's voice) - the agent gives internal server error. 3)I don't see any message body in the input queue when triggered by agent which suggests the agent is not able to push the message body into the input queue in the very first place.
|
One thing that we need to add is the correlation ID. It is used by the application to correlate its input messages to the output messages, used by the app. And it is allowed to write to the Queue resource of the Azure Blob you have created the output query in (Click Asure role Assignment and set Please also check that the @app.function_name(name="GreetingByBatman")
@app.queue_trigger(arg_name="msg", queue_name="inputqueue",
connection="STORAGE_CONNECTION")
def GreetingByBatman(msg: func.QueueMessage) -> None:
logging.info('Python queue trigger function processed a queue item')
# Queue to send message to
queue_client = QueueClient(
os.environ["STORAGE_CONNECTION__queueServiceUri"],
queue_name="outputqueue",
credential=DefaultAzureCredential(),
message_encode_policy=BinaryBase64EncodePolicy(),
message_decode_policy=BinaryBase64DecodePolicy()
)
messagepayload = json.loads(msg.get_body().decode('utf-8'))
name=messagepayload["name"]
correlation_id=messagepayload['CorrelationId']
greeting_note = f""" It's not who you are underneath, {name}, but what you do that defines you. Stay strong, stay vigilant… and happy to have you here """
result_message = {
'Value': greeting_note,
'CorrelationId': correlation_id
}
queue_client.send_message(json.dumps(result_message).encode('utf-8'))
logging.info(f"Sent message to queue with message {result_message}") Please make sure, that if you send the input (in Azure portal) as {
"name": "Test",
"CorrelationId": "42"
} You get {
"Value": "It's not who you are underneath, Test, but what you do that defines you. Stay strong, stay vigilant… and happy to have you here",
"CorrelationId": "42"
} |
Hi @kuljotSB. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
@nick863 I modified the code to make up for the missing "CorrelationId" payload but it doesn't solve the problem. Moreover I have made sure that I have the necessary RBAC permissions - for My user (as I am running this setup locally but not with Azurite - instead a storage account on cloud - which means the function app that I am running locally will take my user identity), AI Project and AI Hub. I modified the code by adding logging statements to go deeper inside to see how all of this is behaving (Attaching the modified code below):
A point to be noted is that the following logging statement isn't visible anywhere in the terminal: This suggests that the queue triggered function doesn't have the input payload in the first place so it doesn't write anything to the output queue. This suggests that there is something wrong with the agent that isn't letting the agent submit the payload to the inputqueue |
Do you see the first logging statement |
Hi @kuljotSB. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
Hi all,
I have been trying to create an agent with an azure function (queue trigger) deployed into azure with the azure ai foundry SDK. The only problem is when i create an agent with tool as the azure function, it fails saying: "Invalid tool value(s): azure_function"
Pasting the code for reference:
Any help or resolution would be highly appreciated!
The text was updated successfully, but these errors were encountered: