Skip to content

Commit

Permalink
BREAKING_CHANGE: [vertexai] remove GenerateContentConfig (#10576)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 617275853

Co-authored-by: Jaycee Li <jayceeli@google.com>
  • Loading branch information
copybara-service[bot] and jaycee-li committed Mar 20, 2024
1 parent d514d9a commit 31f5e12
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 458 deletions.
Expand Up @@ -53,22 +53,7 @@ public ChatSession(GenerativeModel model) {
*/
@BetaApi
public ResponseStream<GenerateContentResponse> sendMessageStream(String text) throws IOException {
return sendMessageStream(text, GenerateContentConfig.newBuilder().build());
}

/**
* Sends a message to the model and returns a stream of responses.
*
* @param text the message to be sent.
* @param config a {@link GenerateContentConfig} that contains all the configs for sending message
* in a chat session.
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
* stream by stream() method.
*/
@BetaApi
public ResponseStream<GenerateContentResponse> sendMessageStream(
String text, GenerateContentConfig config) throws IOException {
return sendMessageStream(ContentMaker.fromString(text), config);
return sendMessageStream(ContentMaker.fromString(text));
}

/**
Expand All @@ -81,25 +66,9 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
@BetaApi
public ResponseStream<GenerateContentResponse> sendMessageStream(Content content)
throws IOException, IllegalArgumentException {
return sendMessageStream(content, GenerateContentConfig.newBuilder().build());
}

/**
* Sends a message to the model and returns a stream of responses.
*
* @param content the content to be sent.
* @param config a {@link GenerateContentConfig} that contains all the configs for sending message
* in a chat session.
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
* stream by stream() method.
*/
@BetaApi
public ResponseStream<GenerateContentResponse> sendMessageStream(
Content content, GenerateContentConfig config) throws IOException {
checkLastResponseAndEditHistory();
history.add(content);
ResponseStream<GenerateContentResponse> respStream =
model.generateContentStream(history, config);
ResponseStream<GenerateContentResponse> respStream = model.generateContentStream(history);
currentResponseStream = respStream;
currentResponse = null;
return respStream;
Expand All @@ -113,21 +82,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
*/
@BetaApi
public GenerateContentResponse sendMessage(String text) throws IOException {
return sendMessage(text, GenerateContentConfig.newBuilder().build());
}

/**
* Sends a message to the model and returns a response.
*
* @param text the message to be sent.
* @param config a {@link GenerateContentConfig} that contains all the configs for sending message
* in a chat session.
* @return a response.
*/
@BetaApi
public GenerateContentResponse sendMessage(String text, GenerateContentConfig config)
throws IOException {
return sendMessage(ContentMaker.fromString(text), config);
return sendMessage(ContentMaker.fromString(text));
}

/**
Expand All @@ -138,23 +93,9 @@ public GenerateContentResponse sendMessage(String text, GenerateContentConfig co
*/
@BetaApi
public GenerateContentResponse sendMessage(Content content) throws IOException {
return sendMessage(content, GenerateContentConfig.newBuilder().build());
}

/**
* Sends a message to the model and returns a response.
*
* @param content the content to be sent.
* @param config a {@link GenerateContentConfig} that contains all the configs for sending message
* in a chat session.
* @return a response.
*/
@BetaApi
public GenerateContentResponse sendMessage(Content content, GenerateContentConfig config)
throws IOException {
checkLastResponseAndEditHistory();
history.add(content);
GenerateContentResponse response = model.generateContent(history, config);
GenerateContentResponse response = model.generateContent(history);
currentResponse = response;
currentResponseStream = null;
return response;
Expand Down

This file was deleted.

0 comments on commit 31f5e12

Please sign in to comment.