29 lines
939 B
Python
29 lines
939 B
Python
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() |