From 9f05af8311fe7145cddec082120da6ff454809cc Mon Sep 17 00:00:00 2001 From: Dionysus Date: Thu, 16 Jan 2025 06:46:58 +0000 Subject: [PATCH] Add cli.py --- cli.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 cli.py diff --git a/cli.py b/cli.py new file mode 100644 index 0000000..875baa4 --- /dev/null +++ b/cli.py @@ -0,0 +1,29 @@ +from app import ElasticSearchAI +import argparse + +def main(): + parser = argparse.ArgumentParser(description='Natural language Elasticsearch query interface') + parser.add_argument('--host', default='localhost', help='Elasticsearch host') + parser.add_argument('--port', type=int, default=9200, help='Elasticsearch port') + args = parser.parse_args() + + es_ai = ElasticSearchAI(args.host, args.port) + + print("Welcome to ElasticSearch AI Query Interface") + print("Enter your queries in natural language, or type 'exit' to quit") + + while True: + query = input("\nEnter your query: ") + + if query.lower() == 'exit': + break + + try: + response = es_ai.process_query(query) + print("\nResponse:") + print(response) + except Exception as e: + print(f"Error processing query: {str(e)}") + +if __name__ == "__main__": + main() \ No newline at end of file