Closed itneedme closed 9 months ago
Thank you for the detailed description. I just submitted the code to fix it.
Add Class LogProbs:
@Data
public class LogProbs {
List<String> tokens;
@JsonProperty("token_logprobs")
List<Double> tokenLogprobs;
@JsonProperty("top_logprobs")
List<Map<String, Double>> topLogprobs;
@JsonProperty("text_offset")
List<Integer> textOffset;
}
Thank you for your efforts in updating the code. However, I noticed that the recent changes might still not align with the OpenAI official documentation. According to the OpenAI API documentation, the logprobs field is an integer in the request object but an object in the response.
In your latest commit, the LogProbs class seems to be designed with several lists, which may not fully comply with the OpenAI documentation's definition for the request object. I recommend reviewing the OpenAI API documentation again to ensure that the implementation of the logprobs field in the response matches the official documentation. This will help avoid potential serialization or deserialization issues in the future.
Thank you for your contribution to the project, and I hope this suggestion is helpful.
The logprobs in com.hw.openai.entity.completions.Completion request is an integer.
package com.hw.openai.entity.completions;
public class Completion implements Serializable {
private Integer logprobs;
}
The logprobs in com.hw.openai.entity.completions.Choice response is an LogProbs.
package com.hw.openai.entity.completions;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Choice {
private String text;
private Integer index;
private LogProbs logprobs;
@JsonProperty("finish_reason")
private String finishReason;
}
Based on the openai documents, I change the array to the List in java.
@Data
public class LogProbs {
List<String> tokens;
@JsonProperty("token_logprobs")
List<Double> tokenLogprobs;
@JsonProperty("top_logprobs")
List<Map<String, Double>> topLogprobs;
@JsonProperty("text_offset")
List<Integer> textOffset;
}
If the above code is incorrect or may lead to deserialization errors, could you provide me with a detailed example that includes the fields within logprobs? Thank you.
The official documentation as well as the fields within logprobs you provided earlier are all null.
"logprobs":{
"tokens":null,
"token_logprobs":null,
"top_logprobs":null,
"text_offset":null
}
Thank you so much for your prompt and effective resolution to this issue.
Describe the bug When I request the /v1/completions api, i got a exception which says the JSON response seems to have logprobs as an object (START_OBJECT token), but the Java code is expecting an integer value (Cannot deserialize instance of java.lang.Integer``).
Log and Stack trace exception details :
To Reproduce just request the /v1/completions openai api.
Expected behavior expeted bahavior is none exception with a success response.
Please complete the following information:
Additional context this openai api reference snapshot.