Roughly ten to twelve years ago, I read a book (written in English) that featured a man whose only companion was a female AI. I think the book had been published fairly recently; I'd estimate that its publication was sometime between 2004 and 2011, though it could be earlier. I unfortunately don't remember a lot of concrete details, but here's what I've got:
I think the protagonist, a man who was probably in his twenties or thirties, was drifting through space in some kind of craft. He spent his time talking to an AI built into the craft. The story is told from first-person perspective, and I'm fairly certain that the protagonist mentions that he had an option to make his onboard AI have a male or female presentation, and choose the female option; he seems slightly defensive about this.
There may have been some dystopian undercurrent to the story, but I don't recall that being the main focus. I think there's some way for the AI to view the protagonist's memories, and part of the story describes the AI seeing a childhood memory.
The target audience was probably either teenagers or adults. The primary theme I recall was the loneliness of only having one other entity to talk to, and the fact that the entity was an AI. I think the book primarily focused on the relationship developed between the AI and protagonist throughout the story.