Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

terminal_channel.py 839B

12345678910111213141516171819202122232425262728293031
  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