From 4f5d348151cea38b3da73c1131dc662b390d5cd3 Mon Sep 17 00:00:00 2001
From: Boris Burdiliak <boris.burdiliak@gmail.com>
Date: Tue, 12 Nov 2024 14:23:55 +0100
Subject: [PATCH] scalafmt

---
 .../io/cequence/openaiscala/anthropic/JsonFormats.scala   | 1 -
 .../cequence/openaiscala/anthropic/domain/Message.scala   | 1 -
 .../anthropic/service/impl/AnthropicServiceImpl.scala     | 2 +-
 .../impl/OpenAIAnthropicChatCompletionService.scala       | 1 -
 .../openaiscala/anthropic/service/impl/package.scala      | 2 +-
 .../service/impl/OpenAIChatCompletionServiceImpl.scala    | 1 -
 .../main/scala/io/cequence/openaiscala/domain/Batch.scala | 8 ++++----
 .../domain/settings/CreateChatCompletionSettings.scala    | 2 --
 .../openaiscala/service/OpenAIChatCompletionExtra.scala   | 2 +-
 .../adapter/ChatCompletionSettingsConversions.scala       | 1 -
 .../openaiscala/service/adapter/RetryServiceAdapter.scala | 2 +-
 .../examples/adapter/RetryAdapterExample.scala            | 1 -
 .../nonopenai/AnthropicCreateMessageWithPdf.scala         | 4 +---
 .../examples/nonopenai/AnthropicCreateSystemMessage.scala | 1 -
 14 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/JsonFormats.scala b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/JsonFormats.scala
index 3cbcddc3..23d8a420 100644
--- a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/JsonFormats.scala
+++ b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/JsonFormats.scala
@@ -1,6 +1,5 @@
 package io.cequence.openaiscala.anthropic
 
-import io.cequence.openaiscala.anthropic.domain.CacheControl.Ephemeral
 import io.cequence.openaiscala.anthropic.domain.Content.ContentBlock.{MediaBlock, TextBlock}
 import io.cequence.openaiscala.anthropic.domain.Content.{
   ContentBlockBase,
diff --git a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/domain/Message.scala b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/domain/Message.scala
index 31a0eebc..f694a5c6 100644
--- a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/domain/Message.scala
+++ b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/domain/Message.scala
@@ -1,7 +1,6 @@
 package io.cequence.openaiscala.anthropic.domain
 
 import io.cequence.openaiscala.anthropic.domain.Content.{
-  ContentBlock,
   ContentBlockBase,
   ContentBlocks,
   SingleString
diff --git a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/AnthropicServiceImpl.scala b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/AnthropicServiceImpl.scala
index 0af924f7..bcb0061d 100644
--- a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/AnthropicServiceImpl.scala
+++ b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/AnthropicServiceImpl.scala
@@ -94,7 +94,7 @@ private[service] trait AnthropicServiceImpl extends Anthropic {
     val messageJsons = messages.map(Json.toJson(_))
 
     val systemJson = system.map {
-      case single @ Content.SingleString(text, cacheControl) =>
+      case Content.SingleString(text, cacheControl) =>
         if (cacheControl.isEmpty) JsString(text)
         else {
           val blocks =
diff --git a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/OpenAIAnthropicChatCompletionService.scala b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/OpenAIAnthropicChatCompletionService.scala
index b5126f6a..ee1a4061 100644
--- a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/OpenAIAnthropicChatCompletionService.scala
+++ b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/OpenAIAnthropicChatCompletionService.scala
@@ -2,7 +2,6 @@ package io.cequence.openaiscala.anthropic.service.impl
 
 import akka.NotUsed
 import akka.stream.scaladsl.Source
-import io.cequence.openaiscala.anthropic.domain.Content
 import io.cequence.openaiscala.anthropic.service.AnthropicService
 import io.cequence.openaiscala.domain.BaseMessage
 import io.cequence.openaiscala.domain.response.{
diff --git a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/package.scala b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/package.scala
index 335bddfe..98c8be21 100644
--- a/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/package.scala
+++ b/anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/impl/package.scala
@@ -80,7 +80,7 @@ package object impl extends AnthropicServiceConsts {
       .foldLeft((List.empty[Message], countUserMessagesToCache)) {
         case ((acc, userMessagesToCache), message) =>
           message match {
-            case Message.UserMessage(contentString, cacheControl) =>
+            case Message.UserMessage(contentString, _) =>
               val newCacheControl = if (userMessagesToCache > 0) Some(Ephemeral) else None
               (
                 acc :+ Message.UserMessage(contentString, newCacheControl),
diff --git a/openai-client/src/main/scala/io/cequence/openaiscala/service/impl/OpenAIChatCompletionServiceImpl.scala b/openai-client/src/main/scala/io/cequence/openaiscala/service/impl/OpenAIChatCompletionServiceImpl.scala
index 06b81cb1..762125f4 100644
--- a/openai-client/src/main/scala/io/cequence/openaiscala/service/impl/OpenAIChatCompletionServiceImpl.scala
+++ b/openai-client/src/main/scala/io/cequence/openaiscala/service/impl/OpenAIChatCompletionServiceImpl.scala
@@ -11,7 +11,6 @@ import io.cequence.openaiscala.service.adapter.{
 import io.cequence.openaiscala.service.{OpenAIChatCompletionService, OpenAIServiceConsts}
 import io.cequence.wsclient.JsonUtil
 import io.cequence.wsclient.ResponseImplicits._
-import io.cequence.wsclient.service.WSClient
 import io.cequence.wsclient.service.WSClientWithEngineTypes.WSClientWithEngine
 import play.api.libs.json.{JsObject, JsValue, Json}
 
diff --git a/openai-core/src/main/scala/io/cequence/openaiscala/domain/Batch.scala b/openai-core/src/main/scala/io/cequence/openaiscala/domain/Batch.scala
index b35c2fbf..620bdd7a 100644
--- a/openai-core/src/main/scala/io/cequence/openaiscala/domain/Batch.scala
+++ b/openai-core/src/main/scala/io/cequence/openaiscala/domain/Batch.scala
@@ -87,15 +87,15 @@ object Batch {
     request_counts: Map[String, Int],
     metadata: Option[Map[String, String]]
   ) {
-    def isRunning =
+    def isRunning: Boolean =
       List("in_progress", "validating", "finalizing", "cancelling").contains(status)
 
     // "failed", "completed", "expired", "cancelled"
-    def isFinished = !isRunning
+    def isFinished: Boolean = !isRunning
 
-    def isSuccess = status == "completed"
+    def isSuccess: Boolean = status == "completed"
 
-    def isFailedOrCancelledOrExpired = isFinished && !isSuccess
+    def isFailedOrCancelledOrExpired: Boolean = isFinished && !isSuccess
   }
 
   case class BatchProcessingErrors(
diff --git a/openai-core/src/main/scala/io/cequence/openaiscala/domain/settings/CreateChatCompletionSettings.scala b/openai-core/src/main/scala/io/cequence/openaiscala/domain/settings/CreateChatCompletionSettings.scala
index 651a3164..04134143 100644
--- a/openai-core/src/main/scala/io/cequence/openaiscala/domain/settings/CreateChatCompletionSettings.scala
+++ b/openai-core/src/main/scala/io/cequence/openaiscala/domain/settings/CreateChatCompletionSettings.scala
@@ -2,8 +2,6 @@ package io.cequence.openaiscala.domain.settings
 
 import io.cequence.wsclient.domain.EnumValue
 
-import scala.util.Try
-
 case class CreateChatCompletionSettings(
   // ID of the model to use. Currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported.
   model: String,
diff --git a/openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIChatCompletionExtra.scala b/openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIChatCompletionExtra.scala
index ef615f8d..ec48c79f 100644
--- a/openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIChatCompletionExtra.scala
+++ b/openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIChatCompletionExtra.scala
@@ -135,7 +135,7 @@ object OpenAIChatCompletionExtra {
     settings: CreateChatCompletionSettings,
     taskNameForLogging: String,
     jsonSchemaModels: Seq[String] = defaultJsonSchemaModels
-  ) = {
+  ): (Seq[BaseMessage], CreateChatCompletionSettings) = {
     val jsonSchemaDef = settings.jsonSchema.getOrElse(
       throw new IllegalArgumentException("JSON schema is not defined but expected.")
     )
diff --git a/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/ChatCompletionSettingsConversions.scala b/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/ChatCompletionSettingsConversions.scala
index ebfdf350..b846c43e 100644
--- a/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/ChatCompletionSettingsConversions.scala
+++ b/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/ChatCompletionSettingsConversions.scala
@@ -1,6 +1,5 @@
 package io.cequence.openaiscala.service.adapter
 
-import io.cequence.openaiscala.domain.response.ResponseFormat
 import io.cequence.openaiscala.domain.settings.{
   ChatCompletionResponseFormatType,
   CreateChatCompletionSettings
diff --git a/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/RetryServiceAdapter.scala b/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/RetryServiceAdapter.scala
index 8fbec409..43540a0e 100644
--- a/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/RetryServiceAdapter.scala
+++ b/openai-core/src/main/scala/io/cequence/openaiscala/service/adapter/RetryServiceAdapter.scala
@@ -1,7 +1,7 @@
 package io.cequence.openaiscala.service.adapter
 
 import akka.actor.Scheduler
-import io.cequence.openaiscala.{RetryHelpers, Retryable}
+import io.cequence.openaiscala.RetryHelpers
 import io.cequence.openaiscala.RetryHelpers.RetrySettings
 import io.cequence.wsclient.service.CloseableService
 
diff --git a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/adapter/RetryAdapterExample.scala b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/adapter/RetryAdapterExample.scala
index e07072ad..5791897a 100644
--- a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/adapter/RetryAdapterExample.scala
+++ b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/adapter/RetryAdapterExample.scala
@@ -1,6 +1,5 @@
 package io.cequence.openaiscala.examples.adapter
 
-import akka.actor.Scheduler
 import io.cequence.openaiscala.{OpenAIScalaClientException, OpenAIScalaClientTimeoutException}
 import io.cequence.openaiscala.RetryHelpers.RetrySettings
 import io.cequence.openaiscala.domain.settings.CreateChatCompletionSettings
diff --git a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateMessageWithPdf.scala b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateMessageWithPdf.scala
index c162909e..c2582bad 100644
--- a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateMessageWithPdf.scala
+++ b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateMessageWithPdf.scala
@@ -10,11 +10,9 @@ import io.cequence.openaiscala.anthropic.service.{AnthropicService, AnthropicSer
 import io.cequence.openaiscala.domain.NonOpenAIModelId
 import io.cequence.openaiscala.examples.ExampleBase
 
-import java.awt.image.RenderedImage
-import java.io.{ByteArrayOutputStream, File}
+import java.io.File
 import java.nio.file.Files
 import java.util.Base64
-import javax.imageio.ImageIO
 import scala.concurrent.Future
 
 // requires `openai-scala-anthropic-client` as a dependency
diff --git a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateSystemMessage.scala b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateSystemMessage.scala
index a345d3fb..9872fda8 100644
--- a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateSystemMessage.scala
+++ b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateSystemMessage.scala
@@ -1,6 +1,5 @@
 package io.cequence.openaiscala.examples.nonopenai
 
-import io.cequence.openaiscala.anthropic.domain.CacheControl.Ephemeral
 import io.cequence.openaiscala.anthropic.domain.Content.ContentBlock.TextBlock
 import io.cequence.openaiscala.anthropic.domain.Content.{ContentBlockBase, SingleString}
 import io.cequence.openaiscala.anthropic.domain.{Content, Message}