/ legacy / python / lib / simple_chat.py
simple_chat.py
 1  #!/usr/bin/env python3
 2  """
 3  Simple chat without the complex interface
 4  """
 5  
 6  import sys
 7  import os
 8  sys.path.insert(0, '/home/tao/kamaji/archive/python')
 9  
10  from kamaji.llm import get_llm
11  
12  def simple_chat():
13      llm = get_llm()
14      print("Simple Kamaji Chat (type 'quit' to exit)")
15      print("-" * 40)
16      
17      while True:
18          try:
19              user_input = input("\nYou: ").strip()
20              if user_input.lower() in ['quit', 'exit', 'q']:
21                  print("Goodbye!")
22                  break
23              
24              if user_input:
25                  print("Kamaji: ", end="", flush=True)
26                  response = llm.invoke(user_input)
27                  print(response)
28                  
29          except KeyboardInterrupt:
30              print("\nGoodbye!")
31              break
32          except EOFError:
33              print("\nGoodbye!")
34              break
35  
36  if __name__ == "__main__":
37      simple_chat()