question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature request for handling callbacks

See original GitHub issue

I think callback functions are also needed to use semantic-kernel better. same concept here(link)

This feature will help solving TODOs. example is here semantic-kernel/python/semantic_kernel/ai/open_ai/services/open_ai_chat_completion.py

    async def complete_chat_async(
        self, messages: List[Tuple[str, str]], request_settings: ChatRequestSettings
    ) -> str:
        ...

        # TODO: tracking on token counts/etc.

        return response.choices[0].message.content

At least i hope SKContext or ContextVariables has callback functions like on_update or on_setitem

If MS doesn’t have a plan for this feature or it takes time, I can try.

Issue Analytics

  • State:open
  • Created 5 months ago
  • Reactions:1
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
ianchicommented, Jun 28, 2023

Hi @alexchaomander, any comments on the proposal and PR? Having no way to track what’s going and “debug” is a big stopper for me.

1reaction
ianchicommented, Jun 19, 2023

This is a possible structure for a handler, with hooks in the order they will be called:

class CallbackHandlerBase:

    def on_pipeline_start(self, context: SKContext):
        pass

    def on_function_start(self, context: SKContext, func: SKFunctionBase):
        pass

    #only for semantic functions
    def on_prompt_rendered(self, context: SKContext, func: SKFunctionBase, prompt: Union[str, List[Tuple[str, str]]]):
        pass

    #only if there is an error
    def on_function_error(self, context: SKContext, func: SKFunctionBase):
        pass

    def on_function_end(self, context: SKContext, func: SKFunctionBase):
        pass

    def on_pipeline_end(self, context: SKContext):
        pass

Some additional hooks should be added for the planner. The pipeline has almost no information, perhaps the call to run_async could have an optional legend parameter just to identify a specific pipeline, and pass it as an argument to the handler, to be able to have a clearer trace. The SKFunctions already have their identification in the definition.

The handlers could be set at the kernel level, and be used as defaults, or at the call level, to override for a specific invocation. All handlers will be invoked in order.

# default handlers
kernel.set_handlers([stdout_handler, thought_process_md])

# call using default handlers
result = await kernel.run_async( sf['func1'], nf['func2'], context=context)

# specific handler for call
result = await kernel.run_async( sf['func1'], nf['func2'], context=context, handlers=[thought_process_html])

If you agree, I could send a PR with an implementation of this approach.

Perhaps later, some general on_error, on_warning, on_info could also be added and use the handler in place of the log parameter, so that more consistent control of messages is possible. A default logger_handler could be available to just write in the provided logger, and so not break the current behavior

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practices for Managing Callbacks in Contact Centers
The callback option is a Computer Telephony Integration (CTI) feature that allows clients to request a callback if the line is busy, ...
Read more >
feature request for handling callbacks · microsoft/semantic- ...
Integrate cutting-edge LLM technology quickly and easily into your apps - feature request for handling callbacks · microsoft/semantic-kernel@8357616.
Read more >
Enabling customer callback
Callback enables your customers to choose between waiting on hold in a queue or requesting a callback. When customers select callback, their places...
Read more >
Managing callbacks - Genesys Documentation
This feature requires the Callback Administrator or Callback Supervisor role. Click Create Callback to submit or schedule a callback request. A new dialog...
Read more >
Working with callback requests using the Customer Service ...
As a customer, you can request a callback from a customer service agent using the Customer Service Portal. You can request an immediate ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found