Add usage data to Completion and Embedding APIs (#39)
Also changed EditResult to use the new shared object
This commit is contained in:
parent
83df513ddc
commit
5e14d4f62b
|
@ -0,0 +1,24 @@
|
|||
package com.theokanning.openai;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* The OpenAI resources used by a request
|
||||
*/
|
||||
@Data
|
||||
public class Usage {
|
||||
/**
|
||||
* The number of prompt tokens used.
|
||||
*/
|
||||
long promptTokens;
|
||||
|
||||
/**
|
||||
* The number of completion tokens used.
|
||||
*/
|
||||
long completionTokens;
|
||||
|
||||
/**
|
||||
* The number of total tokens used
|
||||
*/
|
||||
long totalTokens;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.theokanning.openai.completion;
|
||||
|
||||
import com.theokanning.openai.Usage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -35,4 +36,9 @@ public class CompletionResult {
|
|||
* A list of generated completions.
|
||||
*/
|
||||
List<CompletionChoice> choices;
|
||||
|
||||
/**
|
||||
* The API usage for this request
|
||||
*/
|
||||
Usage usage;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.theokanning.openai.edit;
|
||||
|
||||
import com.theokanning.openai.Usage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -30,5 +31,5 @@ public class EditResult {
|
|||
/**
|
||||
* The API usage for this request
|
||||
*/
|
||||
public EditUsage usage;
|
||||
public Usage usage;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@ import lombok.Data;
|
|||
/**
|
||||
* An object containing the API usage for an edit request
|
||||
*
|
||||
* Deprecated, use {@link com.theokanning.openai.Usage} instead
|
||||
*
|
||||
* https://beta.openai.com/docs/api-reference/edits/create
|
||||
*/
|
||||
@Data
|
||||
@Deprecated
|
||||
public class EditUsage {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.theokanning.openai.embedding;
|
||||
|
||||
import com.theokanning.openai.Usage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -26,4 +27,9 @@ public class EmbeddingResult {
|
|||
* A list of the calculated embeddings
|
||||
*/
|
||||
List<Embedding> data;
|
||||
|
||||
/**
|
||||
* The API usage for this request
|
||||
*/
|
||||
Usage usage;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue