mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 01:36:55 +00:00
OpenAI: rate limiting logging
This commit is contained in:
parent
cffbad0d0d
commit
127128db19
1 changed files with 13 additions and 0 deletions
|
@ -43,6 +43,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class OpenAI {
|
public class OpenAI {
|
||||||
|
@ -239,6 +240,18 @@ public class OpenAI {
|
||||||
String response = Helper.readStream(connection.getInputStream());
|
String response = Helper.readStream(connection.getInputStream());
|
||||||
Log.i("OpenAI response=" + response);
|
Log.i("OpenAI response=" + response);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// https://platform.openai.com/docs/guides/rate-limits/rate-limits-in-headers
|
||||||
|
for (Map.Entry<String, List<String>> entries : connection.getHeaderFields().entrySet()) {
|
||||||
|
String key = entries.getKey();
|
||||||
|
if (key != null && key.startsWith("x-ratelimit"))
|
||||||
|
for (String value : entries.getValue())
|
||||||
|
Log.i("OpenAI", key + "=" + value);
|
||||||
|
}
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
}
|
||||||
|
|
||||||
return new JSONObject(response);
|
return new JSONObject(response);
|
||||||
} finally {
|
} finally {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
|
Loading…
Reference in a new issue