The addition of auth callbacks with OpenAPI plugins seems promising but I am confused on how to use it #5773
-
My guess is that via the auth_callback in OpenAPIFunctionExecutionParameters I could pass header args and query or path_params that are specific to that OpenAPI function. The benefit here would be that if we use automatic function calling it would then already know what headers are required for that function. However, I am having some difficulty in the execution of this. Could someone provide a suggestion on how to inject a standard header with an API key into an OpenAPI call? Where in the workflow should I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
@ColtonBehannon, have you seen this kernel example that shows an example of setting up the auth callback? It doesn't need to be as complex as this one, but you can tailor the callback to grab your API key from wherever you need to load it. |
Beta Was this translation helpful? Give feedback.
-
Hi @ColtonBehannon, there's a lot to unpack. I'll do my best to help, but if I miss something, please let me know.
@SergeyMenshykh, you have a lot more experience working with OpenAPI plugins. Do you have any thoughts around what Colton is trying to achieve? Thank you. If it's simply a feature gap between SK Python and dotnet, that would be the best -- we can pull in any update as needed. |
Beta Was this translation helpful? Give feedback.
-
A couple of thoughts:
I can do some more digging on my end about how to better handle this. |
Beta Was this translation helpful? Give feedback.
-
Update: Following the advice from @moonbox3 I enabled the logger which was a massive help for identifying the args being used with the function call. The model kept wanting to use an empty string for the value of path_params which triggers
from this line. By including in the system prompt that it should not specify empty strings as args but instead use {} it is now working. |
Beta Was this translation helpful? Give feedback.
@ColtonBehannon, have you seen this kernel example that shows an example of setting up the auth callback? It doesn't need to be as complex as this one, but you can tailor the callback to grab your API key from wherever you need to load it.
https://github.com/microsoft/semantic-kernel/blob/9b8a218f5b6df9dcc72d69d989aff9b904cdecf0/python/samples/kernel-syntax-examples/openai_plugin_azure_key_vault.py#L154C13-L154C71