diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/java/ChatFutures.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/java/ChatFutures.kt index 6d21b899..ef9c418d 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/java/ChatFutures.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/java/ChatFutures.kt @@ -46,18 +46,18 @@ abstract class ChatFutures internal constructor() { */ abstract fun sendMessageStream(prompt: Content): Publisher - /** Returns the previous interactions with the model */ - abstract fun getHistory(): ArrayList + /** Returns the [Chat] instance that was used to create this instance */ + abstract fun getChat(): Chat - private class FuturesImpl(val chat: Chat) : ChatFutures() { + private class FuturesImpl(private val chat: Chat) : ChatFutures() { override fun sendMessage(prompt: Content): ListenableFuture = SuspendToFutureAdapter.launchFuture { chat.sendMessage(prompt) } override fun sendMessageStream(prompt: Content): Publisher = chat.sendMessageStream(prompt).asPublisher() - override fun getHistory(): ArrayList { - return ArrayList(chat.history) + override fun getChat(): Chat { + return chat } } diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/java/GenerativeModelFutures.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/java/GenerativeModelFutures.kt index 36d2b34a..c2df839f 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/java/GenerativeModelFutures.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/java/GenerativeModelFutures.kt @@ -64,7 +64,10 @@ abstract class GenerativeModelFutures internal constructor() { */ abstract fun startChat(history: List): ChatFutures - private class FuturesImpl(val model: GenerativeModel) : GenerativeModelFutures() { + /** Returns the [GenerativeModel] instance that was used to create this object */ + abstract fun getGenerativeModel(): GenerativeModel + + private class FuturesImpl(private val model: GenerativeModel) : GenerativeModelFutures() { override fun generateContent( vararg prompt: Content ): ListenableFuture = @@ -79,6 +82,10 @@ abstract class GenerativeModelFutures internal constructor() { override fun startChat(): ChatFutures = startChat(emptyList()) override fun startChat(history: List): ChatFutures = from(model.startChat(history)) + + override fun getGenerativeModel(): GenerativeModel { + return model + } } companion object {