Repository navigation
include_in_function_choices but for plugin Output #12872
Unanswered
FlorianPydde
asked this question in
Q&A
Replies: 1 comment
|
One approach that works without changing the plugin: use a function invocation filter and split the result there. The LLM only sees whatever ends up in from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
from semantic_kernel.functions import FunctionResult
@kernel.filter(FilterTypes.FUNCTION_INVOCATION)
async def mask_search_output(context: FunctionInvocationContext, next):
await next(context)
if context.function.name != "search": # your retrieval function
return
full = context.result.value # chunks with ids, scores, metadata
# 1) keep the full payload for eval/tracing, outside the prompt
eval_store.append({"call_id": ..., "chunks": full})
# 2) send only the cleaned text to the LLM
cleaned = [c["text"] for c in full]
context.result = FunctionResult(function=context.function.metadata, value=cleaned)Here The exact import paths may differ slightly by SK version, so please check against yours. Hope that helps. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I am creating an Agentic Rag agent based on the
chatcompletionagentin python. In short, I would like to be able to trace input/outputs in theChatHistoryAgentThreadwhile hiding/masking input AND outputs to the LLM.Thanks to the
include_in_function_choicesI can leverage theKernelArgumentsobject to send arguments to pluging functions without having the LLM to generate the values for these arguments. Additionalyl, I can review all the inputs to the functions since they are traced stored inChatHistoryAgentThreadwhich is fantastic for debugging.Now here comes the challenge: when I am retrieving the information from my search engine, I want to remove most metadata (chunk_id, embedding value, etc) before sending it to the LLM. However I need to know the id of the chunks for evaluation purposes, i.e. did the search engine retrieve the correct chunks and in which order.
So when returning values from the functions, it would be great to mask/hide some values from the LLM while keeping it part of the thread history, like what we do with the
KernelArgumentsfor inputs.Do you have any recommendation for achieving this ?
Thanks for your support.
All reactions