Skip to content

How to pass, in python, a parameter not provided by the LLM to a function? #10107

Answered by moonbox3
ja-bot asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ja-bot, thanks for your question. Right now we don't have the direct 1:1 "kernel function transformation" method as you pointed out that C# has. Instead, you can emulate this in Python by registering a custom invocation filter that intercepts arguments, removes or masks the sensitive key, and then passes control to the next filter or the underlying function. This way, the LLM never sees that key.

I haven't explicitly tested this yet, but just trying to think through some code that may work:

async def remove_api_key_filter(context: FunctionInvocationContext, next_filter) -> None:
    """A filter that intercepts the function invocation context and
    removes the 'api_key' argument so t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ja-bot
Comment options

Answer selected by sophialagerkranspandey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants