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
24
api/src/main/java/com/theokanning/openai/Usage.java
Normal file
24
api/src/main/java/com/theokanning/openai/Usage.java
Normal file
@ -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;
|
package com.theokanning.openai.completion;
|
||||||
|
|
||||||
|
import com.theokanning.openai.Usage;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -35,4 +36,9 @@ public class CompletionResult {
|
|||||||
* A list of generated completions.
|
* A list of generated completions.
|
||||||
*/
|
*/
|
||||||
List<CompletionChoice> choices;
|
List<CompletionChoice> choices;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The API usage for this request
|
||||||
|
*/
|
||||||
|
Usage usage;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.theokanning.openai.edit;
|
package com.theokanning.openai.edit;
|
||||||
|
|
||||||
|
import com.theokanning.openai.Usage;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,5 +31,5 @@ public class EditResult {
|
|||||||
/**
|
/**
|
||||||
* The API usage for this request
|
* 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
|
* 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
|
* https://beta.openai.com/docs/api-reference/edits/create
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Deprecated
|
||||||
public class EditUsage {
|
public class EditUsage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.theokanning.openai.embedding;
|
package com.theokanning.openai.embedding;
|
||||||
|
|
||||||
|
import com.theokanning.openai.Usage;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -26,4 +27,9 @@ public class EmbeddingResult {
|
|||||||
* A list of the calculated embeddings
|
* A list of the calculated embeddings
|
||||||
*/
|
*/
|
||||||
List<Embedding> data;
|
List<Embedding> data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The API usage for this request
|
||||||
|
*/
|
||||||
|
Usage usage;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user