Add cli.py
This commit is contained in:
parent
dc03439074
commit
9f05af8311
29
cli.py
Normal file
29
cli.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user