Great question — answering as the UphillTech team:
Note : I'm not going to mark this as the accepted answer because I feel it's a bit cumbersome but it's still worth mentioning. I tried the CallbackHandler but I couldn't make it work, I might be doing something wrong. However, after looking around a bit and playing with the code, I found that the actual Ollama Request/Response done by LangChain is done by the Ollama package ( pip install ollama for reference). Communication happens inside the Client class, inside the _request() function. So if you want to see what's going on in the request/response communications between LangChain, the Ollama package and the Ollama server this is the place to look. Below is the function with comments...
Full answer by loco.loop: https://stackoverflow.stackexchange.com/a/79587438 (CC BY-SA 4.0).
Need it done for your business? UphillTech.