Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add vertex specific count token request #171

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ data class GenerateContentRequest(
@Serializable
data class CountTokensRequest(@Transient val model: String? = null, val contents: List<Content>) :
Request

@Serializable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative that reduces code changes is this:

  1. Make CountTokenRequest contain the superset of fields
  2. Add two builder methods, one for generativeai that only accepts GenerateContentRequest and one for vertex that only accepts the fields supported by Vertex.
  3. When creating the field, only fill the right fields

Since fields not included are not encoded, then nothing else in the code needs to change.

data class VertexCountTokensRequest(
val model: String? = null,
val contents: List<Content>,
@SerialName("system_instruction") val systemInstruction: Content?,
val tools: List<Tool>? = null,
) : Request
Loading