cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

AIAPI NotFoundException

linhlinh_sarah
Explorer
0 Likes
649

i'm still working on the SAP AI Core mission and basically just nned to copy code a given github Repository. But somehow when trying to run the code to create a configuration the serve the model, i get an exception. Does someone understand the excepetion and knows what I can do now ? The tutorial doesnt really help with it and in general this shouldnt even be the case as I assume the provided code in the tutorial is correct.

``code

<strong>ai_api_v2_client = AIAPIV2Client(<br></strong><strong>    base_url=aic_service_key["serviceurls"]["AI_API_URL"] + "/v2/lm",<br></strong><strong>    auth_url=aic_service_key["url"] + "/oauth/token",<br></strong><strong>    client_id=aic_service_key["clientid"],<br></strong><strong>    client_secret=aic_service_key["clientsecret"],<br></strong><strong>    resource_group=resource_group)</strong><strong><br></strong><strong>with open(serving_workflow_file) as swf:<br></strong><strong>    serving_workflow = yaml.safe_load(swf)</strong><strong><br></strong><strong>scenario_id = serving_workflow["metadata"]["labels"]["scenarios.ai.sap.com/id"]<br></strong><strong>executable_name = serving_workflow["metadata"]["name"]</strong><strong><br></strong><strong>with open(env_file_path) as efp:<br></strong><strong>    environment_values = json.load(efp)</strong><strong><br></strong><strong>parameter_bindings = [ParameterBinding(key=key, value=value) for key, value in environment_values.items()]</strong><strong><br></strong>

<strong>serve_configuration = {<br></strong><strong>    "name": f"{resource_group}-serve",<br></strong><strong>    "scenario_id": scenario_id,<br></strong><strong>    "executable_id": executable_name,<br></strong><strong>    "parameter_bindings": parameter_bindings,<br></strong><strong>    "input_artifact_bindings": []<br></strong><strong>}</strong><strong><br></strong><strong>serve_config_resp = ai_api_v2_client.configuration.create(**serve_configuration)</strong><strong><br></strong><strong>assert serve_config_resp.message == "Configuration created"</strong><strong><br></strong><strong>pprint(vars(serve_config_resp))<br></strong><strong>print("configuration for serving the model created")</strong>
i get the following exception:---------------------------------------------------------------------------
AIAPINotFoundException                    Traceback (most recent call last)
Cell <br>Cell In[83], line 29<br>     18 parameter_bindings = [ParameterBinding(key=key, value=value) for key, value in environment_values.items()]
     21 serve_configuration = {
     22     "name": f"{resource_group}-serve",
     23     "scenario_id": scenario_id,
   (...)<br>     26     "input_artifact_bindings": []
     27 }
---> 29 serve_config_resp = ai_api_v2_client.configuration.create(**serve_configuration)
     31 assert serve_config_resp.message == "Configuration created"<br>     33 pprint(vars(serve_config_resp))

File 
File <a href="https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/lib/python3.11/site-packages/ai_api_client_sdk/resource_clients/configuration_client.py:57">/opt/homebrew/lib/python3.11/site-packages/ai_api_client_sdk/resource_clients/configuration_client.py:57</a>, in ConfigurationClient.create(self, name, scenario_id, executable_id, parameter_bindings, input_artifact_bindings, resource_group)<br>     55 if input_artifact_bindings:
     56     body['input_artifact_bindings'] = [iab.to_dict() for iab in input_artifact_bindings]
---> 57 response_dict = self.rest_client.post(path='<a href="https://file+.vscode-resource.vscode-cdn.net/configurations">/configurations</a>', body=body, resource_group=resource_group)
     58 return ConfigurationCreateResponse.from_dict(response_dict)

File 
File <a href="https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/lib/python3.11/site-packages/ai_api_client_sdk/helpers/rest_client.py:146">/opt/homebrew/lib/python3.11/site-packages/ai_api_client_sdk/helpers/rest_client.py:146</a>, in RestClient.post(self, path, body, headers, resource_group)<br>    118 def post(self, path: str, body: Dict[str, Union[str, dict]] = None, headers: Dict[str, str] = None,
    119          resource_group: str = None) -> dict:
    120     """Sends a POST request to the server.<br>    121 <br>...<br>    107                                            error_code=error_code, request_id=request_id,
    108                                            details=error_details)


AIAPINotFoundException: Failed to post <a href="https://file+.vscode-resource.vscode-cdn.net/configurations">/configurations</a>: Not Found, Could not create configuration because executable azure-openai-proxy for scenario azure-openai-proxy wasn't found.. 
 Status Code: 404, Request ID:6093ba62-e474-4f6c-b9f7-5b4f93a7e871<br> Status Code: 404, Request ID:6093ba62-e474-4f6c-b9f7-5b4f93a7e871<br>Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Accepted Solutions (0)

Answers (1)

Answers (1)

KarimM
Product and Topic Expert
Product and Topic Expert
0 Likes

Hello Sarah,

ist this the api url you are using:

href="https://file+.vscode-resource.vscode-cdn.net/configurations"?

I guess, there should be some parts be replaced with the the account urls you are using.

In addition, the code you pasted above (I hope the html tags are not part of it), refers to some environment variables, e.g. the "serviceurls". Did you set these variables correctly?

linhlinh_sarah
Explorer
0 Likes

i don't really now, I'm just doing the steps in the tutorial and I assumed I did everything according to the assignmenus and now I'm stuck at creating the configuration.

Here's the link for the gitHub Repo: I'm currently trying to run the different steps in the proxy.ipynp file, i.ex am stcuck at point 6.

https://github.com/SAP-samples/azure-openai-aicore-cap-api/blob/main/01-ai-core-azure-openai-proxy/p...

KarimM
Product and Topic Expert
Product and Topic Expert
0 Likes

in cell #setup there is a resources folder referenced where all the configs like service url and credentials are read and filled into variable aic_service_key_path.

Did you get the resources file from your organization?

If you are trying in Free Tier or your own account, you have to provide the resources.