You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 satır
839B

  1. from bridge.context import *
  2. from channel.channel import Channel
  3. import sys
  4. class TerminalChannel(Channel):
  5. def startup(self):
  6. context = Context()
  7. print("\nPlease input your question")
  8. while True:
  9. try:
  10. prompt = self.get_input("User:\n")
  11. except KeyboardInterrupt:
  12. print("\nExiting...")
  13. sys.exit()
  14. context.type = ContextType.TEXT
  15. context['session_id'] = "User"
  16. context.content = prompt
  17. print("Bot:")
  18. sys.stdout.flush()
  19. res = super().build_reply_content(prompt, context).content
  20. print(res)
  21. def get_input(self, prompt):
  22. """
  23. Multi-line input function
  24. """
  25. print(prompt, end="")
  26. line = input()
  27. return line