refactor sdk for chat demo