microsoft/kernel-memory

[Question] Reading document status

Valkozaur opened this issue · 2 comments

Context / Scenario

Hello, thank you for supporting kernel memory, it's a powerful service.

The question is regarding running the container as a separate service.

Question

I am wondering if the GetDocumentStatusAsync is the only way to know if a document is processed?

I thought that it might be possible to post a message on a queue once the document is processed, so we skip the polling of status.

I had a look through the code but I could not find anything that suggests that.

dluc commented

I thought that it might be possible to post a message on a queue once the document is processed, so we skip the polling of status.

hi @Valkozaur - if we posted a message on a queue, how would the client know that the message is there? wouldn't the client have to poll the queue?

dluc commented

You can implement your approach adding a "custom handler".
When importing a document, you can provide in input a list of steps, which corresponds to the list of handlers to execute.

In the service, you can add a custom handler, used to post a message in a queue that you own, if that helps your scenario.

How to:

  • write a custom handler class responsible for posting messages in your custom queue
  • change the service to load your custom handler with a predefined name - see service config and examples
  • when storing a memory, pass the steps parameter, it's a list of strings, include the name of your handler, e.g. steps: ["extract", "partition", "gen_embeddings", "save_records", "my_post_to_queue"]