in chat.py [0:0]
def main():
"""
Main function to execute the script logic.
"""
conversation_id = ""
last_response_data = None
while True:
user_input = get_user_input()
if user_input == 'CTRL_D':
# Display thoughts and data_points from last_response_data
if last_response_data:
display_thoughts_and_data_points(last_response_data)
else:
print("No previous response to display thoughts and data points.")
continue
elif user_input is None:
continue
else:
use_rest_api = os.getenv('USE_REST_API', "False").lower() == "true"
if use_rest_api:
uri, x_functions_key = get_rest_api_config()
response_data = send_question_to_rest_api(
uri, x_functions_key, user_input, conversation_id)
else:
response_data = send_question_to_python(user_input, conversation_id)
if 'error' in response_data:
print(f"Error: {response_data['error']}")
logger.error(f"Error in response: {response_data['error']}")
continue
last_response_data = response_data
# Update conversation_id
if 'conversation_id' in response_data:
conversation_id = response_data['conversation_id']
else:
logger.warning("No conversation_id in response data.")
# Display only the answer
display_answer(response_data)