Skip to content

Commit 3f7aca8

Browse files
committed
Fix return type string on client methods
1 parent d573c80 commit 3f7aca8

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

openai_client/build.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,11 +1379,20 @@ fn parse_endpoint_path(path_schema: &Yaml, client_output_file: &mut File) {
13791379

13801380
if let Some(response_content_hash) = ok_response["content"].as_hash() {
13811381
if response_content_hash.len() == 1 {
1382-
writeln!(
1383-
client_output_file,
1384-
"\t\tOk(serde_json::from_slice(&response_bytes)?)"
1385-
)
1386-
.unwrap();
1382+
// This is a special case
1383+
if result_type == "String" {
1384+
writeln!(
1385+
client_output_file,
1386+
"\t\tOk(String::from_utf8(response_bytes.to_vec())?)"
1387+
)
1388+
.unwrap();
1389+
} else {
1390+
writeln!(
1391+
client_output_file,
1392+
"\t\tOk(serde_json::from_slice(&response_bytes)?)"
1393+
)
1394+
.unwrap();
1395+
}
13871396
} else {
13881397
writeln!(client_output_file, "\t\tmatch _content_type.as_str() {{").unwrap();
13891398
for (response_name, _) in response_content_hash {

openai_client/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ Please [contact us](https://help.openai.com/) if you need to increase these stor
12641264
if status_code != 200 {
12651265
return Err(ConversaError::UnexpectedStatusCode{code: status_code, response: String::from_utf8(response_bytes.to_vec())?})
12661266
}
1267-
Ok(serde_json::from_slice(&response_bytes)?)
1267+
Ok(String::from_utf8(response_bytes.to_vec())?)
12681268
}
12691269

12701270
/** Run a grader. */

0 commit comments

Comments
 (0)