@@ -507,6 +507,7 @@ class OpenAI {
507
507
std::cerr << " Response is not a valid JSON\n " ;
508
508
std::cout << " << " << response.text << " \n " ;
509
509
#endif
510
+ json = Json{{" Result" , response.text }};
510
511
}
511
512
return json;
512
513
}
@@ -888,8 +889,25 @@ inline Json CategoryChat::create(Json input) {
888
889
// POST https://api.openai.com/v1/audio/transcriptions
889
890
// Transcribes audio into the input language.
890
891
inline Json CategoryAudio::transcribe (Json input) {
892
+ auto lambda = [input]() -> std::map<std::string, std::string> {
893
+ std::map<std::string, std::string> temp;
894
+ temp.insert ({" model" , input[" model" ].get <std::string>()});
895
+ if (input.contains (" language" )) {
896
+ temp.insert ({" language" , input[" language" ].get <std::string>()});
897
+ }
898
+ if (input.contains (" prompt" )) {
899
+ temp.insert ({" prompt" , input[" prompt" ].get <std::string>()});
900
+ }
901
+ if (input.contains (" response_format" )) {
902
+ temp.insert ({" response_format" , input[" response_format" ].get <std::string>()});
903
+ }
904
+ if (input.contains (" temperature" )) {
905
+ temp.insert ({" temperature" , std::to_string (input[" temperature" ].get <float >())});
906
+ }
907
+ return temp;
908
+ };
891
909
openai_.setMultiformPart ({" file" , input[" file" ].get <std::string>()},
892
- std::map<std::string, std::string>{{ " model " , input[ " model " ]. get <std::string>()}}
910
+ lambda ()
893
911
);
894
912
895
913
return openai_.post (" audio/transcriptions" , std::string{" " }, " multipart/form-data" );
@@ -898,8 +916,25 @@ inline Json CategoryAudio::transcribe(Json input) {
898
916
// POST https://api.openai.com/v1/audio/translations
899
917
// Translates audio into into English..
900
918
inline Json CategoryAudio::translate (Json input) {
919
+ auto lambda = [input]() -> std::map<std::string, std::string> {
920
+ std::map<std::string, std::string> temp;
921
+ temp.insert ({" model" , input[" model" ].get <std::string>()});
922
+ if (input.contains (" language" )) {
923
+ temp.insert ({" language" , input[" language" ].get <std::string>()});
924
+ }
925
+ if (input.contains (" prompt" )) {
926
+ temp.insert ({" prompt" , input[" prompt" ].get <std::string>()});
927
+ }
928
+ if (input.contains (" response_format" )) {
929
+ temp.insert ({" response_format" , input[" response_format" ].get <std::string>()});
930
+ }
931
+ if (input.contains (" temperature" )) {
932
+ temp.insert ({" temperature" , std::to_string (input[" temperature" ].get <float >())});
933
+ }
934
+ return temp;
935
+ };
901
936
openai_.setMultiformPart ({" file" , input[" file" ].get <std::string>()},
902
- std::map<std::string, std::string>{{ " model " , input[ " model " ]. get <std::string>()}}
937
+ lambda ()
903
938
);
904
939
905
940
return openai_.post (" audio/translations" , std::string{" " }, " multipart/form-data" );
0 commit comments