05-01 12:10
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- JetPack
- audio record
- 고금리
- java
- KB
- 3rd framework
- arm-linux-androideabi
- 달러예금
- 새마을금고
- 사전청약
- RETROFIT
- gradle
- ndkVersion
- Mac
- Swift
- Data Binding
- kotlin
- ios
- MG더뱅킹정기예금
- 청약
- ChatGPT
- BindingAdapter
- 용산 호반써밋 에이디션
- CHAT GPT
- Android Studio
- Android
- EditText
- Andorid
- ndk r24
- 예금
Archives
- Today
- Total
pear
[android] simple GPT retrofit 3 - call 본문
void requestGPT(final String requestText){
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
String domain ="https://api.openai.com/v1/chat/";
GPTRetrofitInterface mRetrofitInterface = RetrofitGPT
.getClient(domain).create(GPTRetrofitInterface.class);
try {
gptBody body = new gptBody();
body.model = "gpt-3.5-turbo";
body.messages[0].role = "user";
body.messages[0].content = requestText;
Gson gson = new Gson();
String json = gson.toJson(body);
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
Call<gptResponse> call = mRetrofitInterface.completions(jsonObject);
Response<gptResponse> response = call.execute();
if (response.code() == 200) {
System.out.println(response);
final gptResponse res = response.body();
runOnUiThread(new Runnable() {
public void run() {
myTextView.append(String.format("GPT(%d)\n", gptTime));
myTextView.append(res.choices[0].message.content);
}
});
}
else {
//[Todo] onError
Throwable e = new Throwable("send_response_code_"+response.code());
System.out.println(e);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e);
}
}
}).start();
}
'android' 카테고리의 다른 글
[android][ViualStudio Xamarin] 환경 설정. (0) | 2023.06.16 |
---|---|
[android] android studio build setting issue - Unsupported Java. Your build is currently configured to use Java 17.0.6 and Gradle (0) | 2023.06.16 |
[android] simple GPT retrofit 2 - data (0) | 2023.06.13 |
[android] simple GPT retrofit 1 - setting (0) | 2023.06.13 |
[AudioRecord] API (0) | 2022.08.09 |