main.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from cli.command_group import cli
  2. from cli.commands import (
  3. collections,
  4. conversations,
  5. database,
  6. documents,
  7. graphs,
  8. indices,
  9. prompts,
  10. retrieval,
  11. system,
  12. users,
  13. )
  14. from cli.utils.telemetry import posthog, telemetry
  15. def add_command_with_telemetry(command):
  16. cli.add_command(telemetry(command))
  17. # Chunks
  18. add_command_with_telemetry(collections.collections)
  19. add_command_with_telemetry(conversations.conversations)
  20. add_command_with_telemetry(documents.documents)
  21. add_command_with_telemetry(graphs.graphs)
  22. # Graph
  23. add_command_with_telemetry(indices.indices)
  24. add_command_with_telemetry(prompts.prompts)
  25. add_command_with_telemetry(retrieval.retrieval)
  26. add_command_with_telemetry(users.users)
  27. add_command_with_telemetry(system.system)
  28. # Database
  29. add_command_with_telemetry(database.db)
  30. add_command_with_telemetry(database.upgrade)
  31. add_command_with_telemetry(database.downgrade)
  32. add_command_with_telemetry(database.current)
  33. add_command_with_telemetry(database.history)
  34. def main():
  35. try:
  36. cli()
  37. except SystemExit:
  38. # Silently exit without printing the traceback
  39. pass
  40. except Exception as e:
  41. # Handle other exceptions if needed
  42. print("CLI error: An error occurred")
  43. raise e
  44. finally:
  45. # Ensure all events are flushed before exiting
  46. if posthog:
  47. posthog.flush()
  48. posthog.shutdown()
  49. if __name__ == "__main__":
  50. main()