Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbanda committed Nov 26, 2024
1 parent a8dfef8 commit 7e5d455
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ package object impl extends AnthropicServiceConsts {

case Message.UserMessageContent(contentBlocks) =>
val (newContentBlocks, remainingCache) =
contentBlocks.foldLeft((Seq.empty[ContentBlockBase], userMessagesToCacheCount)) {
case ((acc, cacheLeft), content) =>
val (block, newCacheLeft) =
toAnthropic(cacheLeft)(content.asInstanceOf[OpenAIContent])
(acc :+ block, newCacheLeft)
contentBlocks.foldLeft(
(Seq.empty[ContentBlockBase], userMessagesToCacheCount)
) { case ((acc, cacheLeft), content) =>
val (block, newCacheLeft) =
toAnthropic(cacheLeft)(content.asInstanceOf[OpenAIContent])
(acc :+ block, newCacheLeft)
}
(acc :+ Message.UserMessageContent(newContentBlocks), remainingCache)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ import akka.NotUsed
import akka.stream.Materializer
import akka.stream.scaladsl.Source
import io.cequence.openaiscala.domain.BaseMessage
import io.cequence.openaiscala.domain.response.{ChatCompletionChunkResponse, TextCompletionResponse}
import io.cequence.openaiscala.domain.settings.{CreateChatCompletionSettings, CreateCompletionSettings}
import io.cequence.openaiscala.domain.response.{
ChatCompletionChunkResponse,
TextCompletionResponse
}
import io.cequence.openaiscala.domain.settings.{
CreateChatCompletionSettings,
CreateCompletionSettings
}
import io.cequence.openaiscala.service.StreamedServiceTypes.OpenAIStreamedService
import io.cequence.openaiscala.service.adapter.{OpenAIChatCompletionServiceWrapper, OpenAICoreServiceWrapper, OpenAIServiceWrapper}
import io.cequence.openaiscala.service.adapter.{
OpenAIChatCompletionServiceWrapper,
OpenAICoreServiceWrapper,
OpenAIServiceWrapper
}
import io.cequence.wsclient.domain.WsRequestContext
import io.cequence.wsclient.service.CloseableService
import io.cequence.wsclient.service.adapter.ServiceWrapperTypes.CloseableServiceWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ object AnthropicCreateChatCompletionCachedWithOpenAIAdapter
messages = messages,
settings = CreateChatCompletionSettings(
NonOpenAIModelId.claude_3_5_sonnet_20241022
).setUseAnthropicSystemMessagesCache(true), // this is how we pass it through the adapter
).setUseAnthropicSystemMessagesCache(
true
) // this is how we pass it through the adapter
)
.map { content =>
println(content.choices.headOption.map(_.message.content).getOrElse("N/A"))
Expand Down

0 comments on commit 7e5d455

Please sign in to comment.