Pelosi, who has represented San Francisco for nearly 40 years, announced her decision Thursday.