

However, when I use another library, called guidance, which also depends on the OpenAI library, the requests are not being captured by MITMProxy. It’s so simple it is insane that it’s not already being done. With this setup, I have been able to successfully capture HTTP requests sent by my Python program using the OpenAI library via MITMProxy. We do not see what is the last character in the first capture because you let the the capture tool replace it by a dot. It seems you did not fix it: Instead of this sequence in the JSON string 'query':'arId: \'xxxxx\'' you probably need: 'query':'arId: \\'xxxxx\\''. Otherwise, the user experience will suffer, or your application will hang. You should always use the timeout parameter in your code. If you don’t set a timeout, the requests will wait indefinitely on the response.

Use your own timeout feature with a library such as Retry. So I again see the mistake with the missed backslash. If the remote server is very slow, you can tell Requests to wait forever for a response, by passing None as a timeout value and then retrieving a cup of coffee. Requests Timeout in Python When you make requests to an external service, you need to wait for the response before continuing. Lord, please do not use undocumented parameters. HTTPConnection (host, portNone, timeout, sourceaddressNone, blocksize8192) ¶.
