79501773

Date: 2025-03-11 18:33:24
Score: 1
Natty:
Report link

After some hard debugging and searching, I think I found where I am wrong.

  1. I declared Messages to be ObservableCollection, but it only Add operation will be notified to update the UI, .Text field change won't, to make the UI knows that .Text field changed in Messages, I need to let my ChatMessage class implement INotifyPropertyChanged

  2. After step 1, any message.Text field changed in Messages should trigger UI to update, but because of AI inference is CPU heavy, so `generator.GenerateNextToken();` will block the main thread, so I my case the UI will be updated after the AI part.

To solve my problem, I should try make `generator.GenerateNextToken()` async, so its execution won't block the main thread, I need to dig into Microsoft.ML.OnnxRuntimeGenAI to find a async method or find another library that provide async method.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • No code block (0.5):
  • Self-answer (0.5):
Posted by: Joey