Add custom roles to Messages in Threads

An idea occurred to me: if the role parameter is not allowed to be other than user, then instead we can simply stick our own role in the content field, and it works just fine! With this ability, I am able to now cache assistant responses in Langroid, see this code

I keep an updated hash H of the conversation in the thread metadata, and cache the assistant response R at any stage so C[H] = R. On any run, before starting an assistant run, I look whether there is a cached R = C[H] , and if there is, I stick in R (the cached assistant response) onto the thread, as a msg with user role (since that is the only role allowed), but I prefix the content with "ASSISTANT:...". This assistant spoofing is handled in the expected way by the assistant, i.e. it treats the ASSISTANT-labled messages as if they were generated by the assistant. E.g. see this test