The import order was changed to avoid import errors. The import of langchain was moved to the top of the file to avoid circular import errors.