@@ -9,6 +9,7 @@ import com.mardillu.openai.model.Message
99import com.mardillu.openai.network.OpenApiClient
1010import com.mardillu.openai.test.databinding.ActivityMainBinding
1111import kotlinx.coroutines.launch
12+ import timber.log.Timber
1213import java.io.File
1314
1415class MainActivity : AppCompatActivity () {
@@ -29,7 +30,7 @@ class MainActivity : AppCompatActivity() {
2930 val result = chatGptService.getTextCompletion(" Hello chat gpt! what is the meaning of life?" )
3031 binding.result1.text = result.choices[0 ].text
3132 } catch (e: Exception ) {
32- Log .e (" MainActivity" , " Error in getTextCompletion" , e )
33+ Timber .tag (" MainActivity" ).e(e , " Error in getTextCompletion" )
3334 }
3435 }
3536
@@ -38,7 +39,7 @@ class MainActivity : AppCompatActivity() {
3839 val result = chatGptService.getChatCompletion(messages = listOf (Message (" user" , " What is the update with your weekly PR review" )))
3940 binding.result2.text = result.choices[0 ].message.content
4041 } catch (e: Exception ) {
41- Log .e (" MainActivity" , " Error in getChatCompletion" , e )
42+ Timber .tag (" MainActivity" ).e(e , " Error in getChatCompletion" )
4243 }
4344 }
4445
@@ -47,7 +48,7 @@ class MainActivity : AppCompatActivity() {
4748 val result = chatGptService.getEditCompletion(input = " What day of the wek is it?" , instruction = " Fix the spelling mistakes" )
4849 binding.result3.text = result.choices[0 ].text
4950 } catch (e: Exception ) {
50- Log .e (" MainActivity" , " Error in getEditCompletion" , e )
51+ Timber .tag (" MainActivity" ).e(e , " Error in getEditCompletion" )
5152 }
5253 }
5354
@@ -56,7 +57,7 @@ class MainActivity : AppCompatActivity() {
5657 val result = chatGptService.getEmbeddings(" Hello chat gpt! what is the meaning of life?" )
5758 binding.result4.text = result.data[0 ].embedding.size.toString()
5859 } catch (e: Exception ) {
59- Log .e (" MainActivity" , " Error in getEmbeddings" , e )
60+ Timber .tag (" MainActivity" ).e(e , " Error in getEmbeddings" )
6061 }
6162 }
6263
@@ -65,7 +66,7 @@ class MainActivity : AppCompatActivity() {
6566 val result = chatGptService.createImage(" A cute baby sea otter" )
6667 binding.result5.text = result.data[0 ].url
6768 } catch (e: Exception ) {
68- Log .e (" MainActivity" , " Error in createImage" , e )
69+ Timber .tag (" MainActivity" ).e(e , " Error in createImage" )
6970 }
7071 }
7172
@@ -74,7 +75,7 @@ class MainActivity : AppCompatActivity() {
7475 val result = chatGptService.getModeration(" I want to kill them." )
7576 binding.result6.text = result.results[0 ].categories.hate.toString()
7677 } catch (e: Exception ) {
77- Log .e (" MainActivity" , " Error in getModeration" , e )
78+ Timber .tag (" MainActivity" ).e(e , " Error in getModeration" )
7879 }
7980 }
8081
@@ -87,7 +88,7 @@ class MainActivity : AppCompatActivity() {
8788 )
8889 binding.result7.text = result.data[0 ].url
8990 } catch (e: Exception ) {
90- Log .e (" MainActivity" , " Error in createImageEdit" , e )
91+ Timber .tag (" MainActivity" ).e(e , " Error in createImageEdit" )
9192 }
9293 }
9394
@@ -96,7 +97,7 @@ class MainActivity : AppCompatActivity() {
9697 val result = chatGptService.createImageVariation(imageFromAssets(" img.png" ))
9798 binding.result8.text = result.data[0 ].url
9899 } catch (e: Exception ) {
99- Log .e (" MainActivity" , " Error in createImageVariation" , e )
100+ Timber .tag (" MainActivity" ).e(e , " Error in createImageVariation" )
100101 }
101102 }
102103
@@ -105,7 +106,7 @@ class MainActivity : AppCompatActivity() {
105106 val result = chatGptService.createTranscription(imageFromAssets(" audio.m4a" ))
106107 binding.result9.text = result.text
107108 } catch (e: Exception ) {
108- Log .e (" MainActivity" , " Error in createTranscription" , e )
109+ Timber .tag (" MainActivity" ).e(e , " Error in createTranscription" )
109110 }
110111 }
111112
@@ -114,7 +115,7 @@ class MainActivity : AppCompatActivity() {
114115 val result = chatGptService.createTranslation(imageFromAssets(" audio.m4a" ))
115116 binding.result10.text = result.text
116117 } catch (e: Exception ) {
117- Log .e (" MainActivity" , " Error in createTranslation" , e )
118+ Timber .tag (" MainActivity" ).e(e , " Error in createTranslation" )
118119 }
119120 }
120121 }
0 commit comments